Skip to content

Commit e16ad44

Browse files
authored
[PM-17242] While on autofill search on all item types. (#4824)
1 parent d26a2ee commit e16ad44

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModel.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,9 +1049,15 @@ class VaultItemListingViewModel @Inject constructor(
10491049
}
10501050

10511051
private fun handleSearchIconClick() {
1052+
val searchType = if (state.autofillSelectionData != null) {
1053+
SearchType.Vault.All
1054+
} else {
1055+
state.itemListingType.toSearchType()
1056+
}
1057+
10521058
sendEvent(
10531059
event = VaultItemListingEvent.NavigateToSearchScreen(
1054-
searchType = state.itemListingType.toSearchType(),
1060+
searchType = searchType,
10551061
),
10561062
)
10571063
}

app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModelTest.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,24 @@ class VaultItemListingViewModelTest : BaseViewModelTest() {
339339
}
340340
}
341341

342+
@Test
343+
fun `SearchIconClick should emit NavigateToVaultSearchScreen with all search type`() = runTest {
344+
specialCircumstanceManager.specialCircumstance = SpecialCircumstance.AutofillSelection(
345+
autofillSelectionData = AutofillSelectionData(
346+
framework = AutofillSelectionData.Framework.ACCESSIBILITY,
347+
type = AutofillSelectionData.Type.LOGIN,
348+
uri = null,
349+
),
350+
shouldFinishWhenComplete = false,
351+
)
352+
val searchType = SearchType.Vault.All
353+
val viewModel = createVaultItemListingViewModel()
354+
viewModel.eventFlow.test {
355+
viewModel.trySendAction(VaultItemListingsAction.SearchIconClick)
356+
assertEquals(VaultItemListingEvent.NavigateToSearchScreen(searchType), awaitItem())
357+
}
358+
}
359+
342360
@Test
343361
fun `LockClick should call lockVaultForCurrentUser`() {
344362
every { vaultRepository.lockVaultForCurrentUser() } just runs

0 commit comments

Comments
 (0)