BIT-2237: Sync password visibility fields for set and reset password screens (#1259)

This commit is contained in:
David Perez
2024-06-20 17:08:07 +01:00
committed by Álison Fernandes
parent 44728bba02
commit e9a42918d3
4 changed files with 68 additions and 0 deletions
@@ -1,10 +1,12 @@
package com.x8bit.bitwarden.ui.auth.feature.resetPassword
import androidx.compose.ui.test.assert
import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.hasAnyAncestor
import androidx.compose.ui.test.isDialog
import androidx.compose.ui.test.isDisplayed
import androidx.compose.ui.test.onAllNodesWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTextInput
@@ -223,6 +225,31 @@ class ResetPasswordScreenTest : BaseComposeTest() {
viewModel.trySendAction(ResetPasswordAction.PasswordHintInputChanged("Test123"))
}
}
@Test
fun `toggling one password field visibility should toggle the other`() {
// should start with 3 Show buttons:
composeTestRule
.onAllNodesWithContentDescription("Show")
.assertCountEquals(3)[1]
.performClick()
// after clicking, only the "previous master password" field in the "Show" state
composeTestRule
.onAllNodesWithContentDescription("Show")
.assertCountEquals(1)
// and there should be 2 hide buttons now, and we'll click the second one:
composeTestRule
.onAllNodesWithContentDescription("Hide")
.assertCountEquals(2)[0]
.performClick()
// then there should be all three show buttons again
composeTestRule
.onAllNodesWithContentDescription("Show")
.assertCountEquals(3)
}
}
private val DEFAULT_STATE = ResetPasswordState(
@@ -1,9 +1,11 @@
package com.x8bit.bitwarden.ui.auth.feature.setpassword
import androidx.compose.ui.test.assert
import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.hasAnyAncestor
import androidx.compose.ui.test.isDialog
import androidx.compose.ui.test.isDisplayed
import androidx.compose.ui.test.onAllNodesWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTextInput
@@ -117,6 +119,31 @@ class SetPasswordScreenTest : BaseComposeTest() {
viewModel.trySendAction(SetPasswordAction.PasswordHintInputChanged("Test123"))
}
}
@Test
fun `toggling one password field visibility should toggle the other`() {
// should start with 2 Show buttons:
composeTestRule
.onAllNodesWithContentDescription("Show")
.assertCountEquals(2)[0]
.performClick()
// after clicking there should be no Show buttons:
composeTestRule
.onAllNodesWithContentDescription("Show")
.assertCountEquals(0)
// and there should be 2 hide buttons now, and we'll click the second one:
composeTestRule
.onAllNodesWithContentDescription("Hide")
.assertCountEquals(2)[1]
.performClick()
// then there should be two show buttons again
composeTestRule
.onAllNodesWithContentDescription("Show")
.assertCountEquals(2)
}
}
private val DEFAULT_STATE = SetPasswordState(