BIT-1171: Element IDs for LoginApporvalScreen and Reset Password Screen (#901)

This commit is contained in:
Joshua Queen 2024-01-31 13:23:27 -05:00 committed by Álison Fernandes
parent 24806c4920
commit bb0c91ee5a
2 changed files with 34 additions and 6 deletions

View file

@ -22,9 +22,13 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel import androidx.hilt.navigation.compose.hiltViewModel
@ -141,6 +145,7 @@ fun ResetPasswordScreen(
} }
} }
@OptIn(ExperimentalComposeUiApi::class)
@Composable @Composable
@Suppress("LongMethod") @Suppress("LongMethod")
private fun ResetPasswordScreeContent( private fun ResetPasswordScreeContent(
@ -154,6 +159,7 @@ private fun ResetPasswordScreeContent(
Column( Column(
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
modifier = modifier modifier = modifier
.semantics { testTagsAsResourceId = true }
.imePadding() .imePadding()
.verticalScroll(rememberScrollState()), .verticalScroll(rememberScrollState()),
) { ) {
@ -204,6 +210,7 @@ private fun ResetPasswordScreeContent(
value = state.currentPasswordInput, value = state.currentPasswordInput,
onValueChange = onCurrentPasswordInputChanged, onValueChange = onCurrentPasswordInputChanged,
modifier = Modifier modifier = Modifier
.semantics { testTag = "MasterPasswordField" }
.padding(horizontal = 16.dp) .padding(horizontal = 16.dp)
.fillMaxWidth(), .fillMaxWidth(),
) )
@ -215,6 +222,7 @@ private fun ResetPasswordScreeContent(
value = state.passwordInput, value = state.passwordInput,
onValueChange = onPasswordInputChanged, onValueChange = onPasswordInputChanged,
modifier = Modifier modifier = Modifier
.semantics { testTag = "NewPasswordField" }
.padding(horizontal = 16.dp) .padding(horizontal = 16.dp)
.fillMaxWidth(), .fillMaxWidth(),
) )
@ -226,6 +234,7 @@ private fun ResetPasswordScreeContent(
value = state.retypePasswordInput, value = state.retypePasswordInput,
onValueChange = onRetypePasswordInputChanged, onValueChange = onRetypePasswordInputChanged,
modifier = Modifier modifier = Modifier
.semantics { testTag = "RetypePasswordField" }
.padding(horizontal = 16.dp) .padding(horizontal = 16.dp)
.fillMaxWidth(), .fillMaxWidth(),
) )
@ -238,6 +247,7 @@ private fun ResetPasswordScreeContent(
onValueChange = onPasswordHintInputChanged, onValueChange = onPasswordHintInputChanged,
hint = stringResource(id = R.string.master_password_hint_description), hint = stringResource(id = R.string.master_password_hint_description),
modifier = Modifier modifier = Modifier
.semantics { testTag = "MasterPasswordHintLabel" }
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )

View file

@ -19,11 +19,15 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel import androidx.hilt.navigation.compose.hiltViewModel
@ -131,6 +135,7 @@ fun LoginApprovalScreen(
} }
} }
@OptIn(ExperimentalComposeUiApi::class)
@Suppress("LongMethod") @Suppress("LongMethod")
@Composable @Composable
private fun LoginApprovalContent( private fun LoginApprovalContent(
@ -141,6 +146,7 @@ private fun LoginApprovalContent(
) { ) {
Column( Column(
modifier = modifier modifier = modifier
.semantics { testTagsAsResourceId = true }
.verticalScroll(state = rememberScrollState()), .verticalScroll(state = rememberScrollState()),
) { ) {
Spacer(modifier = Modifier.height(8.dp)) Spacer(modifier = Modifier.height(8.dp))
@ -163,7 +169,8 @@ private fun LoginApprovalContent(
color = MaterialTheme.colorScheme.onSurfaceVariant, color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp)
.semantics { testTag = "LogInAttemptByLabel" },
) )
Spacer(modifier = Modifier.height(24.dp)) Spacer(modifier = Modifier.height(24.dp))
@ -173,7 +180,8 @@ private fun LoginApprovalContent(
color = MaterialTheme.colorScheme.onSurfaceVariant, color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp)
.semantics { testTag = "FingerprintValueLabel" },
) )
Spacer(modifier = Modifier.height(12.dp)) Spacer(modifier = Modifier.height(12.dp))
@ -184,7 +192,8 @@ private fun LoginApprovalContent(
style = LocalNonMaterialTypography.current.sensitiveInfoSmall, style = LocalNonMaterialTypography.current.sensitiveInfoSmall,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp)
.semantics { testTag = "FingerprintValue" },
) )
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
@ -192,6 +201,7 @@ private fun LoginApprovalContent(
LoginApprovalInfoColumn( LoginApprovalInfoColumn(
label = stringResource(id = R.string.device_type), label = stringResource(id = R.string.device_type),
value = state.deviceType, value = state.deviceType,
valueTestTag = "DeviceTypeValueLabel",
) )
LoginApprovalInfoColumn( LoginApprovalInfoColumn(
@ -211,7 +221,8 @@ private fun LoginApprovalContent(
onClick = onConfirmLoginClick, onClick = onConfirmLoginClick,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp)
.semantics { testTag = "ConfirmLoginButton" },
) )
Spacer(modifier = Modifier.height(8.dp)) Spacer(modifier = Modifier.height(8.dp))
@ -221,7 +232,8 @@ private fun LoginApprovalContent(
onClick = onDeclineLoginClick, onClick = onDeclineLoginClick,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp)
.semantics { testTag = "DenyLoginButton" },
) )
Spacer(modifier = Modifier.navigationBarsPadding()) Spacer(modifier = Modifier.navigationBarsPadding())
@ -235,6 +247,7 @@ private fun LoginApprovalContent(
private fun LoginApprovalInfoColumn( private fun LoginApprovalInfoColumn(
label: String, label: String,
value: String, value: String,
valueTestTag: String? = null,
) { ) {
Spacer(modifier = Modifier.height(8.dp)) Spacer(modifier = Modifier.height(8.dp))
@ -255,7 +268,12 @@ private fun LoginApprovalInfoColumn(
color = MaterialTheme.colorScheme.onSurfaceVariant, color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp)
.semantics {
if (valueTestTag != null) {
testTag = valueTestTag
}
},
) )
Spacer(modifier = Modifier.height(8.dp)) Spacer(modifier = Modifier.height(8.dp))