Update BitwardenPasswordField TestTags (#4621)

This commit is contained in:
David Perez authored and GitHub committed 2025-01-24 17:08:33 +00:00
1 parent dbefcfe342
commit 3a6db38172
19 files changed
+56 -38

No files matched your search

@@ -255,9 +255,9 @@ private fun CompleteRegistrationContent(
modifier = Modifier.fillMaxWidth(),
)
},
passwordFieldTestTag = "MasterPasswordEntry",
cardStyle = CardStyle.Top(dividerPadding = 0.dp),
modifier = Modifier
.testTag("MasterPasswordEntry")
.fillMaxWidth()
.standardHorizontalMargin(),
)
@@ -272,9 +272,9 @@ private fun CompleteRegistrationContent(
showPasswordChange = { showPassword = it },
onValueChange = handler.onConfirmPasswordInputChange,
showPasswordTestTag = "ConfirmPasswordVisibilityToggle",
passwordFieldTestTag = "ConfirmMasterPasswordEntry",
cardStyle = CardStyle.Middle(dividerPadding = 0.dp),
modifier = Modifier
.testTag("ConfirmMasterPasswordEntry")
.fillMaxWidth()
.standardHorizontalMargin(),
)
@@ -219,9 +219,9 @@ fun CreateAccountScreen(
color = BitwardenTheme.colorScheme.text.secondary,
)
},
passwordFieldTestTag = "MasterPasswordEntry",
cardStyle = CardStyle.Top(dividerPadding = 0.dp),
modifier = Modifier
.testTag("MasterPasswordEntry")
.fillMaxWidth()
.standardHorizontalMargin(),
)
@@ -234,9 +234,9 @@ fun CreateAccountScreen(
{ viewModel.trySendAction(ConfirmPasswordInputChange(it)) }
},
showPasswordTestTag = "ConfirmPasswordVisibilityToggle",
passwordFieldTestTag = "ConfirmMasterPasswordEntry",
cardStyle = CardStyle.Middle(dividerPadding = 0.dp),
modifier = Modifier
.testTag("ConfirmMasterPasswordEntry")
.fillMaxWidth()
.standardHorizontalMargin(),
)
@@ -105,10 +105,10 @@ private fun RemovePasswordScreenContent(
value = state.input,
onValueChange = onInputChanged,
showPasswordTestTag = "PasswordVisibilityToggle",
textFieldTestTag = "MasterPasswordEntry",
autoFocus = true,
cardStyle = CardStyle.Full,
modifier = Modifier
.testTag(tag = "MasterPasswordEntry")
.standardHorizontalMargin()
.fillMaxWidth(),
)
@@ -185,9 +185,9 @@ private fun ResetPasswordScreenContent(
label = stringResource(id = R.string.current_master_password),
value = state.currentPasswordInput,
onValueChange = onCurrentPasswordInputChanged,
textFieldTestTag = "MasterPasswordField",
cardStyle = CardStyle.Top(dividerPadding = 0.dp),
modifier = Modifier
.testTag("MasterPasswordField")
.standardHorizontalMargin()
.fillMaxWidth(),
)
@@ -200,6 +200,7 @@ private fun ResetPasswordScreenContent(
onValueChange = onPasswordInputChanged,
showPassword = isPasswordVisible,
showPasswordChange = { isPasswordVisible = it },
passwordFieldTestTag = "NewPasswordField",
cardStyle = if (
state.resetReason == ForcePasswordResetReason.WEAK_MASTER_PASSWORD_ON_LOGIN) {
CardStyle.Middle(dividerPadding = 0.dp)
@@ -207,7 +208,6 @@ private fun ResetPasswordScreenContent(
CardStyle.Top(dividerPadding = 0.dp)
},
modifier = Modifier
.testTag("NewPasswordField")
.standardHorizontalMargin()
.fillMaxWidth(),
)
@@ -218,9 +218,9 @@ private fun ResetPasswordScreenContent(
onValueChange = onRetypePasswordInputChanged,
showPassword = isPasswordVisible,
showPasswordChange = { isPasswordVisible = it },
passwordFieldTestTag = "RetypePasswordField",
cardStyle = CardStyle.Middle(dividerPadding = 0.dp),
modifier = Modifier
.testTag("RetypePasswordField")
.standardHorizontalMargin()
.fillMaxWidth(),
)
@@ -146,9 +146,9 @@ private fun SetPasswordScreenContent(
showPassword = isPasswordVisible,
showPasswordChange = { isPasswordVisible = it },
supportingText = stringResource(id = R.string.master_password_description),
passwordFieldTestTag = "NewPasswordField",
cardStyle = CardStyle.Top(dividerPadding = 0.dp),
modifier = Modifier
.testTag("NewPasswordField")
.standardHorizontalMargin()
.fillMaxWidth(),
)
@@ -159,9 +159,9 @@ private fun SetPasswordScreenContent(
onValueChange = onRetypePasswordInputChanged,
showPassword = isPasswordVisible,
showPasswordChange = { isPasswordVisible = it },
passwordFieldTestTag = "RetypePasswordField",
cardStyle = CardStyle.Middle(dividerPadding = 0.dp),
modifier = Modifier
.testTag("RetypePasswordField")
.standardHorizontalMargin()
.fillMaxWidth(),
)
@@ -270,9 +270,9 @@ fun VaultUnlockScreen(
},
),
supportingText = state.vaultUnlockType.unlockScreenMessage(),
textFieldTestTag = state.vaultUnlockType.unlockScreenInputTestTag,
cardStyle = CardStyle.Top(hasDivider = false),
modifier = Modifier
.testTag(tag = state.vaultUnlockType.unlockScreenInputTestTag)
.standardHorizontalMargin()
.fillMaxWidth(),
)
@@ -78,10 +78,9 @@ fun BitwardenMasterPasswordDialog(
value = masterPassword,
onValueChange = { masterPassword = it },
autoFocus = true,
textFieldTestTag = "AlertInputField",
cardStyle = CardStyle.Full,
modifier = Modifier
.testTag("AlertInputField")
.imePadding(),
modifier = Modifier.imePadding(),
)
}
},
@@ -66,9 +66,9 @@ fun BitwardenPinDialog(
value = pin,
onValueChange = { pin = it },
autoFocus = true,
textFieldTestTag = "AlertInputField",
cardStyle = CardStyle.Full,
modifier = Modifier
.testTag("AlertInputField")
.fillMaxWidth()
.imePadding(),
)
@@ -7,6 +7,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalTextToolbar
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.tooling.preview.Preview
@@ -24,6 +25,7 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
* @param label Label for the text field.
* @param value Current text on the text field.
* @param modifier Modifier for the composable.
* @param passwordFieldTestTag The optional test tag associated with the inner password field.
* @param cardStyle Indicates the type of card style to be applied.
*/
@Composable
@@ -31,13 +33,15 @@ fun BitwardenHiddenPasswordField(
label: String?,
value: String,
modifier: Modifier = Modifier,
passwordFieldTestTag: String? = null,
cardStyle: CardStyle? = null,
) {
CompositionLocalProvider(value = LocalTextToolbar provides BitwardenEmptyTextToolbar) {
TextField(
modifier = modifier
.cardBackground(cardStyle = cardStyle)
.cardPadding(cardStyle = cardStyle, vertical = 6.dp),
.cardPadding(cardStyle = cardStyle, vertical = 6.dp)
.run { passwordFieldTestTag?.let { testTag(tag = it) } ?: this },
textStyle = BitwardenTheme.typography.sensitiveInfoSmall,
label = label?.let { { Text(text = it) } },
value = value,
@@ -26,6 +26,7 @@ import androidx.compose.ui.focus.focusRequester
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.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTag
@@ -74,6 +75,7 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
* @param imeAction the preferred IME action for the keyboard to have.
* @param keyboardActions the callbacks of keyboard actions.
* @param textToolbarType The type of [TextToolbar] to use on the text field.
* @param passwordFieldTestTag The optional test tag associated with the inner password field.
* @param cardStyle Indicates the type of card style to be applied.
*/
@Suppress("LongMethod", "CyclomaticComplexMethod")
@@ -94,6 +96,7 @@ fun BitwardenPasswordField(
imeAction: ImeAction = ImeAction.Default,
keyboardActions: KeyboardActions = KeyboardActions.Default,
textToolbarType: TextToolbarType = TextToolbarType.DEFAULT,
passwordFieldTestTag: String? = null,
cardStyle: CardStyle? = null,
) {
val focusRequester = remember { FocusRequester() }
@@ -165,7 +168,9 @@ fun BitwardenPasswordField(
onClick = { showPasswordChange.invoke(!showPassword) },
)
},
modifier = Modifier.fillMaxWidth(),
modifier = Modifier
.run { passwordFieldTestTag?.let { testTag(tag = it) } ?: this }
.fillMaxWidth(),
)
supportingTextContent?.let {
Spacer(modifier = Modifier.height(height = 8.dp))
@@ -211,6 +216,7 @@ fun BitwardenPasswordField(
* @param imeAction the preferred IME action for the keyboard to have.
* @param keyboardActions the callbacks of keyboard actions.
* @param textToolbarType The type of [TextToolbar] to use on the text field.
* @param passwordFieldTestTag The optional test tag associated with the inner password field.
* @param cardStyle Indicates the type of card style to be applied.
*/
@Composable
@@ -230,6 +236,7 @@ fun BitwardenPasswordField(
imeAction: ImeAction = ImeAction.Default,
keyboardActions: KeyboardActions = KeyboardActions.Default,
textToolbarType: TextToolbarType = TextToolbarType.DEFAULT,
passwordFieldTestTag: String? = null,
cardStyle: CardStyle? = null,
) {
BitwardenPasswordField(
@@ -257,6 +264,7 @@ fun BitwardenPasswordField(
imeAction = imeAction,
keyboardActions = keyboardActions,
textToolbarType = textToolbarType,
passwordFieldTestTag = passwordFieldTestTag,
cardStyle = cardStyle,
)
}
@@ -285,6 +293,7 @@ fun BitwardenPasswordField(
* @param imeAction the preferred IME action for the keyboard to have.
* @param keyboardActions the callbacks of keyboard actions.
* @param textToolbarType The type of [TextToolbar] to use on the text field.
* @param passwordFieldTestTag The optional test tag associated with the inner password field.
* @param cardStyle Indicates the type of card style to be applied.
*/
@Composable
@@ -303,6 +312,7 @@ fun BitwardenPasswordField(
imeAction: ImeAction = ImeAction.Default,
keyboardActions: KeyboardActions = KeyboardActions.Default,
textToolbarType: TextToolbarType = TextToolbarType.DEFAULT,
passwordFieldTestTag: String? = null,
cardStyle: CardStyle? = null,
) {
var showPassword by rememberSaveable { mutableStateOf(value = initialShowPassword) }
@@ -322,6 +332,7 @@ fun BitwardenPasswordField(
imeAction = imeAction,
keyboardActions = keyboardActions,
textToolbarType = textToolbarType,
passwordFieldTestTag = passwordFieldTestTag,
cardStyle = cardStyle,
)
}
@@ -347,6 +358,7 @@ fun BitwardenPasswordField(
* the password field.
* @param imeAction the preferred IME action for the keyboard to have.
* @param keyboardActions the callbacks of keyboard actions.
* @param textFieldTestTag The optional test tag associated with the inner text field.
* @param cardStyle Indicates the type of card style to be applied.
*/
@Composable
@@ -364,6 +376,7 @@ fun BitwardenPasswordField(
keyboardType: KeyboardType = KeyboardType.Password,
imeAction: ImeAction = ImeAction.Default,
keyboardActions: KeyboardActions = KeyboardActions.Default,
textFieldTestTag: String? = null,
cardStyle: CardStyle? = null,
) {
var showPassword by rememberSaveable { mutableStateOf(initialShowPassword) }
@@ -382,6 +395,7 @@ fun BitwardenPasswordField(
keyboardType = keyboardType,
imeAction = imeAction,
keyboardActions = keyboardActions,
passwordFieldTestTag = textFieldTestTag,
cardStyle = cardStyle,
)
}
@@ -20,7 +20,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.TextToolbar
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
@@ -95,10 +94,9 @@ fun BitwardenPasswordFieldWithActions(
readOnly = readOnly,
singleLine = singleLine,
showPasswordTestTag = showPasswordTestTag,
passwordFieldTestTag = passwordFieldTestTag,
textToolbarType = textToolbarType,
modifier = Modifier
.semantics { passwordFieldTestTag?.let { testTag = it } }
.weight(weight = 1f),
modifier = Modifier.weight(weight = 1f),
)
BitwardenRowOfActions(
modifier = Modifier.padding(paddingValues = actionsPadding),
@@ -78,6 +78,7 @@ import kotlinx.collections.immutable.toImmutableList
* @param visualTransformation Transforms the visual representation of the input [value].
* @param keyboardType the preferred type of keyboard input.
* @param textToolbarType The type of [TextToolbar] to use on the text field.
* @param textFieldTestTag The optional test tag associated with the inner text field.
* @param cardStyle Indicates the type of card style to be applied.
*/
@Composable
@@ -161,6 +162,7 @@ fun BitwardenTextField(
* @param visualTransformation Transforms the visual representation of the input [value].
* @param keyboardType the preferred type of keyboard input.
* @param textToolbarType The type of [TextToolbar] to use on the text field.
* @param textFieldTestTag The optional test tag associated with the inner text field.
* @param cardStyle Indicates the type of card style to be applied.
*/
@Suppress("LongMethod", "CyclomaticComplexMethod")
@@ -249,9 +249,9 @@ private fun ExportVaultScreenContent(
modifier = Modifier.fillMaxWidth(),
)
},
showPasswordTestTag = "FilePasswordEntry",
cardStyle = CardStyle.Full,
modifier = Modifier
.testTag("FilePasswordEntry")
.standardHorizontalMargin()
.fillMaxWidth(),
)
@@ -264,9 +264,9 @@ private fun ExportVaultScreenContent(
onValueChange = onConfirmFilePasswordInputChanged,
showPassword = showPassword,
showPasswordChange = { showPassword = it },
passwordFieldTestTag = "ConfirmFilePasswordEntry",
cardStyle = CardStyle.Full,
modifier = Modifier
.testTag("ConfirmFilePasswordEntry")
.standardHorizontalMargin()
.fillMaxWidth(),
)
@@ -321,9 +321,9 @@ private fun ExportVaultScreenContent(
value = state.passwordInput,
readOnly = state.policyPreventsExport,
onValueChange = onPasswordInputChanged,
textFieldTestTag = "MasterPasswordEntry",
cardStyle = CardStyle.Full,
modifier = Modifier
.testTag("MasterPasswordEntry")
.standardHorizontalMargin()
.fillMaxWidth(),
)
@@ -927,10 +927,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
value = usernameTypeState.selectedServiceType.apiAccessToken,
onValueChange = forwardedEmailAliasHandlers.onAddyIoAccessTokenTextChange,
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
textFieldTestTag = "ForwardedEmailApiSecretEntry",
cardStyle = CardStyle.Full,
modifier = Modifier
.standardHorizontalMargin()
.testTag("ForwardedEmailApiSecretEntry")
.fillMaxWidth(),
)
@@ -954,10 +954,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
value = usernameTypeState.selectedServiceType.apiKey,
onValueChange = forwardedEmailAliasHandlers.onDuckDuckGoApiKeyTextChange,
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
textFieldTestTag = "ForwardedEmailApiSecretEntry",
cardStyle = CardStyle.Full,
modifier = Modifier
.standardHorizontalMargin()
.testTag("ForwardedEmailApiSecretEntry")
.fillMaxWidth(),
)
}
@@ -968,10 +968,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
value = usernameTypeState.selectedServiceType.apiKey,
onValueChange = forwardedEmailAliasHandlers.onFastMailApiKeyTextChange,
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
textFieldTestTag = "ForwardedEmailApiSecretEntry",
cardStyle = CardStyle.Full,
modifier = Modifier
.standardHorizontalMargin()
.testTag("ForwardedEmailApiSecretEntry")
.fillMaxWidth(),
)
}
@@ -982,10 +982,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
value = usernameTypeState.selectedServiceType.apiAccessToken,
onValueChange = forwardedEmailAliasHandlers.onFirefoxRelayAccessTokenTextChange,
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
textFieldTestTag = "ForwardedEmailApiSecretEntry",
cardStyle = CardStyle.Full,
modifier = Modifier
.standardHorizontalMargin()
.testTag("ForwardedEmailApiSecretEntry")
.fillMaxWidth(),
)
}
@@ -996,10 +996,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
value = usernameTypeState.selectedServiceType.apiKey,
onValueChange = forwardedEmailAliasHandlers.onForwardEmailApiKeyTextChange,
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
textFieldTestTag = "ForwardedEmailApiSecretEntry",
cardStyle = CardStyle.Full,
modifier = Modifier
.standardHorizontalMargin()
.testTag("ForwardedEmailApiSecretEntry")
.fillMaxWidth(),
)
@@ -1023,10 +1023,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
value = usernameTypeState.selectedServiceType.apiKey,
onValueChange = forwardedEmailAliasHandlers.onSimpleLoginApiKeyTextChange,
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
textFieldTestTag = "ForwardedEmailApiSecretEntry",
cardStyle = CardStyle.Full,
modifier = Modifier
.standardHorizontalMargin()
.testTag("ForwardedEmailApiSecretEntry")
.fillMaxWidth(),
)
}
@@ -1038,10 +1038,10 @@ private fun ColumnScope.ForwardedEmailAliasTypeContent(
value = obfuscatedTextField,
onValueChange = { obfuscatedTextField = it },
showPasswordTestTag = "ShowForwardedEmailApiSecretButton",
textFieldTestTag = "ForwardedEmailApiSecretEntry",
cardStyle = CardStyle.Full,
modifier = Modifier
.standardHorizontalMargin()
.testTag("ForwardedEmailApiSecretEntry")
.fillMaxWidth(),
)
}
@@ -420,9 +420,9 @@ private fun AddSendOptions(
readOnly = sendRestrictionPolicy,
value = state.common.passwordInput,
onValueChange = addSendHandlers.onPasswordChange,
textFieldTestTag = "SendNewPasswordEntry",
cardStyle = CardStyle.Full,
modifier = Modifier
.testTag("SendNewPasswordEntry")
.fillMaxWidth()
.standardHorizontalMargin(),
)
@@ -85,9 +85,9 @@ fun LazyListScope.vaultAddEditCardItems(
cardHandlers.onNumberVisibilityChange(showNumber)
},
showPasswordTestTag = "ShowCardNumberButton",
passwordFieldTestTag = "CardNumberEntry",
cardStyle = CardStyle.Middle(),
modifier = Modifier
.testTag("CardNumberEntry")
.fillMaxWidth()
.standardHorizontalMargin(),
)
@@ -164,9 +164,9 @@ fun LazyListScope.vaultAddEditCardItems(
},
keyboardType = KeyboardType.NumberPassword,
showPasswordTestTag = "CardShowSecurityCodeButton",
passwordFieldTestTag = "CardSecurityCodeEntry",
cardStyle = CardStyle.Bottom,
modifier = Modifier
.testTag("CardSecurityCodeEntry")
.fillMaxWidth()
.standardHorizontalMargin(),
)
@@ -578,8 +578,9 @@ private fun CoachMarkScope<AddEditItemCoachMark>.PasswordRow(
BitwardenHiddenPasswordField(
label = stringResource(id = R.string.password),
value = password,
passwordFieldTestTag = "LoginPasswordEntry",
cardStyle = CardStyle.Bottom,
modifier = modifier.testTag("LoginPasswordEntry"),
modifier = modifier,
)
}
}
@@ -77,9 +77,9 @@ fun LazyListScope.vaultAddEditSshKeyItems(
showPassword = sshKeyState.showPrivateKey,
showPasswordChange = { sshKeyTypeHandlers.onPrivateKeyVisibilityChange(it) },
showPasswordTestTag = "ViewPrivateKeyButton",
passwordFieldTestTag = "PrivateKeyEntry",
cardStyle = CardStyle.Middle(),
modifier = Modifier
.testTag("PrivateKeyEntry")
.fillMaxWidth()
.standardHorizontalMargin(),
)
@@ -376,9 +376,9 @@ private fun PasswordField(
BitwardenHiddenPasswordField(
label = stringResource(id = R.string.password),
value = passwordData.password,
passwordFieldTestTag = "LoginPasswordEntry",
cardStyle = cardStyle,
modifier = modifier
.testTag("LoginPasswordEntry"),
modifier = modifier,
)
}
}