Skip to content

Commit

Permalink
QA Automation - Locators for Android (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
vphan916 authored Oct 23, 2024
1 parent 5c38522 commit 932c26d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ fun EditItemContent(
Spacer(Modifier.height(8.dp))
BitwardenTextField(
modifier = Modifier
.semantics { testTag = "NameTextField" }
.fillMaxSize()
.padding(horizontal = 16.dp),
label = stringResource(id = R.string.name),
Expand All @@ -264,6 +265,7 @@ fun EditItemContent(
Spacer(modifier = Modifier.height(8.dp))
BitwardenPasswordField(
modifier = Modifier
.semantics { testTag = "KeyTextField" }
.fillMaxSize()
.padding(horizontal = 16.dp),
label = stringResource(id = R.string.key),
Expand All @@ -278,6 +280,7 @@ fun EditItemContent(
Spacer(modifier = Modifier.height(8.dp))
BitwardenTextField(
modifier = Modifier
.semantics { testTag = "UsernameTextField" }
.fillMaxWidth()
.padding(horizontal = 16.dp),
label = stringResource(id = R.string.username),
Expand Down Expand Up @@ -331,6 +334,7 @@ private fun AdvancedOptions(
Column(modifier = modifier) {
Row(
modifier = Modifier
.semantics { testTag = "CollapseAdvancedOptions" }
.padding(vertical = 4.dp)
.clip(RoundedCornerShape(28.dp))
.clickable(
Expand Down Expand Up @@ -381,7 +385,7 @@ private fun AdvancedOptions(
BitwardenMultiSelectButton(
modifier = Modifier
.fillMaxSize()
.semantics { testTag = "ItemTypePicker" },
.semantics { testTag = "OTPItemTypePicker" },
label = stringResource(id = R.string.otp_type),
options = typeOptionsWithStrings.values.toImmutableList(),
selectedOption = viewState.itemData.type.name,
Expand All @@ -403,7 +407,8 @@ private fun AdvancedOptions(
Spacer(Modifier.height(8.dp))
BitwardenMultiSelectButton(
modifier = Modifier
.fillMaxWidth(),
.fillMaxWidth()
.semantics { testTag = "AlgorithmItemTypePicker" },
label = stringResource(id = R.string.algorithm),
options = algorithmOptionsWithStrings.values.toImmutableList(),
selectedOption = viewState.itemData.algorithm.name,
Expand All @@ -430,7 +435,8 @@ private fun AdvancedOptions(
Spacer(modifier = Modifier.height(8.dp))
BitwardenMultiSelectButton(
modifier = Modifier
.fillMaxWidth(),
.fillMaxWidth()
.semantics { testTag = "RefreshPeriodItemTypePicker" },
label = stringResource(id = R.string.refresh_period),
options = refreshPeriodOptionsWithStrings.values.toImmutableList(),
selectedOption = stringResource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
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.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -69,6 +71,7 @@ fun VaultVerificationCodeItem(
Box(modifier = modifier) {
Row(
modifier = Modifier
.semantics { testTag = "Item" }
.then(
if (allowLongPress) {
Modifier.combinedClickable(
Expand Down Expand Up @@ -98,7 +101,9 @@ fun VaultVerificationCodeItem(
iconData = startIcon,
contentDescription = null,
tint = MaterialTheme.colorScheme.onSurface,
modifier = Modifier.size(24.dp),
modifier = Modifier
.semantics { testTag = "BitwardenIcon" }
.size(24.dp),
)

Column(
Expand All @@ -108,6 +113,7 @@ fun VaultVerificationCodeItem(
) {
if (!primaryLabel.isNullOrEmpty()) {
Text(
modifier = Modifier.semantics { testTag = "Name" },
text = primaryLabel,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurface,
Expand All @@ -118,6 +124,7 @@ fun VaultVerificationCodeItem(

if (!secondaryLabel.isNullOrEmpty()) {
Text(
modifier = Modifier.semantics { testTag = "Username" },
text = secondaryLabel,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
Expand All @@ -128,12 +135,14 @@ fun VaultVerificationCodeItem(
}

BitwardenCircularCountdownIndicator(
modifier = Modifier.semantics { testTag = "CircularCountDown" },
timeLeftSeconds = timeLeftSeconds,
periodSeconds = periodSeconds,
alertThresholdSeconds = alertThresholdSeconds,
)

Text(
modifier = Modifier.semantics { testTag = "AuthCode" },
text = authCode.chunked(3).joinToString(" "),
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
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.text.input.KeyboardCapitalization
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand Down Expand Up @@ -175,6 +177,7 @@ fun ManualCodeEntryScreen(
}
},
modifier = Modifier
.semantics { testTag = "NameTextField" }
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
Expand All @@ -192,6 +195,7 @@ fun ManualCodeEntryScreen(
},
capitalization = KeyboardCapitalization.Characters,
modifier = Modifier
.semantics { testTag = "KeyTextField" }
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
Expand All @@ -203,6 +207,7 @@ fun ManualCodeEntryScreen(
{ viewModel.trySendAction(ManualCodeEntryAction.CodeSubmit) }
},
modifier = Modifier
.semantics { testTag = "AddCodeButton" }
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
Expand Down

0 comments on commit 932c26d

Please sign in to comment.