From a8670965f9c6b8de79a6d338a1ba59b4b6cf32f9 Mon Sep 17 00:00:00 2001 From: David Perez Date: Mon, 11 Mar 2024 16:58:52 -0500 Subject: [PATCH] BIT-1969: Add testTags for password history (#1123) --- .../generator/passwordhistory/PasswordHistoryListItem.kt | 6 +++++- .../generator/passwordhistory/PasswordHistoryScreen.kt | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/passwordhistory/PasswordHistoryListItem.kt b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/passwordhistory/PasswordHistoryListItem.kt index 0792ea2ee..e78c7cc30 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/passwordhistory/PasswordHistoryListItem.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/passwordhistory/PasswordHistoryListItem.kt @@ -19,6 +19,8 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.semantics.testTag import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.x8bit.bitwarden.R @@ -49,7 +51,6 @@ fun PasswordHistoryListItem( .then(modifier), verticalAlignment = Alignment.CenterVertically, ) { - Column(modifier = Modifier.weight(1f)) { var widthPx by remember(label) { mutableIntStateOf(0) } val textStyle = LocalNonMaterialTypography.current.sensitiveInfoMedium @@ -64,6 +65,7 @@ fun PasswordHistoryListItem( style = textStyle, color = MaterialTheme.colorScheme.onSurface, modifier = Modifier + .semantics { testTag = "GeneratedPasswordValue" } .fillMaxWidth() .onGloballyPositioned { widthPx = it.size.width }, ) @@ -72,6 +74,7 @@ fun PasswordHistoryListItem( text = supportingLabel, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.semantics { testTag = "GeneratedPasswordDateLabel" }, ) } @@ -80,6 +83,7 @@ fun PasswordHistoryListItem( colors = IconButtonDefaults.iconButtonColors( contentColor = MaterialTheme.colorScheme.primary, ), + modifier = Modifier.semantics { testTag = "CopyPasswordValueButton" }, ) { Icon( painter = painterResource(id = R.drawable.ic_copy), diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/passwordhistory/PasswordHistoryScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/passwordhistory/PasswordHistoryScreen.kt index 87bbf5e45..db1564b4a 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/passwordhistory/PasswordHistoryScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/generator/passwordhistory/PasswordHistoryScreen.kt @@ -161,16 +161,17 @@ private fun PasswordHistoryLoading(modifier: Modifier = Modifier) { @Composable private fun PasswordHistoryContent( state: PasswordHistoryState.ViewState.Content, - modifier: Modifier = Modifier, onPasswordCopyClick: (PasswordHistoryState.GeneratedPassword) -> Unit, + modifier: Modifier = Modifier, ) { - LazyColumn(modifier = modifier.semantics { testTag = "GeneratedPasswordRow" }) { + LazyColumn(modifier = modifier) { items(state.passwords) { password -> PasswordHistoryListItem( label = password.password, supportingLabel = password.date, onCopyClick = { onPasswordCopyClick(password) }, modifier = Modifier + .semantics { testTag = "GeneratedPasswordRow" } .fillMaxWidth() .padding(horizontal = 16.dp), )