mirror of
https://github.com/bitwarden/android.git
synced 2026-11-19 17:40:12 -06:00
Add UI support for hiding all button on TrustedDeviceScreen (#1152)
This commit is contained in:
committed by
Álison Fernandes
parent
f080b2cb8b
commit
e012dbf45d
+71
@@ -64,6 +64,45 @@ class TrustedDeviceScreenTest : BaseComposeTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `continue button should be displayed according to state`() {
|
||||
composeTestRule
|
||||
.onNodeWithText("Continue")
|
||||
.performScrollTo()
|
||||
.assertIsDisplayed()
|
||||
|
||||
mutableStateFlow.update { it.copy(showContinueButton = false) }
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText("Continue")
|
||||
.assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on continue clicked should send ContinueClick`() {
|
||||
composeTestRule
|
||||
.onNodeWithText("Continue")
|
||||
.performScrollTo()
|
||||
.performClick()
|
||||
verify(exactly = 1) {
|
||||
viewModel.trySendAction(TrustedDeviceAction.ContinueClick)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `other device button should be displayed according to state`() {
|
||||
composeTestRule
|
||||
.onNodeWithText("Approve with my other device")
|
||||
.performScrollTo()
|
||||
.assertIsDisplayed()
|
||||
|
||||
mutableStateFlow.update { it.copy(showOtherDeviceButton = false) }
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText("Approve with my other device")
|
||||
.assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on approve with device clicked should send ApproveWithDeviceClick`() {
|
||||
composeTestRule
|
||||
@@ -75,6 +114,20 @@ class TrustedDeviceScreenTest : BaseComposeTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `admin approval button should be displayed according to state`() {
|
||||
composeTestRule
|
||||
.onNodeWithText("Request admin approval")
|
||||
.performScrollTo()
|
||||
.assertIsDisplayed()
|
||||
|
||||
mutableStateFlow.update { it.copy(showRequestAdminButton = false) }
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText("Request admin approval")
|
||||
.assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on approve with admin clicked should send ApproveWithAdminClick`() {
|
||||
composeTestRule
|
||||
@@ -86,6 +139,20 @@ class TrustedDeviceScreenTest : BaseComposeTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `master password button should be displayed according to state`() {
|
||||
composeTestRule
|
||||
.onNodeWithText("Approve with master password")
|
||||
.performScrollTo()
|
||||
.assertIsDisplayed()
|
||||
|
||||
mutableStateFlow.update { it.copy(showMasterPasswordButton = false) }
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText("Approve with master password")
|
||||
.assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on approve with master password clicked should send ApproveWithPasswordClick`() {
|
||||
composeTestRule
|
||||
@@ -158,4 +225,8 @@ private val DEFAULT_STATE: TrustedDeviceState = TrustedDeviceState(
|
||||
emailAddress = "email@bitwarden.com",
|
||||
environmentLabel = "vault.bitwarden.pw",
|
||||
isRemembered = false,
|
||||
showContinueButton = true,
|
||||
showOtherDeviceButton = true,
|
||||
showRequestAdminButton = true,
|
||||
showMasterPasswordButton = true,
|
||||
)
|
||||
|
||||
+14
@@ -37,6 +37,16 @@ class TrustedDeviceViewModelTest : BaseViewModelTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on ContinueClick emits ShowToast`() = runTest {
|
||||
val viewModel = createViewModel()
|
||||
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.trySendAction(TrustedDeviceAction.ContinueClick)
|
||||
assertEquals(TrustedDeviceEvent.ShowToast("Not yet implemented".asText()), awaitItem())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on ApproveWithAdminClick emits ShowToast`() = runTest {
|
||||
val viewModel = createViewModel()
|
||||
@@ -94,4 +104,8 @@ private val DEFAULT_STATE: TrustedDeviceState = TrustedDeviceState(
|
||||
emailAddress = "email@bitwarden.com",
|
||||
environmentLabel = "bitwarden.com",
|
||||
isRemembered = false,
|
||||
showContinueButton = false,
|
||||
showOtherDeviceButton = false,
|
||||
showRequestAdminButton = false,
|
||||
showMasterPasswordButton = false,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user