PM-43004: feat: Add ability to create login from Generator (#7453)

This commit is contained in:
David Perez authored and GitHub committed 2026-10-08 14:17:10 +00:00
1 parent 1d0f544a7a
commit 13ee3e7fbf
23 files changed
+323 -101

No files matched your search

@@ -244,7 +244,7 @@ fun RootNavScreen(
navController.navigateToVaultUnlockedGraph(rootNavOptions)
navController.navigateToVaultAddEdit(
args = VaultAddEditArgs(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = currentState.autofillSaveItem.toVaultItemCipherType(),
),
navOptions = rootNavOptions,
@@ -255,7 +255,7 @@ fun RootNavScreen(
navController.navigateToVaultUnlockedGraph(rootNavOptions)
navController.navigateToVaultAddEdit(
args = VaultAddEditArgs(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
navOptions = rootNavOptions,
@@ -221,6 +221,7 @@ private fun VaultUnlockedNavBarScaffold(
onNavigateToPlan = onNavigateToPlan,
)
generatorGraph(
navigateToVaultAddItem = navigateToVaultAddItem,
onNavigateToPasswordHistory = { navigateToPasswordHistory() },
onDimNavBarRequest = { shouldDim -> shouldDimNavBar = shouldDim },
)
@@ -4,6 +4,7 @@ import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptions
import androidx.navigation.navigation
import com.x8bit.bitwarden.ui.vault.feature.addedit.VaultAddEditArgs
import kotlinx.serialization.Serializable
/**
@@ -16,6 +17,7 @@ data object GeneratorGraphRoute
* Add generator destination to the root nav graph.
*/
fun NavGraphBuilder.generatorGraph(
navigateToVaultAddItem: (args: VaultAddEditArgs) -> Unit,
onNavigateToPasswordHistory: () -> Unit,
onDimNavBarRequest: (Boolean) -> Unit,
) {
@@ -23,6 +25,7 @@ fun NavGraphBuilder.generatorGraph(
startDestination = GeneratorRoute.Standard,
) {
generatorDestination(
navigateToVaultAddItem = navigateToVaultAddItem,
onNavigateToPasswordHistory = onNavigateToPasswordHistory,
onDimNavBarRequest = onDimNavBarRequest,
)
@@ -10,6 +10,7 @@ import com.bitwarden.ui.platform.base.util.composableWithRootPushTransitions
import com.bitwarden.ui.platform.base.util.composableWithSlideTransitions
import com.bitwarden.ui.platform.util.ParcelableRouteSerializer
import com.x8bit.bitwarden.ui.tools.feature.generator.model.GeneratorMode
import com.x8bit.bitwarden.ui.vault.feature.addedit.VaultAddEditArgs
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable
@@ -89,11 +90,13 @@ fun SavedStateHandle.toGeneratorArgs(): GeneratorArgs {
* Add generator destination to the root nav graph.
*/
fun NavGraphBuilder.generatorDestination(
navigateToVaultAddItem: (args: VaultAddEditArgs) -> Unit,
onNavigateToPasswordHistory: () -> Unit,
onDimNavBarRequest: (Boolean) -> Unit,
) {
composableWithRootPushTransitions<GeneratorRoute.Standard> {
GeneratorScreen(
navigateToVaultAddItem = navigateToVaultAddItem,
onNavigateToPasswordHistory = onNavigateToPasswordHistory,
onNavigateBack = {},
onDimNavBarRequest = onDimNavBarRequest,
@@ -109,6 +112,7 @@ fun NavGraphBuilder.generatorModalDestination(
) {
composableWithSlideTransitions<GeneratorRoute.Modal> {
GeneratorScreen(
navigateToVaultAddItem = {},
onNavigateToPasswordHistory = {},
onNavigateBack = onNavigateBack,
onDimNavBarRequest = {},
@@ -105,6 +105,9 @@ import com.x8bit.bitwarden.ui.tools.feature.generator.handlers.rememberRandomWor
import com.x8bit.bitwarden.ui.tools.feature.generator.handlers.rememberUsernameTypeHandlers
import com.x8bit.bitwarden.ui.tools.feature.generator.model.ExploreGeneratorCoachMark
import com.x8bit.bitwarden.ui.tools.feature.generator.model.GeneratorMode
import com.x8bit.bitwarden.ui.vault.feature.addedit.VaultAddEditArgs
import com.x8bit.bitwarden.ui.vault.model.VaultAddEditType
import com.x8bit.bitwarden.ui.vault.model.VaultItemCipherType
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
@@ -120,6 +123,7 @@ import kotlin.math.max
fun GeneratorScreen(
viewModel: GeneratorViewModel = hiltViewModel(),
onNavigateToPasswordHistory: () -> Unit,
navigateToVaultAddItem: (args: VaultAddEditArgs) -> Unit,
onNavigateBack: () -> Unit,
onDimNavBarRequest: (Boolean) -> Unit,
intentManager: IntentManager = LocalIntentManager.current,
@@ -154,6 +158,17 @@ fun GeneratorScreen(
val scope = rememberCoroutineScope()
EventsEffect(viewModel = viewModel) { event ->
when (event) {
is GeneratorEvent.NavigateToAddLogin -> {
navigateToVaultAddItem(
VaultAddEditArgs(
vaultAddEditType = VaultAddEditType.AddItem(
initialData = event.initialData,
),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
}
GeneratorEvent.NavigateToPasswordHistory -> onNavigateToPasswordHistory()
is GeneratorEvent.ShowSnackbar -> {
@@ -257,6 +272,7 @@ fun GeneratorScreen(
onRegenerateClick = { viewModel.trySendAction(GeneratorAction.RegenerateClick) },
onCopyClick = { viewModel.trySendAction(GeneratorAction.CopyClick) },
onSaveClick = { viewModel.trySendAction(GeneratorAction.SaveClick) },
onCreateLoginClick = { viewModel.trySendAction(GeneratorAction.CreateLoginClick) },
onUsernameSubStateOptionClicked = onUsernameOptionClicked,
passwordHandlers = passwordHandlers,
passphraseHandlers = passphraseHandlers,
@@ -351,6 +367,7 @@ private fun CoachMarkScope<ExploreGeneratorCoachMark>.ScrollContent(
onRegenerateClick: () -> Unit,
onCopyClick: () -> Unit,
onSaveClick: () -> Unit,
onCreateLoginClick: () -> Unit,
onUsernameSubStateOptionClicked: (GeneratorState.MainType.Username.UsernameTypeOption) -> Unit,
passwordHandlers: PasswordHandlers,
passphraseHandlers: PassphraseHandlers,
@@ -450,7 +467,7 @@ private fun CoachMarkScope<ExploreGeneratorCoachMark>.ScrollContent(
onShowPreviousCoachMark = onShowPreviousCoachMark,
onDismissCoachMark = onDismissCoachMark,
onShowNextCoachMark = onShowNextCoachMark,
onCopyClick = onCopyClick.takeIf { state.generatorMode is GeneratorMode.Modal },
onCopyClick = onCopyClick,
modifier = Modifier
.standardHorizontalMargin()
.fillMaxWidth(),
@@ -463,7 +480,7 @@ private fun CoachMarkScope<ExploreGeneratorCoachMark>.ScrollContent(
GeneratorMode.Default -> {
@Suppress("MaxLineLength")
coachMarkHighlightItem(
key = ExploreGeneratorCoachMark.COPY_PASSWORD_BUTTON,
key = ExploreGeneratorCoachMark.CREATE_LOGIN_BUTTON,
title = BitwardenString.coachmark_6_of_6.asText(),
description = BitwardenString
.after_you_save_your_new_password_to_bitwarden_don_t_forget_to_update_it_on_your_account_website
@@ -486,10 +503,10 @@ private fun CoachMarkScope<ExploreGeneratorCoachMark>.ScrollContent(
.standardHorizontalMargin(windowAdaptiveInfo = windowAdaptiveInfo),
) {
BitwardenFilledButton(
label = stringResource(id = BitwardenString.copy),
onClick = onCopyClick,
label = stringResource(id = BitwardenString.create_login),
onClick = onCreateLoginClick,
modifier = Modifier
.testTag(tag = "CopyValueButton")
.testTag(tag = "CreateLoginButton")
.fillMaxWidth(),
)
}
@@ -608,7 +625,7 @@ private fun CoachMarkScope<ExploreGeneratorCoachMark>.GeneratedStringItem(
onShowPreviousCoachMark: () -> Unit,
onDismissCoachMark: () -> Unit,
onShowNextCoachMark: () -> Unit,
onCopyClick: (() -> Unit)?,
onCopyClick: () -> Unit,
modifier: Modifier = Modifier,
) {
BitwardenTextField(
@@ -645,14 +662,12 @@ private fun CoachMarkScope<ExploreGeneratorCoachMark>.GeneratedStringItem(
modifier = Modifier.testTag("RegenerateValueButton"),
)
}
onCopyClick?.let {
BitwardenStandardIconButton(
vectorIconRes = BitwardenDrawable.ic_copy,
contentDescription = stringResource(id = BitwardenString.copy),
onClick = it,
modifier = Modifier.testTag(tag = "CopyValueButton"),
)
}
BitwardenStandardIconButton(
vectorIconRes = BitwardenDrawable.ic_copy,
contentDescription = stringResource(id = BitwardenString.copy),
onClick = onCopyClick,
modifier = Modifier.testTag(tag = "CopyValueButton"),
)
},
onValueChange = {},
readOnly = true,
@@ -1608,6 +1623,7 @@ private fun RandomWordIncludeNumberToggleItem(
private fun Generator_preview() {
BitwardenTheme {
GeneratorScreen(
navigateToVaultAddItem = {},
onNavigateToPasswordHistory = {},
onNavigateBack = {},
onDimNavBarRequest = {},
@@ -50,6 +50,7 @@ import com.x8bit.bitwarden.ui.tools.feature.generator.util.GeneratorRequestResul
import com.x8bit.bitwarden.ui.tools.feature.generator.util.toServiceType
import com.x8bit.bitwarden.ui.tools.feature.generator.util.toStrictestPolicy
import com.x8bit.bitwarden.ui.tools.feature.generator.util.toUsernameGeneratorRequest
import com.x8bit.bitwarden.ui.vault.model.VaultAddEditType
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.launchIn
@@ -157,6 +158,7 @@ class GeneratorViewModel @Inject constructor(
is GeneratorAction.SaveClick -> handleSaveClick()
is GeneratorAction.RegenerateClick -> handleRegenerateClick()
is GeneratorAction.CopyClick -> handleCopyClick()
is GeneratorAction.CreateLoginClick -> handleCreateLoginClick()
is GeneratorAction.MainTypeOptionSelect -> handleMainTypeOptionSelect(action)
is GeneratorAction.MainType -> handleMainTypeAction(action)
is GeneratorAction.Internal -> handleInternalAction(action)
@@ -725,6 +727,24 @@ class GeneratorViewModel @Inject constructor(
clipboardManager.setText(text = state.generatedText)
}
private fun handleCreateLoginClick() {
sendEvent(
GeneratorEvent.NavigateToAddLogin(
initialData = when (state.selectedType.mainTypeOption) {
GeneratorState.MainTypeOption.USERNAME -> {
VaultAddEditType.AddItem.InitialData.Username(value = state.generatedText)
}
GeneratorState.MainTypeOption.PASSWORD,
GeneratorState.MainTypeOption.PASSPHRASE,
-> {
VaultAddEditType.AddItem.InitialData.Password(value = state.generatedText)
}
},
),
)
}
private fun handleTooltipClick() {
sendEvent(GeneratorEvent.NavigateToTooltip)
}
@@ -2368,10 +2388,15 @@ sealed class GeneratorAction {
data object PasswordHistoryClick : GeneratorAction()
/**
* Indicates the user has selected a generated string from the modal generator
* Indicates the user has selected a generated string from the modal generator.
*/
data object SaveClick : GeneratorAction()
/**
* Indicates the user has selected to create a login from the generated value.
*/
data object CreateLoginClick : GeneratorAction()
/**
* Indicates the user has clicked the close button.
*/
@@ -2837,6 +2862,13 @@ sealed class GeneratorEvent {
*/
data object NavigateBack : GeneratorEvent()
/**
* Navigate to create a Login with the generated data.
*/
data class NavigateToAddLogin(
val initialData: VaultAddEditType.AddItem.InitialData,
) : GeneratorEvent()
/**
* Navigate back to learn more screen.
*/
@@ -9,5 +9,5 @@ enum class ExploreGeneratorCoachMark {
USERNAME_MODE,
PASSWORD_OPTIONS,
GENERATE_BUTTON,
COPY_PASSWORD_BUTTON,
CREATE_LOGIN_BUTTON,
}
@@ -19,6 +19,8 @@ data class VaultAddEditRoute(
val vaultAddEditMode: VaultAddEditMode,
val vaultItemId: String?,
val vaultItemCipherType: VaultItemCipherType,
val initialValueType: InitialValueType?,
val initialValue: String?,
val selectedFolderId: String? = null,
val selectedCollectionId: String? = null,
)
@@ -33,6 +35,15 @@ enum class VaultAddEditMode {
CLONE,
}
/**
* The type of initial data that is being provided.
*/
@Serializable
enum class InitialValueType {
PASSWORD,
USERNAME,
}
/**
* Class to retrieve vault add & edit arguments from the [SavedStateHandle].
*/
@@ -50,7 +61,22 @@ fun SavedStateHandle.toVaultAddEditArgs(): VaultAddEditArgs {
val route = this.toRoute<VaultAddEditRoute>()
return VaultAddEditArgs(
vaultAddEditType = when (route.vaultAddEditMode) {
VaultAddEditMode.ADD -> VaultAddEditType.AddItem
VaultAddEditMode.ADD -> {
VaultAddEditType.AddItem(
initialData = when (route.initialValueType) {
InitialValueType.PASSWORD -> VaultAddEditType.AddItem.InitialData.Password(
value = requireNotNull(route.initialValue),
)
InitialValueType.USERNAME -> VaultAddEditType.AddItem.InitialData.Username(
value = requireNotNull(route.initialValue),
)
null -> null
},
)
}
VaultAddEditMode.EDIT -> {
VaultAddEditType.EditItem(vaultItemId = requireNotNull(route.vaultItemId))
}
@@ -102,13 +128,20 @@ fun NavController.navigateToVaultAddEdit(
args: VaultAddEditArgs,
navOptions: NavOptions? = null,
) {
val initialData = (args.vaultAddEditType as? VaultAddEditType.AddItem)?.initialData
navigate(
route = VaultAddEditRoute(
vaultAddEditMode = when (args.vaultAddEditType) {
VaultAddEditType.AddItem -> VaultAddEditMode.ADD
is VaultAddEditType.AddItem -> VaultAddEditMode.ADD
is VaultAddEditType.CloneItem -> VaultAddEditMode.CLONE
is VaultAddEditType.EditItem -> VaultAddEditMode.EDIT
},
initialValueType = when (initialData) {
is VaultAddEditType.AddItem.InitialData.Password -> InitialValueType.PASSWORD
is VaultAddEditType.AddItem.InitialData.Username -> InitialValueType.USERNAME
null -> null
},
initialValue = initialData?.value,
vaultItemId = args.vaultAddEditType.vaultItemId,
vaultItemCipherType = args.vaultItemCipherType,
selectedFolderId = args.selectedFolderId,
@@ -212,7 +212,9 @@ class VaultAddEditViewModel @Inject constructor(
selectedCollectionId = selectedCollectionId,
),
isIndividualVaultDisabled = isIndividualVaultDisabled,
type = vaultCipherType.toItemType(),
type = vaultCipherType.toItemType(
initialData = vaultAddEditType.initialData,
),
)
}
@@ -1,14 +1,21 @@
package com.x8bit.bitwarden.ui.vault.feature.addedit.util
import com.x8bit.bitwarden.ui.vault.feature.addedit.VaultAddEditState
import com.x8bit.bitwarden.ui.vault.model.VaultAddEditType.AddItem.InitialData
import com.x8bit.bitwarden.ui.vault.model.VaultItemCipherType
/**
* Transforms a [VaultItemCipherType] into [VaultAddEditState.ViewState.Content.ItemType].
*/
fun VaultItemCipherType.toItemType(): VaultAddEditState.ViewState.Content.ItemType =
fun VaultItemCipherType.toItemType(
initialData: InitialData?,
): VaultAddEditState.ViewState.Content.ItemType =
when (this) {
VaultItemCipherType.LOGIN -> VaultAddEditState.ViewState.Content.ItemType.Login()
VaultItemCipherType.LOGIN -> VaultAddEditState.ViewState.Content.ItemType.Login(
username = (initialData as? InitialData.Username)?.value.orEmpty(),
password = (initialData as? InitialData.Password)?.value.orEmpty(),
)
VaultItemCipherType.CARD -> VaultAddEditState.ViewState.Content.ItemType.Card()
VaultItemCipherType.IDENTITY -> VaultAddEditState.ViewState.Content.ItemType.Identity()
VaultItemCipherType.SECURE_NOTE -> VaultAddEditState.ViewState.Content.ItemType.SecureNotes
@@ -16,9 +23,11 @@ fun VaultItemCipherType.toItemType(): VaultAddEditState.ViewState.Content.ItemTy
VaultItemCipherType.BANK_ACCOUNT -> {
VaultAddEditState.ViewState.Content.ItemType.BankAccount()
}
VaultItemCipherType.DRIVERS_LICENSE -> {
VaultAddEditState.ViewState.Content.ItemType.License()
}
VaultItemCipherType.PASSPORT -> {
VaultAddEditState.ViewState.Content.ItemType.Passport()
}
@@ -118,7 +118,7 @@ fun VaultItemListingScreen(
is VaultItemListingEvent.NavigateToAddVaultItem -> {
onNavigateToVaultAddItemScreen(
VaultAddEditArgs(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = event.vaultItemCipherType,
selectedFolderId = event.selectedFolderId,
selectedCollectionId = event.selectedCollectionId,
@@ -131,7 +131,7 @@ fun VaultScreen(
is VaultEvent.NavigateToAddItemScreen -> {
onNavigateToVaultAddItemScreen(
VaultAddEditArgs(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = event.type,
),
)
@@ -17,8 +17,33 @@ sealed class VaultAddEditType : Parcelable {
* Indicates that we want to create a completely new vault item.
*/
@Parcelize
data object AddItem : VaultAddEditType() {
data class AddItem(
val initialData: InitialData? = null,
) : VaultAddEditType() {
override val vaultItemId: String? get() = null
/**
* When present, indicates that an initial value should be displayed for the new item.
*/
@Parcelize
sealed class InitialData : Parcelable {
/**
* The initial value.
*/
abstract val value: String
/**
* The initial value for a new password.
*/
@Parcelize
data class Password(override val value: String) : InitialData()
/**
* The initial value for a new username.
*/
@Parcelize
data class Username(override val value: String) : InitialData()
}
}
/**
@@ -261,6 +261,8 @@ class RootNavScreenTest : BitwardenComposeTest() {
vaultAddEditMode = VaultAddEditMode.ADD,
vaultItemId = null,
vaultItemCipherType = VaultItemCipherType.LOGIN,
initialValueType = null,
initialValue = null,
selectedFolderId = null,
selectedCollectionId = null,
),
@@ -284,6 +286,8 @@ class RootNavScreenTest : BitwardenComposeTest() {
vaultAddEditMode = VaultAddEditMode.ADD,
vaultItemId = null,
vaultItemCipherType = VaultItemCipherType.CARD,
initialValueType = null,
initialValue = null,
selectedFolderId = null,
selectedCollectionId = null,
),
@@ -330,6 +334,8 @@ class RootNavScreenTest : BitwardenComposeTest() {
vaultAddEditMode = VaultAddEditMode.ADD,
vaultItemId = null,
vaultItemCipherType = VaultItemCipherType.LOGIN,
initialValueType = null,
initialValue = null,
selectedFolderId = null,
selectedCollectionId = null,
),
@@ -37,6 +37,7 @@ import com.bitwarden.ui.util.isCoachMarkToolTip
import com.x8bit.bitwarden.data.platform.manager.util.AppResumeStateManager
import com.x8bit.bitwarden.ui.platform.base.BitwardenComposeTest
import com.x8bit.bitwarden.ui.tools.feature.generator.model.GeneratorMode
import com.x8bit.bitwarden.ui.vault.model.VaultAddEditType
import io.mockk.every
import io.mockk.just
import io.mockk.mockk
@@ -50,6 +51,8 @@ import org.junit.jupiter.api.Assertions.assertTrue
@Suppress("LargeClass")
class GeneratorScreenTest : BitwardenComposeTest() {
private var onNavigateToPasswordHistoryScreenCalled = false
private var onNavigateToVaultAddItemCalled = false
private var onNavigateBackCalled = false
private var onDimNavBarRequest: Boolean? = null
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
@@ -72,8 +75,9 @@ class GeneratorScreenTest : BitwardenComposeTest() {
) {
GeneratorScreen(
viewModel = viewModel,
navigateToVaultAddItem = { onNavigateToVaultAddItemCalled = true },
onNavigateToPasswordHistory = { onNavigateToPasswordHistoryScreenCalled = true },
onNavigateBack = {},
onNavigateBack = { onNavigateBackCalled = true },
onDimNavBarRequest = { onDimNavBarRequest = it },
)
}
@@ -273,6 +277,21 @@ class GeneratorScreenTest : BitwardenComposeTest() {
assertTrue(onNavigateToPasswordHistoryScreenCalled)
}
@Test
fun `NavigateToAddLogin event should call onNavigateToVaultAddItem`() {
val event = GeneratorEvent.NavigateToAddLogin(
initialData = VaultAddEditType.AddItem.InitialData.Username(value = "bitwarden_user"),
)
mutableEventFlow.tryEmit(event)
assertTrue(onNavigateToVaultAddItemCalled)
}
@Test
fun `NavigateBack event should call onNavigateBack`() {
mutableEventFlow.tryEmit(GeneratorEvent.NavigateBack)
assertTrue(onNavigateBackCalled)
}
@Test
fun `Snackbar should be displayed with correct message on ShowSnackbar event`() {
mutableEventFlow.tryEmit(GeneratorEvent.ShowSnackbar("Test Snackbar Message".asText()))
@@ -296,7 +315,7 @@ class GeneratorScreenTest : BitwardenComposeTest() {
@Test
fun `clicking the Copy button should send CopyClick action`() {
composeTestRule
.onNodeWithText(text = "Copy")
.onNodeWithContentDescription(label = "Copy")
.performClick()
verify {
@@ -304,6 +323,17 @@ class GeneratorScreenTest : BitwardenComposeTest() {
}
}
@Test
fun `clicking the Create login button should send CreateLoginClick action`() {
composeTestRule
.onNodeWithText(text = "Create login")
.performClick()
verify {
viewModel.trySendAction(GeneratorAction.CreateLoginClick)
}
}
@Test
fun `clicking a MainStateOption should send MainTypeOptionSelect action`() {
// Opens the menu
@@ -35,6 +35,7 @@ import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockSdkPolicy
import com.x8bit.bitwarden.ui.tools.feature.generator.GeneratorState.MainType.Username.UsernameType.ForwardedEmailAlias.ServiceType
import com.x8bit.bitwarden.ui.tools.feature.generator.GeneratorState.MainType.Username.UsernameType.ForwardedEmailAlias.ServiceTypeOption
import com.x8bit.bitwarden.ui.tools.feature.generator.model.GeneratorMode
import com.x8bit.bitwarden.ui.vault.model.VaultAddEditType
import io.mockk.every
import io.mockk.just
import io.mockk.mockk
@@ -584,6 +585,60 @@ class GeneratorViewModelTest : BaseViewModelTest() {
}
}
@Test
fun `CreateLoginClick for password state should emit NavigateToAddLogin with Password`() =
runTest {
val viewModel = createViewModel(state = initialPasscodeState)
viewModel.eventFlow.test {
viewModel.trySendAction(GeneratorAction.CreateLoginClick)
assertEquals(
GeneratorEvent.NavigateToAddLogin(
initialData = VaultAddEditType.AddItem.InitialData.Password(
value = viewModel.stateFlow.value.generatedText,
),
),
awaitItem(),
)
}
}
@Test
fun `CreateLoginClick for passphrase state should emit NavigateToAddLogin with Password`() =
runTest {
val viewModel = createViewModel(state = initialPassphraseState)
viewModel.eventFlow.test {
viewModel.trySendAction(GeneratorAction.CreateLoginClick)
assertEquals(
GeneratorEvent.NavigateToAddLogin(
initialData = VaultAddEditType.AddItem.InitialData.Password(
value = viewModel.stateFlow.value.generatedText,
),
),
awaitItem(),
)
}
}
@Test
fun `CreateLoginClick for username state should emit NavigateToAddLogin with Username`() =
runTest {
val viewModel = createViewModel(state = initialUsernameState)
viewModel.eventFlow.test {
viewModel.trySendAction(GeneratorAction.CreateLoginClick)
assertEquals(
GeneratorEvent.NavigateToAddLogin(
initialData = VaultAddEditType.AddItem.InitialData.Username(
value = viewModel.stateFlow.value.generatedText,
),
),
awaitItem(),
)
}
}
@Test
fun `Policy should overwrite password options if stricter`() {
val policy = createMockSdkPolicy(
@@ -131,6 +131,7 @@ class AddEditSendViewModelTest : BaseViewModelTest() {
SendView::toViewState,
UUID::randomUUID,
)
every { UUID.randomUUID().toString() } returns "uuid"
}
@AfterEach
@@ -13,7 +13,7 @@ class VaultAddEditNavigationTest {
fun `navigateToVaultAddEdit should pass along the selected collection ID`() {
navController.navigateToVaultAddEdit(
args = VaultAddEditArgs(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
selectedCollectionId = "mockCollectionId",
),
@@ -23,6 +23,8 @@ class VaultAddEditNavigationTest {
navController.navigate(
route = VaultAddEditRoute(
vaultAddEditMode = VaultAddEditMode.ADD,
initialValueType = null,
initialValue = null,
vaultItemId = null,
vaultItemCipherType = VaultItemCipherType.LOGIN,
selectedFolderId = null,
@@ -37,7 +39,7 @@ class VaultAddEditNavigationTest {
fun `navigateToVaultAddEdit should pass along the selected folder ID`() {
navController.navigateToVaultAddEdit(
args = VaultAddEditArgs(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
selectedFolderId = "mockFolderId",
),
@@ -47,6 +49,8 @@ class VaultAddEditNavigationTest {
navController.navigate(
route = VaultAddEditRoute(
vaultAddEditMode = VaultAddEditMode.ADD,
initialValueType = null,
initialValue = null,
vaultItemId = null,
vaultItemCipherType = VaultItemCipherType.LOGIN,
selectedFolderId = "mockFolderId",
@@ -4642,7 +4642,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
fun `should display policy warning when personal vault is disabled for add item type`() {
mutableStateFlow.update {
it.copy(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
viewState = VaultAddEditState.ViewState.Content(
common = VaultAddEditState.ViewState.Content.Common(
originalCipher = createMockCipherView(1),
@@ -5058,7 +5058,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
@Test
fun `learn about add logins card should show when state is add mode, login type content, and should show coach mark tour is true`() {
mutableStateFlow.value = DEFAULT_STATE_LOGIN.copy(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
shouldShowCoachMarkTour = true,
)
@@ -5071,7 +5071,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
@Test
fun `learn about add logins card should not show when state is add mode, login type content, and should show coach mark tour is false`() {
mutableStateFlow.value = DEFAULT_STATE_LOGIN.copy(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
shouldShowCoachMarkTour = false,
)
@@ -5131,7 +5131,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
@Test
fun `when learn about logins card is showing, clicking the call to action sends StartLearnAboutLogins action`() {
mutableStateFlow.value = DEFAULT_STATE_LOGIN.copy(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
shouldShowCoachMarkTour = true,
)
@@ -5510,7 +5510,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
),
dialog = VaultAddEditState.DialogState.Generic(message = "test".asText()),
bottomSheetState = null,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
shouldShowCoachMarkTour = false,
defaultUriMatchType = UriMatchTypeModel.EXACT,
hasPremium = false,
@@ -5519,7 +5519,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
)
private val DEFAULT_STATE_LOGIN = VaultAddEditState(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
cipherType = VaultItemCipherType.LOGIN,
viewState = VaultAddEditState.ViewState.Content(
common = VaultAddEditState.ViewState.Content.Common(),
@@ -5536,7 +5536,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
)
private val DEFAULT_STATE_IDENTITY = VaultAddEditState(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
cipherType = VaultItemCipherType.IDENTITY,
viewState = VaultAddEditState.ViewState.Content(
common = VaultAddEditState.ViewState.Content.Common(),
@@ -5553,7 +5553,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
)
private val DEFAULT_STATE_CARD = VaultAddEditState(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
cipherType = VaultItemCipherType.CARD,
viewState = VaultAddEditState.ViewState.Content(
common = VaultAddEditState.ViewState.Content.Common(),
@@ -5570,7 +5570,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
)
private val DEFAULT_STATE_BANK_ACCOUNT = VaultAddEditState(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
cipherType = VaultItemCipherType.BANK_ACCOUNT,
viewState = VaultAddEditState.ViewState.Content(
common = VaultAddEditState.ViewState.Content.Common(),
@@ -5587,7 +5587,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
)
private val DEFAULT_STATE_LICENSE = VaultAddEditState(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
cipherType = VaultItemCipherType.DRIVERS_LICENSE,
viewState = VaultAddEditState.ViewState.Content(
common = VaultAddEditState.ViewState.Content.Common(),
@@ -5604,7 +5604,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
)
private val DEFAULT_STATE_PASSPORT = VaultAddEditState(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
cipherType = VaultItemCipherType.PASSPORT,
viewState = VaultAddEditState.ViewState.Content(
common = VaultAddEditState.ViewState.Content.Common(),
@@ -5638,7 +5638,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
),
dialog = null,
bottomSheetState = null,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
cipherType = VaultItemCipherType.SECURE_NOTE,
shouldShowCoachMarkTour = false,
defaultUriMatchType = UriMatchTypeModel.EXACT,
@@ -5648,7 +5648,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
)
private val DEFAULT_STATE_SECURE_NOTES = VaultAddEditState(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
cipherType = VaultItemCipherType.SECURE_NOTE,
viewState = VaultAddEditState.ViewState.Content(
common = VaultAddEditState.ViewState.Content.Common(),
@@ -5665,7 +5665,7 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
)
private val DEFAULT_STATE_SSH_KEYS = VaultAddEditState(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
cipherType = VaultItemCipherType.SSH_KEY,
viewState = VaultAddEditState.ViewState.Content(
common = VaultAddEditState.ViewState.Content.Common(),
@@ -159,7 +159,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
private val loginInitialSavedStateHandle
get() = createSavedStateHandleWithState(
state = loginInitialState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
)
@@ -274,7 +274,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
@Test
fun `initial state should be correct when state is null`() = runTest {
val expectedState = VaultAddEditState(
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
cipherType = VaultItemCipherType.LOGIN,
viewState = VaultAddEditState.ViewState.Content(
common = VaultAddEditState.ViewState.Content.Common(),
@@ -295,7 +295,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
savedStateHandle = createSavedStateHandleWithState(
state = null,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -316,7 +316,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
savedStateHandle = createSavedStateHandleWithState(
state = initState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -344,7 +344,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
enabled = true,
),
)
val vaultAddEditType = VaultAddEditType.AddItem
val vaultAddEditType = VaultAddEditType.AddItem()
val vaultItemCipherType = VaultItemCipherType.LOGIN
mutableVaultDataFlow.value = DataState.Loaded(
data = createVaultData(),
@@ -395,7 +395,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
@Suppress("MaxLineLength")
fun `Vfo1FoundationFlagUpdateReceive should re-derive the content state using the latest vault data`() =
runTest {
val vaultAddEditType = VaultAddEditType.AddItem
val vaultAddEditType = VaultAddEditType.AddItem()
val vaultItemCipherType = VaultItemCipherType.LOGIN
mutableVaultDataFlow.value = DataState.Loaded(data = createVaultData())
val viewModel = createAddVaultItemViewModel(
@@ -441,7 +441,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val autofillContentState = autofillSelectionData.toDefaultAddTypeContent(
isIndividualVaultDisabled = false,
)
val vaultAddEditType = VaultAddEditType.AddItem
val vaultAddEditType = VaultAddEditType.AddItem()
val vaultItemCipherType = VaultItemCipherType.LOGIN
val initState = createVaultAddItemState(
vaultAddEditType = vaultAddEditType,
@@ -475,7 +475,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
autofillSaveItem = autofillSaveItem,
)
val autofillContentState = autofillSaveItem.toDefaultAddTypeContent(false)
val vaultAddEditType = VaultAddEditType.AddItem
val vaultAddEditType = VaultAddEditType.AddItem()
val vaultItemCipherType = VaultItemCipherType.LOGIN
val initState = createVaultAddItemState(
vaultAddEditType = vaultAddEditType,
@@ -516,7 +516,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
attestationOptions = createMockPasskeyAttestationOptions(number = 1),
isIndividualVaultDisabled = false,
)
val vaultAddEditType = VaultAddEditType.AddItem
val vaultAddEditType = VaultAddEditType.AddItem()
val vaultItemCipherType = VaultItemCipherType.LOGIN
val initState = createVaultAddItemState(
vaultAddEditType = vaultAddEditType,
@@ -600,7 +600,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -939,7 +939,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -1001,7 +1001,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -1057,7 +1057,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
savedStateHandle = createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -1109,7 +1109,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
savedStateHandle = createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -1179,7 +1179,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithNewLogin,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -1282,7 +1282,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -1338,7 +1338,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -1423,7 +1423,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -1470,7 +1470,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -1500,7 +1500,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -1537,7 +1537,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.CARD,
),
)
@@ -1917,7 +1917,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -1951,7 +1951,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -1985,7 +1985,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -2531,7 +2531,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = stateWithNoName,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -2561,7 +2561,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = errorState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -2588,7 +2588,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
createSavedStateHandleWithState(
state = errorState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -2644,7 +2644,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
@Suppress("MaxLineLength")
@Test
fun `screenDisplayName should resolve new title strings for new vault item types in add mode`() {
val baseAddState = createVaultAddItemState(vaultAddEditType = VaultAddEditType.AddItem)
val baseAddState = createVaultAddItemState(vaultAddEditType = VaultAddEditType.AddItem())
assertEquals(
BitwardenString.add_bank_account.asText(),
baseAddState.copy(cipherType = VaultItemCipherType.BANK_ACCOUNT).screenDisplayName,
@@ -3267,7 +3267,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
savedStateHandle = createSavedStateHandleWithState(
state = loginState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -3603,7 +3603,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
state = createVaultAddItemState(
typeContentViewState = createLoginTypeContentViewState(),
),
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -3671,7 +3671,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
)
identityInitialSavedStateHandle = createSavedStateHandleWithState(
state = vaultAddItemInitialState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
)
viewModel = createAddVaultItemViewModel(
@@ -3966,7 +3966,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
)
identityInitialSavedStateHandle = createSavedStateHandleWithState(
state = vaultAddItemInitialState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
)
viewModel = createAddVaultItemViewModel(
@@ -4082,7 +4082,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
)
sshKeyInitialSavedStateHandle = createSavedStateHandleWithState(
state = vaultAddItemInitialState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.SSH_KEY,
)
viewModel = createAddVaultItemViewModel(
@@ -4124,7 +4124,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
)
bankAccountInitialSavedStateHandle = createSavedStateHandleWithState(
state = vaultAddItemInitialState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.BANK_ACCOUNT,
)
viewModel = createAddVaultItemViewModel(
@@ -4303,7 +4303,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
)
licenseInitialSavedStateHandle = createSavedStateHandleWithState(
state = vaultAddItemInitialState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.DRIVERS_LICENSE,
)
viewModel = createAddVaultItemViewModel(
@@ -4497,7 +4497,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
)
passportInitialSavedStateHandle = createSavedStateHandleWithState(
state = vaultAddItemInitialState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.PASSPORT,
)
viewModel = createAddVaultItemViewModel(
@@ -4770,7 +4770,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
vaultAddItemInitialState = createVaultAddItemState()
secureNotesInitialSavedStateHandle = createSavedStateHandleWithState(
state = vaultAddItemInitialState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
)
viewModel = createAddVaultItemViewModel(
@@ -5206,7 +5206,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
savedStateHandle = createSavedStateHandleWithState(
state = initState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -5262,7 +5262,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
savedStateHandle = createSavedStateHandleWithState(
state = initState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -5329,7 +5329,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
savedStateHandle = createSavedStateHandleWithState(
state = initState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -5445,7 +5445,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
),
)
val vaultAddEditType = VaultAddEditType.AddItem
val vaultAddEditType = VaultAddEditType.AddItem()
val vaultItemCipherType = VaultItemCipherType.LOGIN
mutableVaultDataFlow.value = DataState.Loaded(
data = createVaultData(),
@@ -6096,7 +6096,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
.ItemType
.Card(),
),
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.CARD,
),
)
@@ -6150,7 +6150,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
vaultItemCipherType = VaultItemCipherType.CARD,
typeContentViewState = initialCardState,
),
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.CARD,
),
)
@@ -6177,7 +6177,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
.ItemType
.Card(),
),
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.CARD,
),
)
@@ -6208,7 +6208,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
.ItemType
.Card(),
),
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.CARD,
),
)
@@ -6237,7 +6237,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
savedStateHandle = createSavedStateHandleWithState(
state = initialState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.CARD,
),
)
@@ -6275,7 +6275,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
savedStateHandle = createSavedStateHandleWithState(
state = initialState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.CARD,
),
)
@@ -6315,7 +6315,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
vaultItemCipherType = VaultItemCipherType.CARD,
typeContentViewState = initialCard,
),
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.CARD,
),
)
@@ -6364,7 +6364,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
vaultItemCipherType = VaultItemCipherType.CARD,
typeContentViewState = typedCard,
),
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.CARD,
),
)
@@ -6418,7 +6418,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
vaultItemCipherType = VaultItemCipherType.CARD,
typeContentViewState = firstScanCard,
),
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.CARD,
),
)
@@ -6469,7 +6469,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
vaultItemCipherType = VaultItemCipherType.CARD,
typeContentViewState = initialCard,
),
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.CARD,
),
)
@@ -6508,7 +6508,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
@Suppress("LongParameterList")
private fun createVaultAddItemState(
vaultAddEditType: VaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType: VaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType: VaultItemCipherType = VaultItemCipherType.LOGIN,
commonContentViewState: VaultAddEditState.ViewState.Content.Common =
createCommonContentViewState(),
@@ -6785,7 +6785,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
savedStateHandle = createSavedStateHandleWithState(
state = initialState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -6814,7 +6814,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
val viewModel = createAddVaultItemViewModel(
savedStateHandle = createSavedStateHandleWithState(
state = initialState,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
vaultItemCipherType = VaultItemCipherType.LOGIN,
),
)
@@ -560,7 +560,7 @@ class CipherViewExtensionsTest {
val result = createMockCipherView(number = 1)
.validateCipherOrReturnErrorState(
currentAccount = createAccount(),
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
) { _, _ -> providedState }
assertEquals(providedState, result)
@@ -589,7 +589,7 @@ class CipherViewExtensionsTest {
val result = createMockCipherView(number = 1)
.validateCipherOrReturnErrorState(
currentAccount = null,
vaultAddEditType = VaultAddEditType.AddItem,
vaultAddEditType = VaultAddEditType.AddItem(),
) { _, _ -> providedState }
assertEquals(
@@ -34,7 +34,7 @@ class VaultAddEditExtensionsTest {
VaultItemCipherType.SSH_KEY,
)
val result = vaultItemCipherTypeList.map { it.toItemType() }
val result = vaultItemCipherTypeList.map { it.toItemType(initialData = null) }
assertEquals(
listOf(
+1
View File
@@ -1442,6 +1442,7 @@ Do you want to switch to this account?</string>
<string name="use_this_passphrase">Use this passphrase</string>
<string name="use_this_password">Use this password</string>
<string name="use_this_username">Use this username</string>
<string name="create_login">Create login</string>
<string name="keep_unlocking_with_biometrics">Keep unlocking with biometrics</string>
<string name="weve_made_a_security_update">We’ve made a security update. Confirm your biometrics again to keep using them to unlock Bitwarden.</string>
<string name="turn_off">Turn off</string>