Skip to content

Commit

Permalink
PM-16058 add test tag parameter to be applied to the text field (#4487)
Browse files Browse the repository at this point in the history
  • Loading branch information
dseverns-livefront authored Dec 18, 2024
1 parent e2b93ec commit 8548c74
Show file tree
Hide file tree
Showing 25 changed files with 71 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ private fun CompleteRegistrationContent(
?: R.string.master_password_hint_description,
),
modifier = Modifier
.testTag("MasterPasswordHintLabel")
.fillMaxWidth()
.standardHorizontalMargin(),
textFieldTestTag = "MasterPasswordHintLabel",
)
if (showNewOnboardingUi) {
BitwardenClickableText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ fun CreateAccountScreen(
{ viewModel.trySendAction(EmailInputChange(it)) }
},
modifier = Modifier
.testTag("EmailAddressEntry")
.fillMaxWidth()
.padding(horizontal = 16.dp),
keyboardType = KeyboardType.Email,
textFieldTestTag = "EmailAddressEntry",
)
Spacer(modifier = Modifier.height(16.dp))
var showPassword by rememberSaveable { mutableStateOf(false) }
Expand Down Expand Up @@ -239,9 +239,9 @@ fun CreateAccountScreen(
},
hint = stringResource(id = R.string.master_password_hint_description),
modifier = Modifier
.testTag("MasterPasswordHintLabel")
.fillMaxWidth()
.padding(horizontal = 16.dp),
textFieldTestTag = "MasterPasswordHintLabel",
)
Spacer(modifier = Modifier.height(24.dp))
BitwardenSwitch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ private fun EnterpriseSignOnScreenContent(
BitwardenTextField(
modifier = Modifier
.padding(horizontal = 16.dp)
.fillMaxWidth()
.testTag("OrgSSOIdentifierEntry"),
.fillMaxWidth(),
value = state.orgIdentifierInput,
onValueChange = onOrgIdentifierInputChange,
label = stringResource(id = R.string.org_identifier),
textFieldTestTag = "OrgSSOIdentifierEntry",
)

Spacer(modifier = Modifier.height(16.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ fun EnvironmentScreen(
keyboardType = KeyboardType.Uri,
modifier = Modifier
.fillMaxWidth()
.testTag("ServerUrlEntry")
.padding(horizontal = 16.dp),
textFieldTestTag = "ServerUrlEntry",
)

Spacer(modifier = Modifier.height(24.dp))
Expand All @@ -153,8 +153,8 @@ fun EnvironmentScreen(
keyboardType = KeyboardType.Uri,
modifier = Modifier
.fillMaxWidth()
.testTag("WebVaultUrlEntry")
.padding(horizontal = 16.dp),
textFieldTestTag = "WebVaultUrlEntry",
)

Spacer(modifier = Modifier.height(16.dp))
Expand Down Expand Up @@ -183,8 +183,8 @@ fun EnvironmentScreen(
keyboardType = KeyboardType.Uri,
modifier = Modifier
.fillMaxWidth()
.testTag("IdentityUrlEntry")
.padding(horizontal = 16.dp),
textFieldTestTag = "IdentityUrlEntry",
)

Spacer(modifier = Modifier.height(16.dp))
Expand All @@ -199,8 +199,8 @@ fun EnvironmentScreen(
keyboardType = KeyboardType.Uri,
modifier = Modifier
.fillMaxWidth()
.testTag("IconsUrlEntry")
.padding(horizontal = 16.dp),
textFieldTestTag = "IconsUrlEntry",
)

Spacer(modifier = Modifier.navigationBarsPadding())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ private fun LandingScreenContent(

BitwardenTextField(
modifier = Modifier
.testTag("EmailAddressEntry")
.padding(horizontal = 16.dp)
.fillMaxWidth(),
value = state.emailInput,
onValueChange = onEmailInputChange,
label = stringResource(id = R.string.email_address),
keyboardType = KeyboardType.Email,
textFieldTestTag = "EmailAddressEntry",
)

Spacer(modifier = Modifier.height(2.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ private fun ResetPasswordScreenContent(
onValueChange = onPasswordHintInputChanged,
hint = stringResource(id = R.string.master_password_hint_description),
modifier = Modifier
.testTag("MasterPasswordHintLabel")
.fillMaxWidth()
.padding(horizontal = 16.dp),
textFieldTestTag = "MasterPasswordHintLabel",
)

Spacer(modifier = Modifier.navigationBarsPadding())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ private fun SetPasswordScreenContent(
onValueChange = onPasswordHintInputChanged,
hint = stringResource(id = R.string.master_password_hint_description),
modifier = Modifier
.testTag("MasterPasswordHintLabel")
.fillMaxWidth()
.padding(horizontal = 16.dp),
textFieldTestTag = "MasterPasswordHintLabel",
)

Spacer(modifier = Modifier.navigationBarsPadding())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ private fun StartRegistrationContent(
value = nameInput,
onValueChange = handler.onNameInputChange,
modifier = Modifier
.testTag("NameEntry")
.fillMaxWidth()
.standardHorizontalMargin(),
textFieldTestTag = "NameEntry",
)
Spacer(modifier = Modifier.height(16.dp))
BitwardenTextField(
Expand All @@ -225,10 +225,10 @@ private fun StartRegistrationContent(
value = emailInput,
onValueChange = handler.onEmailInputChange,
modifier = Modifier
.testTag("EmailAddressEntry")
.fillMaxWidth()
.standardHorizontalMargin(),
keyboardType = KeyboardType.Email,
textFieldTestTag = "EmailAddressEntry",
)
Spacer(modifier = Modifier.height(2.dp))
Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ fun BitwardenTextEntryDialog(
value = text,
onValueChange = { text = it },
modifier = Modifier
.testTag("AlertContentText")
.focusRequester(focusRequester)
.onGloballyPositioned {
shouldRequestFocus = true
},
textFieldTestTag = "AlertContentText",
)
},
shape = BitwardenTheme.shapes.dialog,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalTextToolbar
import androidx.compose.ui.platform.TextToolbar
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.TextFieldValue
Expand Down Expand Up @@ -89,7 +90,8 @@ fun BitwardenTextField(
autoFocus: Boolean = false,
visualTransformation: VisualTransformation = VisualTransformation.None,
textToolbarType: TextToolbarType = TextToolbarType.DEFAULT,
autoCompleteOptions: ImmutableList<String> = persistentListOf<String>(),
autoCompleteOptions: ImmutableList<String> = persistentListOf(),
textFieldTestTag: String? = null,
) {
var widthPx by remember { mutableIntStateOf(0) }
val focusRequester = remember { FocusRequester() }
Expand Down Expand Up @@ -127,7 +129,8 @@ fun BitwardenTextField(
Box(modifier = modifier) {
OutlinedTextField(
colors = bitwardenTextFieldColors(),
modifier = Modifier
modifier = modifier
.testTag(textFieldTestTag.orEmpty())
.onGloballyPositioned { widthPx = it.size.width }
.onFocusEvent { focusState -> hasFocused = focusState.hasFocus }
.focusRequester(focusRequester)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ fun BitwardenTextFieldWithActions(
verticalAlignment = Alignment.CenterVertically,
) {
BitwardenTextField(
modifier = Modifier
.semantics { textFieldTestTag?.let { testTag = it } }
.weight(1f),
modifier = Modifier.weight(1f),
label = label,
value = value,
readOnly = readOnly,
Expand All @@ -85,6 +83,7 @@ fun BitwardenTextFieldWithActions(
shouldAddCustomLineBreaks = shouldAddCustomLineBreaks,
visualTransformation = visualTransformation,
textToolbarType = textToolbarType,
textFieldTestTag = textFieldTestTag,
)
BitwardenRowOfActions(
modifier = Modifier.run { actionsTestTag?.let { testTag(it) } ?: this },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ fun PinInputDialog(
},
keyboardType = KeyboardType.Number,
modifier = Modifier
.testTag(tag = "AlertInputField")
.fillMaxWidth(),
textFieldTestTag = "AlertInputField",
)
Spacer(modifier = Modifier.height(height = 16.dp))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,9 @@ private fun PassphraseWordSeparatorInputItem(
}
},
modifier = modifier
.testTag("WordSeparatorEntry")
.fillMaxWidth()
.padding(horizontal = 16.dp),
textFieldTestTag = "WordSeparatorEntry",
)
}

Expand Down Expand Up @@ -917,8 +917,8 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
onValueChange = forwardedEmailAliasHandlers.onAddyIoDomainNameTextChange,
modifier = Modifier
.padding(horizontal = 16.dp)
.testTag("AnonAddyDomainNameEntry")
.fillMaxWidth(),
textFieldTestTag = "AnonAddyDomainNameEntry",
)
}

Expand Down Expand Up @@ -981,8 +981,8 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
onValueChange = forwardedEmailAliasHandlers.onForwardEmailDomainNameTextChange,
modifier = Modifier
.padding(horizontal = 16.dp)
.testTag("ForwardedEmailDomainNameEntry")
.fillMaxWidth(),
textFieldTestTag = "ForwardedEmailDomainNameEntry",
)
}

Expand Down Expand Up @@ -1069,8 +1069,8 @@ private fun PlusAddressedEmailTextInputItem(
onValueChange = onPlusAddressedEmailTextChange,
modifier = modifier
.fillMaxWidth()
.testTag("PlusAddressedEmailEntry")
.padding(horizontal = 16.dp),
textFieldTestTag = "PlusAddressedEmailEntry",
)
}

Expand Down Expand Up @@ -1103,8 +1103,8 @@ private fun CatchAllEmailTextInputItem(
onValueChange = onDomainTextChange,
modifier = modifier
.fillMaxWidth()
.testTag("CatchAllEmailDomainEntry")
.padding(horizontal = 16.dp),
textFieldTestTag = "CatchAllEmailDomainEntry",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ fun AddSendContent(

BitwardenTextField(
modifier = Modifier
.testTag(tag = "SendNameEntry")
.fillMaxWidth()
.padding(horizontal = 16.dp),
label = stringResource(id = R.string.name),
hint = stringResource(id = R.string.name_info),
readOnly = policyDisablesSend,
value = state.common.name,
onValueChange = addSendHandlers.onNamChange,
textFieldTestTag = "SendNameEntry",
)

Spacer(modifier = Modifier.height(8.dp))
Expand Down Expand Up @@ -203,7 +203,6 @@ fun AddSendContent(
is AddSendState.ViewState.Content.SendType.Text -> {
BitwardenTextField(
modifier = Modifier
.testTag(tag = "SendTextContentEntry")
.fillMaxWidth()
.padding(horizontal = 16.dp),
label = stringResource(id = R.string.text),
Expand All @@ -212,6 +211,7 @@ fun AddSendContent(
value = type.input,
singleLine = false,
onValueChange = addSendHandlers.onTextChange,
textFieldTestTag = "SendTextContentEntry",
)
Spacer(modifier = Modifier.height(16.dp))
BitwardenSwitch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ fun LazyListScope.vaultAddEditCardItems(
value = commonState.name,
onValueChange = commonHandlers.onNameTextChange,
modifier = Modifier
.testTag("ItemNameEntry")
.fillMaxWidth()
.padding(horizontal = 16.dp),
textFieldTestTag = "ItemNameEntry",
)
}
item {
Expand All @@ -64,9 +64,9 @@ fun LazyListScope.vaultAddEditCardItems(
value = cardState.cardHolderName,
onValueChange = cardHandlers.onCardHolderNameTextChange,
modifier = Modifier
.testTag("CardholderNameEntry")
.fillMaxWidth()
.padding(horizontal = 16.dp),
textFieldTestTag = "CardholderNameEntry",
)
}
item {
Expand Down Expand Up @@ -140,9 +140,9 @@ fun LazyListScope.vaultAddEditCardItems(
onValueChange = cardHandlers.onExpirationYearTextChange,
keyboardType = KeyboardType.Number,
modifier = Modifier
.testTag("CardExpirationYearEntry")
.fillMaxWidth()
.padding(horizontal = 16.dp),
textFieldTestTag = "CardExpirationYearEntry",
)
}
item {
Expand Down Expand Up @@ -253,9 +253,9 @@ fun LazyListScope.vaultAddEditCardItems(
value = commonState.notes,
onValueChange = commonHandlers.onNotesTextChange,
modifier = Modifier
.testTag("ItemNotesEntry")
.fillMaxWidth()
.padding(horizontal = 16.dp),
textFieldTestTag = "ItemNotesEntry",
)
}

Expand Down
Loading

0 comments on commit 8548c74

Please sign in to comment.