From c9de5b919ce4bdba156cdef098fa7a09ae38a48a Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 12 Mar 2024 16:49:37 -0500 Subject: [PATCH] BIT-1990: Add test tags for all rows in setting UI (#1129) --- .../feature/settings/SettingsScreen.kt | 3 ++ .../feature/settings/SettingsViewModel.kt | 36 +++++++++++++++---- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/SettingsScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/SettingsScreen.kt index b99f1bdf5..0d857834f 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/SettingsScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/SettingsScreen.kt @@ -26,6 +26,8 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll 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 androidx.hilt.navigation.compose.hiltViewModel @@ -88,6 +90,7 @@ fun SettingsScreen( { viewModel.trySendAction(SettingsAction.SettingsClick(it)) } }, modifier = Modifier + .semantics { testTag = it.testTag } .padding(horizontal = 16.dp) .fillMaxWidth(), ) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/SettingsViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/SettingsViewModel.kt index f9b968cb5..087a6e2d8 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/SettingsViewModel.kt @@ -99,12 +99,34 @@ sealed class SettingsAction { * Enum representing the settings rows, such as "account security" or "vault". * * @property text The [Text] of the string that represents the label of each setting. + * @property testTag The value that should be set for the test tag. This is used in Appium testing. */ -enum class Settings(val text: Text) { - ACCOUNT_SECURITY(R.string.account_security.asText()), - AUTO_FILL(R.string.autofill.asText()), - VAULT(R.string.vault.asText()), - APPEARANCE(R.string.appearance.asText()), - OTHER(R.string.other.asText()), - ABOUT(R.string.about.asText()), +enum class Settings( + val text: Text, + val testTag: String, +) { + ACCOUNT_SECURITY( + text = R.string.account_security.asText(), + testTag = "AccountSecuritySettingsButton", + ), + AUTO_FILL( + text = R.string.autofill.asText(), + testTag = "AutofillSettingsButton", + ), + VAULT( + text = R.string.vault.asText(), + testTag = "VaultSettingsButton", + ), + APPEARANCE( + text = R.string.appearance.asText(), + testTag = "AppearanceSettingsButton", + ), + OTHER( + text = R.string.other.asText(), + testTag = "OtherSettingsButton", + ), + ABOUT( + text = R.string.about.asText(), + testTag = "AboutSettingsButton", + ), }