diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlocked/VaultUnlockedNavigation.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlocked/VaultUnlockedNavigation.kt index d9264faca..98fa14fca 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlocked/VaultUnlockedNavigation.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlocked/VaultUnlockedNavigation.kt @@ -75,8 +75,11 @@ fun NavGraphBuilder.vaultUnlockedGraph( vaultItemListingDestinationAsRoot( onNavigateBack = { navController.popBackStack() }, onNavigateToVaultItemScreen = { navController.navigateToVaultItem(vaultItemId = it) }, - onNavigateToVaultAddItemScreen = { - navController.navigateToVaultAddEdit(VaultAddEditType.AddItem(it)) + onNavigateToVaultAddItemScreen = { cipherType, selectedFolderId -> + navController.navigateToVaultAddEdit( + VaultAddEditType.AddItem(cipherType), + selectedFolderId, + ) }, onNavigateToSearchVault = { navController.navigateToSearch(searchType = it) }, onNavigateToVaultEditItemScreen = { @@ -86,8 +89,11 @@ fun NavGraphBuilder.vaultUnlockedGraph( vaultUnlockedNavBarDestination( onNavigateToExportVault = { navController.navigateToExportVault() }, onNavigateToFolders = { navController.navigateToFolders() }, - onNavigateToVaultAddItem = { - navController.navigateToVaultAddEdit(VaultAddEditType.AddItem(it)) + onNavigateToVaultAddItem = { cipherType, selectedFolderId -> + navController.navigateToVaultAddEdit( + VaultAddEditType.AddItem(cipherType), + selectedFolderId, + ) }, onNavigateToVaultItem = { navController.navigateToVaultItem(it) }, onNavigateToVaultEditItem = { diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarNavigation.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarNavigation.kt index af86915c2..5345f8873 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarNavigation.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarNavigation.kt @@ -25,7 +25,7 @@ fun NavController.navigateToVaultUnlockedNavBar(navOptions: NavOptions? = null) */ @Suppress("LongParameterList") fun NavGraphBuilder.vaultUnlockedNavBarDestination( - onNavigateToVaultAddItem: (VaultItemCipherType) -> Unit, + onNavigateToVaultAddItem: (VaultItemCipherType, String?) -> Unit, onNavigateToVaultItem: (vaultItemId: String) -> Unit, onNavigateToVaultEditItem: (vaultItemId: String) -> Unit, onNavigateToSearchSend: (searchType: SearchType.Sends) -> Unit, diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarScreen.kt index 1a3b029cd..b0c011c5e 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarScreen.kt @@ -64,7 +64,7 @@ import com.x8bit.bitwarden.ui.vault.model.VaultItemCipherType fun VaultUnlockedNavBarScreen( viewModel: VaultUnlockedNavBarViewModel = hiltViewModel(), navController: NavHostController = rememberNavController(), - onNavigateToVaultAddItem: (VaultItemCipherType) -> Unit, + onNavigateToVaultAddItem: (VaultItemCipherType, String?) -> Unit, onNavigateToVaultItem: (vaultItemId: String) -> Unit, onNavigateToVaultEditItem: (vaultItemId: String) -> Unit, onNavigateToSearchSend: (searchType: SearchType.Sends) -> Unit, @@ -158,7 +158,7 @@ private fun VaultUnlockedNavBarScaffold( sendTabClickedAction: () -> Unit, generatorTabClickedAction: () -> Unit, settingsTabClickedAction: () -> Unit, - navigateToVaultAddItem: (VaultItemCipherType) -> Unit, + navigateToVaultAddItem: (VaultItemCipherType, String?) -> Unit, onNavigateToVaultItem: (vaultItemId: String) -> Unit, onNavigateToVaultEditItem: (vaultItemId: String) -> Unit, onNavigateToSearchSend: (searchType: SearchType.Sends) -> Unit, diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditNavigation.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditNavigation.kt index ea2ec0fa6..aa130f7f5 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditNavigation.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditNavigation.kt @@ -26,12 +26,14 @@ private const val ADD_ITEM_TYPE: String = "vault_add_item_type" private const val ADD_EDIT_ITEM_PREFIX: String = "vault_add_edit_item" private const val ADD_EDIT_ITEM_TYPE: String = "vault_add_edit_type" +private const val ADD_SELECTED_FOLDER_ID: String = "vault_add_selected_folder_id" private const val ADD_EDIT_ITEM_ROUTE: String = ADD_EDIT_ITEM_PREFIX + "/{$ADD_EDIT_ITEM_TYPE}" + "?$EDIT_ITEM_ID={$EDIT_ITEM_ID}" + - "?$ADD_ITEM_TYPE={$ADD_ITEM_TYPE}" + "?$ADD_ITEM_TYPE={$ADD_ITEM_TYPE}" + + "?$ADD_SELECTED_FOLDER_ID={$ADD_SELECTED_FOLDER_ID}" /** * Class to retrieve vault add & edit arguments from the [SavedStateHandle]. @@ -39,6 +41,7 @@ private const val ADD_EDIT_ITEM_ROUTE: String = @OmitFromCoverage data class VaultAddEditArgs( val vaultAddEditType: VaultAddEditType, + val selectedFolderId: String? = null, ) { constructor(savedStateHandle: SavedStateHandle) : this( vaultAddEditType = when (requireNotNull(savedStateHandle[ADD_EDIT_ITEM_TYPE])) { @@ -53,6 +56,7 @@ data class VaultAddEditArgs( CLONE_TYPE -> VaultAddEditType.CloneItem(requireNotNull(savedStateHandle[EDIT_ITEM_ID])) else -> throw IllegalStateException("Unknown VaultAddEditType.") }, + selectedFolderId = savedStateHandle[ADD_SELECTED_FOLDER_ID], ) } @@ -72,6 +76,10 @@ fun NavGraphBuilder.vaultAddEditDestination( route = ADD_EDIT_ITEM_ROUTE, arguments = listOf( navArgument(ADD_EDIT_ITEM_TYPE) { type = NavType.StringType }, + navArgument(ADD_SELECTED_FOLDER_ID) { + type = NavType.StringType + nullable = true + }, ), ) { VaultAddEditScreen( @@ -90,12 +98,14 @@ fun NavGraphBuilder.vaultAddEditDestination( */ fun NavController.navigateToVaultAddEdit( vaultAddEditType: VaultAddEditType, + selectedFolderId: String? = null, navOptions: NavOptions? = null, ) { navigate( route = "$ADD_EDIT_ITEM_PREFIX/${vaultAddEditType.toTypeString()}" + "?$EDIT_ITEM_ID=${vaultAddEditType.toIdOrNull()}" + - "?$ADD_ITEM_TYPE=${vaultAddEditType.toVaultItemCipherTypeOrNull()}", + "?$ADD_ITEM_TYPE=${vaultAddEditType.toVaultItemCipherTypeOrNull()}" + + "?$ADD_SELECTED_FOLDER_ID=$selectedFolderId", navOptions = navOptions, ) } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditViewModel.kt index 240d052ec..1f6b45979 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditViewModel.kt @@ -109,6 +109,7 @@ class VaultAddEditViewModel @Inject constructor( initialState = savedStateHandle[KEY_STATE] ?: run { val vaultAddEditType = VaultAddEditArgs(savedStateHandle).vaultAddEditType + val selectedFolderId = VaultAddEditArgs(savedStateHandle).selectedFolderId val isIndividualVaultDisabled = policyManager .getActivePolicies(type = PolicyTypeJson.PERSONAL_OWNERSHIP) .any() @@ -153,7 +154,9 @@ class VaultAddEditViewModel @Inject constructor( isIndividualVaultDisabled = isIndividualVaultDisabled, ) ?: VaultAddEditState.ViewState.Content( - common = VaultAddEditState.ViewState.Content.Common(), + common = VaultAddEditState.ViewState.Content.Common( + selectedFolderId = selectedFolderId, + ), isIndividualVaultDisabled = isIndividualVaultDisabled, type = vaultAddEditType.vaultItemCipherType.toItemType(), ) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/util/CipherViewExtensions.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/util/CipherViewExtensions.kt index 11f6fe81f..cc5776772 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/util/CipherViewExtensions.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/addedit/util/CipherViewExtensions.kt @@ -131,7 +131,8 @@ fun VaultAddEditState.ViewState.appendFolderAndOwnerData( common = currentContentState.common.copy( selectedFolderId = folderViewList.toSelectedFolderId( cipherView = currentContentState.common.originalCipher, - ), + ) + ?: currentContentState.common.selectedFolderId, availableFolders = folderViewList.toAvailableFolders( resourceManager = resourceManager, ), diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingNavigation.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingNavigation.kt index b076c532a..e9f424de7 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingNavigation.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingNavigation.kt @@ -64,7 +64,10 @@ fun NavGraphBuilder.vaultItemListingDestination( onNavigateToVaultItemScreen: (id: String) -> Unit, onNavigateToVaultEditItemScreen: (cipherId: String) -> Unit, onNavigateToVaultItemListing: (vaultItemListingType: VaultItemListingType) -> Unit, - onNavigateToVaultAddItemScreen: (vaultItemCipherType: VaultItemCipherType) -> Unit, + onNavigateToVaultAddItemScreen: ( + cipherType: VaultItemCipherType, + selectedFolderId: String?, + ) -> Unit, onNavigateToSearchVault: (searchType: SearchType.Vault) -> Unit, ) { internalVaultItemListingDestination( @@ -87,7 +90,10 @@ fun NavGraphBuilder.vaultItemListingDestinationAsRoot( onNavigateBack: () -> Unit, onNavigateToVaultItemScreen: (id: String) -> Unit, onNavigateToVaultEditItemScreen: (cipherId: String) -> Unit, - onNavigateToVaultAddItemScreen: (VaultItemCipherType) -> Unit, + onNavigateToVaultAddItemScreen: ( + cipherType: VaultItemCipherType, + selectedFolderId: String?, + ) -> Unit, onNavigateToSearchVault: (searchType: SearchType.Vault) -> Unit, ) { composableWithStayTransitions( @@ -128,7 +134,7 @@ fun NavGraphBuilder.sendItemListingDestination( onNavigateBack = onNavigateBack, onNavigateToAddSendItem = onNavigateToAddSendItem, onNavigateToEditSendItem = onNavigateToEditSendItem, - onNavigateToVaultAddItemScreen = { }, + onNavigateToVaultAddItemScreen = { _, _ -> }, onNavigateToVaultItemScreen = { }, onNavigateToVaultEditItemScreen = { }, onNavigateToVaultItemListing = { }, @@ -146,7 +152,10 @@ private fun NavGraphBuilder.internalVaultItemListingDestination( onNavigateToVaultItemScreen: (id: String) -> Unit, onNavigateToVaultEditItemScreen: (cipherId: String) -> Unit, onNavigateToVaultItemListing: (vaultItemListingType: VaultItemListingType) -> Unit, - onNavigateToVaultAddItemScreen: (vaultItemCipherType: VaultItemCipherType) -> Unit, + onNavigateToVaultAddItemScreen: ( + cipherType: VaultItemCipherType, + selectedFolderId: String?, + ) -> Unit, onNavigateToAddSendItem: () -> Unit, onNavigateToEditSendItem: (sendId: String) -> Unit, onNavigateToSearch: (searchType: SearchType) -> Unit, diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreen.kt index 3285eb877..7b86d7680 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreen.kt @@ -72,7 +72,10 @@ fun VaultItemListingScreen( onNavigateToVaultItem: (id: String) -> Unit, onNavigateToVaultEditItemScreen: (cipherVaultId: String) -> Unit, onNavigateToVaultItemListing: (vaultItemListingType: VaultItemListingType) -> Unit, - onNavigateToVaultAddItemScreen: (vaultItemCipherType: VaultItemCipherType) -> Unit, + onNavigateToVaultAddItemScreen: ( + vaultItemCipherType: VaultItemCipherType, + selectedFolderId: String?, + ) -> Unit, onNavigateToAddSendItem: () -> Unit, onNavigateToEditSendItem: (sendId: String) -> Unit, onNavigateToSearch: (searchType: SearchType) -> Unit, @@ -113,7 +116,10 @@ fun VaultItemListingScreen( } is VaultItemListingEvent.NavigateToAddVaultItem -> { - onNavigateToVaultAddItemScreen(event.vaultItemCipherType) + onNavigateToVaultAddItemScreen( + event.vaultItemCipherType, + event.selectedFolderId, + ) } is VaultItemListingEvent.NavigateToEditCipher -> { diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModel.kt index e1e8084ef..4af2169e7 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModel.kt @@ -534,6 +534,13 @@ class VaultItemListingViewModel @Inject constructor( private fun handleAddVaultItemClick() { val event = when (val itemListingType = state.itemListingType) { + is VaultItemListingState.ItemListingType.Vault.Folder -> { + VaultItemListingEvent.NavigateToAddVaultItem( + vaultItemCipherType = itemListingType.toVaultItemCipherType(), + selectedFolderId = itemListingType.folderId, + ) + } + is VaultItemListingState.ItemListingType.Vault -> { VaultItemListingEvent.NavigateToAddVaultItem( vaultItemCipherType = itemListingType.toVaultItemCipherType(), @@ -2089,7 +2096,7 @@ data class VaultItemListingState( get() = folderId ?.let { folderName.asText() } ?: R.string.folder_none.asText() - override val hasFab: Boolean get() = false + override val hasFab: Boolean get() = true } /** @@ -2150,6 +2157,7 @@ sealed class VaultItemListingEvent { */ data class NavigateToAddVaultItem( val vaultItemCipherType: VaultItemCipherType, + val selectedFolderId: String? = null, ) : VaultItemListingEvent() /** diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingStateExtensions.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingStateExtensions.kt index 87814f044..02fe69bb8 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingStateExtensions.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingStateExtensions.kt @@ -40,8 +40,8 @@ fun VaultItemListingState.ItemListingType.Vault.toVaultItemCipherType(): VaultIt is VaultItemListingState.ItemListingType.Vault.SshKey -> VaultItemCipherType.SSH_KEY is VaultItemListingState.ItemListingType.Vault.Login -> VaultItemCipherType.LOGIN is VaultItemListingState.ItemListingType.Vault.Collection -> VaultItemCipherType.LOGIN + is VaultItemListingState.ItemListingType.Vault.Folder -> VaultItemCipherType.LOGIN is VaultItemListingState.ItemListingType.Vault.Trash, - is VaultItemListingState.ItemListingType.Vault.Folder, -> { throw IllegalStateException( "Cannot create vault item from this VaultItemListingState!", diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultGraphNavigation.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultGraphNavigation.kt index 8b4a052fa..c1a030d54 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultGraphNavigation.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultGraphNavigation.kt @@ -20,7 +20,10 @@ const val VAULT_GRAPH_ROUTE: String = "vault_graph" @Suppress("LongParameterList") fun NavGraphBuilder.vaultGraph( navController: NavController, - onNavigateToVaultAddItemScreen: (vaultItemCipherType: VaultItemCipherType) -> Unit, + onNavigateToVaultAddItemScreen: ( + vaultItemCipherType: VaultItemCipherType, + selectedFolderId: String?, + ) -> Unit, onNavigateToVaultItemScreen: (vaultItemId: String) -> Unit, onNavigateToVaultEditItemScreen: (vaultItemId: String) -> Unit, onNavigateToSearchVault: (searchType: SearchType.Vault) -> Unit, @@ -33,7 +36,7 @@ fun NavGraphBuilder.vaultGraph( ) { vaultDestination( onNavigateToVaultAddItemScreen = { - onNavigateToVaultAddItemScreen(VaultItemCipherType.LOGIN) + onNavigateToVaultAddItemScreen(VaultItemCipherType.LOGIN, null) }, onNavigateToVaultItemScreen = onNavigateToVaultItemScreen, onNavigateToVaultEditItemScreen = onNavigateToVaultEditItemScreen, diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarScreenTest.kt index 0999c3b57..6311356eb 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlockednavbar/VaultUnlockedNavBarScreenTest.kt @@ -41,7 +41,7 @@ class VaultUnlockedNavBarScreenTest : BaseComposeTest() { VaultUnlockedNavBarScreen( viewModel = viewModel, navController = fakeNavHostController, - onNavigateToVaultAddItem = {}, + onNavigateToVaultAddItem = { _, _ -> }, onNavigateToVaultItem = {}, onNavigateToVaultEditItem = {}, onNavigateToAddSend = {}, diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreenTest.kt index f84921b60..de75be94c 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreenTest.kt @@ -117,7 +117,9 @@ class VaultItemListingScreenTest : BaseComposeTest() { biometricsManager = biometricsManager, onNavigateBack = { onNavigateBackCalled = true }, onNavigateToVaultItem = { onNavigateToVaultItemId = it }, - onNavigateToVaultAddItemScreen = { onNavigateToVaultAddItemScreenCalled = true }, + onNavigateToVaultAddItemScreen = { _, _ -> + onNavigateToVaultAddItemScreenCalled = true + }, onNavigateToAddSendItem = { onNavigateToAddSendScreenCalled = true }, onNavigateToEditSendItem = { onNavigateToEditSendItemId = it }, onNavigateToSearch = { onNavigateToSearchType = it }, diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModelTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModelTest.kt index 591a0f1e4..6035771f0 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModelTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingViewModelTest.kt @@ -942,6 +942,27 @@ class VaultItemListingViewModelTest : BaseViewModelTest() { } } + @Suppress("MaxLineLength") + @Test + fun `AddVaultItemClick inside a folder should emit NavigateToAddVaultItem with a selected folder id`() = + runTest { + val viewModel = createVaultItemListingViewModel( + savedStateHandle = createSavedStateHandleWithVaultItemListingType( + vaultItemListingType = VaultItemListingType.Folder(folderId = "id"), + ), + ) + viewModel.eventFlow.test { + viewModel.trySendAction(VaultItemListingsAction.AddVaultItemClick) + assertEquals( + VaultItemListingEvent.NavigateToAddVaultItem( + VaultItemCipherType.LOGIN, + selectedFolderId = "id", + ), + awaitItem(), + ) + } + } + @Test fun `AddVaultItemClick for vault item should emit NavigateToAddVaultItem`() = runTest { val viewModel = createVaultItemListingViewModel() diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingStateExtensionsTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingStateExtensionsTest.kt index 211d6dc58..0b2129f87 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingStateExtensionsTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingStateExtensionsTest.kt @@ -130,6 +130,7 @@ class VaultItemListingStateExtensionsTest { VaultItemListingState.ItemListingType.Vault.Login, VaultItemListingState.ItemListingType.Vault.Collection(collectionId = "mockId"), VaultItemListingState.ItemListingType.Vault.SshKey, + VaultItemListingState.ItemListingType.Vault.Folder(folderId = "mockId"), ) val result = itemListingTypes.map { it.toVaultItemCipherType() } @@ -142,6 +143,7 @@ class VaultItemListingStateExtensionsTest { VaultItemCipherType.LOGIN, VaultItemCipherType.LOGIN, VaultItemCipherType.SSH_KEY, + VaultItemCipherType.LOGIN, ), result, ) @@ -149,15 +151,8 @@ class VaultItemListingStateExtensionsTest { @Test fun `toVaultItemCipherType should throw an exception for unsupported ItemListingTypes`() { - val itemListingTypes = listOf( - VaultItemListingState.ItemListingType.Vault.Trash, - VaultItemListingState.ItemListingType.Vault.Folder( - folderId = "mockId", - ), - ) - - itemListingTypes.forEach { - assertThrows { it.toVaultItemCipherType() } + assertThrows { + VaultItemListingState.ItemListingType.Vault.Trash.toVaultItemCipherType() } } }