mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
Navigate directly to generator when edited item's password or username fields are empty (#785)
This commit is contained in:
parent
465cce42f0
commit
2f2f5703a7
2 changed files with 71 additions and 4 deletions
|
@ -346,7 +346,13 @@ private fun UsernameRow(
|
|||
iconPainter = painterResource(id = R.drawable.ic_generator),
|
||||
contentDescription = stringResource(id = R.string.generate_username),
|
||||
),
|
||||
onClick = { shouldShowDialog = true },
|
||||
onClick = {
|
||||
if (loginState.username.isEmpty()) {
|
||||
loginItemTypeHandlers.onOpenUsernameGeneratorClick()
|
||||
} else {
|
||||
shouldShowDialog = true
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
|
@ -375,6 +381,7 @@ private fun UsernameRow(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("LongMethod")
|
||||
@Composable
|
||||
private fun PasswordRow(
|
||||
loginState: VaultAddEditState.ViewState.Content.ItemType.Login,
|
||||
|
@ -403,7 +410,13 @@ private fun PasswordRow(
|
|||
iconPainter = painterResource(id = R.drawable.ic_generator),
|
||||
contentDescription = stringResource(id = R.string.generate_password),
|
||||
),
|
||||
onClick = { shouldShowDialog = true },
|
||||
onClick = {
|
||||
if (loginState.password.isEmpty()) {
|
||||
loginItemTypeHandlers.onOpenPasswordGeneratorClick()
|
||||
} else {
|
||||
shouldShowDialog = true
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
if (shouldShowDialog) {
|
||||
|
|
|
@ -408,7 +408,11 @@ class VaultAddEditScreenTest : BaseComposeTest() {
|
|||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `in ItemType_Login state clicking Username generator action should open dialog that triggers OpenUsernameGeneratorClick`() {
|
||||
fun `in ItemType_Login state clicking Username text field generator action with non empty username should open dialog that triggers OpenUsernameGeneratorClick`() {
|
||||
mutableStateFlow.update { currentState ->
|
||||
updateLoginType(currentState) { copy(username = "username") }
|
||||
}
|
||||
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
composeTestRule
|
||||
|
@ -429,6 +433,28 @@ class VaultAddEditScreenTest : BaseComposeTest() {
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `in ItemType_Login state clicking Username generator icon with empty username field should trigger OpenPasswordGeneratorClick`() {
|
||||
mutableStateFlow.update { currentState ->
|
||||
updateLoginType(currentState) { copy(username = "") }
|
||||
}
|
||||
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithContentDescriptionAfterScroll(label = "Generate username")
|
||||
.performClick()
|
||||
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
verify {
|
||||
viewModel.trySendAction(
|
||||
VaultAddEditAction.ItemType.LoginType.OpenUsernameGeneratorClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `in ItemType_Login state clicking Password checker action should trigger PasswordCheckerClick`() {
|
||||
|
@ -449,7 +475,11 @@ class VaultAddEditScreenTest : BaseComposeTest() {
|
|||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `in ItemType_Login state click Password text field generator action should open dialog that triggers OpenPasswordGeneratorClick`() {
|
||||
fun `in ItemType_Login state clicking Password text field generator action with non empty password field should open dialog that triggers OpenPasswordGeneratorClick`() {
|
||||
mutableStateFlow.update { currentState ->
|
||||
updateLoginType(currentState) { copy(password = "password") }
|
||||
}
|
||||
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
composeTestRule
|
||||
|
@ -472,6 +502,30 @@ class VaultAddEditScreenTest : BaseComposeTest() {
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `in ItemType_Login state clicking Password generator icon with empty password field should trigger OpenPasswordGeneratorClick`() {
|
||||
mutableStateFlow.update { currentState ->
|
||||
updateLoginType(currentState) { copy(password = "") }
|
||||
}
|
||||
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithTextAfterScroll(text = "Password")
|
||||
.onSiblings()
|
||||
.onLast()
|
||||
.performClick()
|
||||
|
||||
composeTestRule.assertNoDialogExists()
|
||||
|
||||
verify {
|
||||
viewModel.trySendAction(
|
||||
VaultAddEditAction.ItemType.LoginType.OpenPasswordGeneratorClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `in ItemType_Login state changing Password text field should trigger PasswordTextChange`() {
|
||||
composeTestRule
|
||||
|
|
Loading…
Reference in a new issue