mirror of
https://github.com/bitwarden/android.git
synced 2024-11-22 01:16:02 +03:00
BIT-970: Ensure Terms of Service switch reads off checked state (#171)
This commit is contained in:
parent
0af6e7f826
commit
8378f5bef6
2 changed files with 31 additions and 0 deletions
|
@ -40,6 +40,8 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.semantics.CustomAccessibilityAction
|
||||
import androidx.compose.ui.semantics.customActions
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.toggleableState
|
||||
import androidx.compose.ui.state.ToggleableState
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.withStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
@ -317,6 +319,7 @@ private fun TermsAndPrivacySwitch(
|
|||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.semantics(mergeDescendants = true) {
|
||||
toggleableState = ToggleableState(isChecked)
|
||||
customActions = listOf(
|
||||
CustomAccessibilityAction(
|
||||
label = termsString,
|
||||
|
|
|
@ -4,6 +4,8 @@ import android.content.Intent
|
|||
import android.net.Uri
|
||||
import androidx.compose.ui.test.assertCountEquals
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.assertIsOff
|
||||
import androidx.compose.ui.test.assertIsOn
|
||||
import androidx.compose.ui.test.filterToOne
|
||||
import androidx.compose.ui.test.hasAnyAncestor
|
||||
import androidx.compose.ui.test.isDialog
|
||||
|
@ -96,6 +98,32 @@ class CreateAccountScreenTest : BaseComposeTest() {
|
|||
verify { viewModel.trySendAction(CheckDataBreachesToggle(true)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `accept policies should be toggled on or off according to the state`() {
|
||||
val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||
val viewModel = mockk<CreateAccountViewModel>(relaxed = true) {
|
||||
every { stateFlow } returns mutableStateFlow
|
||||
every { eventFlow } returns emptyFlow()
|
||||
every { trySendAction(AcceptPoliciesToggle(true)) } returns Unit
|
||||
}
|
||||
composeTestRule.setContent {
|
||||
CreateAccountScreen(
|
||||
onNavigateBack = {},
|
||||
onNavigateToLogin = { _, _ -> },
|
||||
viewModel = viewModel,
|
||||
)
|
||||
}
|
||||
composeTestRule
|
||||
.onNodeWithText("By activating this switch you agree", substring = true)
|
||||
.assertIsOff()
|
||||
|
||||
mutableStateFlow.update { it.copy(isAcceptPoliciesToggled = true) }
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText("By activating this switch you agree", substring = true)
|
||||
.assertIsOn()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `accept policies click should send AcceptPoliciesToggle action`() {
|
||||
val viewModel = mockk<CreateAccountViewModel>(relaxed = true) {
|
||||
|
|
Loading…
Reference in a new issue