mirror of
https://github.com/bitwarden/android.git
synced 2025-02-17 04:19:54 +03:00
BIT-1969: Add testTags for password history (#1123)
This commit is contained in:
parent
b649288948
commit
a8670965f9
2 changed files with 8 additions and 3 deletions
|
@ -19,6 +19,8 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.layout.onGloballyPositioned
|
import androidx.compose.ui.layout.onGloballyPositioned
|
||||||
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.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.x8bit.bitwarden.R
|
import com.x8bit.bitwarden.R
|
||||||
|
@ -49,7 +51,6 @@ fun PasswordHistoryListItem(
|
||||||
.then(modifier),
|
.then(modifier),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
var widthPx by remember(label) { mutableIntStateOf(0) }
|
var widthPx by remember(label) { mutableIntStateOf(0) }
|
||||||
val textStyle = LocalNonMaterialTypography.current.sensitiveInfoMedium
|
val textStyle = LocalNonMaterialTypography.current.sensitiveInfoMedium
|
||||||
|
@ -64,6 +65,7 @@ fun PasswordHistoryListItem(
|
||||||
style = textStyle,
|
style = textStyle,
|
||||||
color = MaterialTheme.colorScheme.onSurface,
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.semantics { testTag = "GeneratedPasswordValue" }
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.onGloballyPositioned { widthPx = it.size.width },
|
.onGloballyPositioned { widthPx = it.size.width },
|
||||||
)
|
)
|
||||||
|
@ -72,6 +74,7 @@ fun PasswordHistoryListItem(
|
||||||
text = supportingLabel,
|
text = supportingLabel,
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
modifier = Modifier.semantics { testTag = "GeneratedPasswordDateLabel" },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +83,7 @@ fun PasswordHistoryListItem(
|
||||||
colors = IconButtonDefaults.iconButtonColors(
|
colors = IconButtonDefaults.iconButtonColors(
|
||||||
contentColor = MaterialTheme.colorScheme.primary,
|
contentColor = MaterialTheme.colorScheme.primary,
|
||||||
),
|
),
|
||||||
|
modifier = Modifier.semantics { testTag = "CopyPasswordValueButton" },
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = painterResource(id = R.drawable.ic_copy),
|
painter = painterResource(id = R.drawable.ic_copy),
|
||||||
|
|
|
@ -161,16 +161,17 @@ private fun PasswordHistoryLoading(modifier: Modifier = Modifier) {
|
||||||
@Composable
|
@Composable
|
||||||
private fun PasswordHistoryContent(
|
private fun PasswordHistoryContent(
|
||||||
state: PasswordHistoryState.ViewState.Content,
|
state: PasswordHistoryState.ViewState.Content,
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
onPasswordCopyClick: (PasswordHistoryState.GeneratedPassword) -> Unit,
|
onPasswordCopyClick: (PasswordHistoryState.GeneratedPassword) -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
LazyColumn(modifier = modifier.semantics { testTag = "GeneratedPasswordRow" }) {
|
LazyColumn(modifier = modifier) {
|
||||||
items(state.passwords) { password ->
|
items(state.passwords) { password ->
|
||||||
PasswordHistoryListItem(
|
PasswordHistoryListItem(
|
||||||
label = password.password,
|
label = password.password,
|
||||||
supportingLabel = password.date,
|
supportingLabel = password.date,
|
||||||
onCopyClick = { onPasswordCopyClick(password) },
|
onCopyClick = { onPasswordCopyClick(password) },
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.semantics { testTag = "GeneratedPasswordRow" }
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = 16.dp),
|
.padding(horizontal = 16.dp),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue