[PM-22568] Change totp seed field to a password field (#5350)

This commit is contained in:
aj-rosado 2025-06-13 17:32:12 +01:00 committed by GitHub
parent 053dfc1647
commit 469df4495a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 51 additions and 2 deletions

View File

@ -361,7 +361,7 @@ private fun TotpRow(
onTotpSetupClick: () -> Unit, onTotpSetupClick: () -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
BitwardenTextField( BitwardenPasswordField(
label = stringResource(id = R.string.authenticator_key), label = stringResource(id = R.string.authenticator_key),
value = totpKey.orEmpty(), value = totpKey.orEmpty(),
onValueChange = {}, onValueChange = {},
@ -400,7 +400,7 @@ private fun TotpRow(
.testTag("SetupTotpButton"), .testTag("SetupTotpButton"),
) )
}, },
textFieldTestTag = "LoginTotpEntry", passwordFieldTestTag = "LoginTotpEntry",
cardStyle = CardStyle.Full, cardStyle = CardStyle.Full,
modifier = modifier modifier = modifier
.fillMaxWidth() .fillMaxWidth()

View File

@ -985,7 +985,20 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
composeTestRule composeTestRule
.onNodeWithTextAfterScroll("Authenticator key") .onNodeWithTextAfterScroll("Authenticator key")
.assertTextEquals("Authenticator key", "••••••••")
composeTestRule
.onNodeWithTextAfterScroll("Authenticator key")
.assertExists()
.onChildren()
.filterToOne(hasContentDescription(value = "Show"))
.assertExists()
.performClick()
composeTestRule
.onNodeWithText("Authenticator key")
.assertTextEquals("Authenticator key", "TestCode") .assertTextEquals("Authenticator key", "TestCode")
.assertIsEnabled()
mutableStateFlow.update { currentState -> mutableStateFlow.update { currentState ->
updateLoginType(currentState) { copy(totp = "NewTestCode") } updateLoginType(currentState) { copy(totp = "NewTestCode") }
@ -1000,6 +1013,42 @@ class VaultAddEditScreenTest : BitwardenComposeTest() {
} }
} }
@Test
fun `in ItemType_Login state totp control should display the text provided by the state`() {
mutableStateFlow.update { currentState ->
updateLoginType(currentState) { copy(totp = "TestCode") }
}
composeTestRule
.onNodeWithTextAfterScroll("Authenticator key")
.assertTextEquals("Authenticator key", "••••••••")
composeTestRule
.onNodeWithTextAfterScroll("Authenticator key")
.assertExists()
.onChildren()
.filterToOne(hasContentDescription(value = "Show"))
.assertExists()
.performClick()
composeTestRule
.onNodeWithText("Authenticator key")
.assertTextEquals("Authenticator key", "TestCode")
.assertIsEnabled()
composeTestRule
.onNodeWithText("Authenticator key")
.assertExists()
.onChildren()
.filterToOne(hasContentDescription(value = "Hide"))
.assertExists()
.performClick()
composeTestRule
.onNodeWithTextAfterScroll("Authenticator key")
.assertTextEquals("Authenticator key", "••••••••")
}
@Suppress("MaxLineLength") @Suppress("MaxLineLength")
@Test @Test
fun `in ItemType_Login state the totp text field click on trailing icon should call ClearTotpKeyClick`() { fun `in ItemType_Login state the totp text field click on trailing icon should call ClearTotpKeyClick`() {