Skip to content

Commit d96494e

Browse files
Update BitwardenPasswordField TestTags (#4632)
1 parent 91d7cf4 commit d96494e

File tree

19 files changed

+56
-38
lines changed

19 files changed

+56
-38
lines changed

app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/completeregistration/CompleteRegistrationScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ private fun CompleteRegistrationContent(
255255
modifier = Modifier.fillMaxWidth(),
256256
)
257257
},
258+
passwordFieldTestTag = "MasterPasswordEntry",
258259
cardStyle = CardStyle.Top(dividerPadding = 0.dp),
259260
modifier = Modifier
260-
.testTag("MasterPasswordEntry")
261261
.fillMaxWidth()
262262
.standardHorizontalMargin(),
263263
)
@@ -272,9 +272,9 @@ private fun CompleteRegistrationContent(
272272
showPasswordChange = { showPassword = it },
273273
onValueChange = handler.onConfirmPasswordInputChange,
274274
showPasswordTestTag = "ConfirmPasswordVisibilityToggle",
275+
passwordFieldTestTag = "ConfirmMasterPasswordEntry",
275276
cardStyle = CardStyle.Middle(dividerPadding = 0.dp),
276277
modifier = Modifier
277-
.testTag("ConfirmMasterPasswordEntry")
278278
.fillMaxWidth()
279279
.standardHorizontalMargin(),
280280
)

app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/createaccount/CreateAccountScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ fun CreateAccountScreen(
219219
color = BitwardenTheme.colorScheme.text.secondary,
220220
)
221221
},
222+
passwordFieldTestTag = "MasterPasswordEntry",
222223
cardStyle = CardStyle.Top(dividerPadding = 0.dp),
223224
modifier = Modifier
224-
.testTag("MasterPasswordEntry")
225225
.fillMaxWidth()
226226
.standardHorizontalMargin(),
227227
)
@@ -234,9 +234,9 @@ fun CreateAccountScreen(
234234
{ viewModel.trySendAction(ConfirmPasswordInputChange(it)) }
235235
},
236236
showPasswordTestTag = "ConfirmPasswordVisibilityToggle",
237+
passwordFieldTestTag = "ConfirmMasterPasswordEntry",
237238
cardStyle = CardStyle.Middle(dividerPadding = 0.dp),
238239
modifier = Modifier
239-
.testTag("ConfirmMasterPasswordEntry")
240240
.fillMaxWidth()
241241
.standardHorizontalMargin(),
242242
)

app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/removepassword/RemovePasswordScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ private fun RemovePasswordScreenContent(
105105
value = state.input,
106106
onValueChange = onInputChanged,
107107
showPasswordTestTag = "PasswordVisibilityToggle",
108+
textFieldTestTag = "MasterPasswordEntry",
108109
autoFocus = true,
109110
cardStyle = CardStyle.Full,
110111
modifier = Modifier
111-
.testTag(tag = "MasterPasswordEntry")
112112
.standardHorizontalMargin()
113113
.fillMaxWidth(),
114114
)

app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/resetpassword/ResetPasswordScreen.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ private fun ResetPasswordScreenContent(
185185
label = stringResource(id = R.string.current_master_password),
186186
value = state.currentPasswordInput,
187187
onValueChange = onCurrentPasswordInputChanged,
188+
textFieldTestTag = "MasterPasswordField",
188189
cardStyle = CardStyle.Top(dividerPadding = 0.dp),
189190
modifier = Modifier
190-
.testTag("MasterPasswordField")
191191
.standardHorizontalMargin()
192192
.fillMaxWidth(),
193193
)
@@ -200,14 +200,14 @@ private fun ResetPasswordScreenContent(
200200
onValueChange = onPasswordInputChanged,
201201
showPassword = isPasswordVisible,
202202
showPasswordChange = { isPasswordVisible = it },
203+
passwordFieldTestTag = "NewPasswordField",
203204
cardStyle = if (
204205
state.resetReason == ForcePasswordResetReason.WEAK_MASTER_PASSWORD_ON_LOGIN) {
205206
CardStyle.Middle(dividerPadding = 0.dp)
206207
} else {
207208
CardStyle.Top(dividerPadding = 0.dp)
208209
},
209210
modifier = Modifier
210-
.testTag("NewPasswordField")
211211
.standardHorizontalMargin()
212212
.fillMaxWidth(),
213213
)
@@ -218,9 +218,9 @@ private fun ResetPasswordScreenContent(
218218
onValueChange = onRetypePasswordInputChanged,
219219
showPassword = isPasswordVisible,
220220
showPasswordChange = { isPasswordVisible = it },
221+
passwordFieldTestTag = "RetypePasswordField",
221222
cardStyle = CardStyle.Middle(dividerPadding = 0.dp),
222223
modifier = Modifier
223-
.testTag("RetypePasswordField")
224224
.standardHorizontalMargin()
225225
.fillMaxWidth(),
226226
)

app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/setpassword/SetPasswordScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ private fun SetPasswordScreenContent(
146146
showPassword = isPasswordVisible,
147147
showPasswordChange = { isPasswordVisible = it },
148148
supportingText = stringResource(id = R.string.master_password_description),
149+
passwordFieldTestTag = "NewPasswordField",
149150
cardStyle = CardStyle.Top(dividerPadding = 0.dp),
150151
modifier = Modifier
151-
.testTag("NewPasswordField")
152152
.standardHorizontalMargin()
153153
.fillMaxWidth(),
154154
)
@@ -159,9 +159,9 @@ private fun SetPasswordScreenContent(
159159
onValueChange = onRetypePasswordInputChanged,
160160
showPassword = isPasswordVisible,
161161
showPasswordChange = { isPasswordVisible = it },
162+
passwordFieldTestTag = "RetypePasswordField",
162163
cardStyle = CardStyle.Middle(dividerPadding = 0.dp),
163164
modifier = Modifier
164-
.testTag("RetypePasswordField")
165165
.standardHorizontalMargin()
166166
.fillMaxWidth(),
167167
)

app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/vaultunlock/VaultUnlockScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ fun VaultUnlockScreen(
270270
},
271271
),
272272
supportingText = state.vaultUnlockType.unlockScreenMessage(),
273+
textFieldTestTag = state.vaultUnlockType.unlockScreenInputTestTag,
273274
cardStyle = CardStyle.Top(hasDivider = false),
274275
modifier = Modifier
275-
.testTag(tag = state.vaultUnlockType.unlockScreenInputTestTag)
276276
.standardHorizontalMargin()
277277
.fillMaxWidth(),
278278
)

app/src/main/java/com/x8bit/bitwarden/ui/platform/components/dialog/BitwardenMasterPasswordDialog.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,9 @@ fun BitwardenMasterPasswordDialog(
7878
value = masterPassword,
7979
onValueChange = { masterPassword = it },
8080
autoFocus = true,
81+
textFieldTestTag = "AlertInputField",
8182
cardStyle = CardStyle.Full,
82-
modifier = Modifier
83-
.testTag("AlertInputField")
84-
.imePadding(),
83+
modifier = Modifier.imePadding(),
8584
)
8685
}
8786
},

app/src/main/java/com/x8bit/bitwarden/ui/platform/components/dialog/BitwardenPinDialog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ fun BitwardenPinDialog(
6666
value = pin,
6767
onValueChange = { pin = it },
6868
autoFocus = true,
69+
textFieldTestTag = "AlertInputField",
6970
cardStyle = CardStyle.Full,
7071
modifier = Modifier
71-
.testTag("AlertInputField")
7272
.fillMaxWidth()
7373
.imePadding(),
7474
)

app/src/main/java/com/x8bit/bitwarden/ui/platform/components/field/BitwardenHiddenPasswordField.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import androidx.compose.runtime.Composable
77
import androidx.compose.runtime.CompositionLocalProvider
88
import androidx.compose.ui.Modifier
99
import androidx.compose.ui.platform.LocalTextToolbar
10+
import androidx.compose.ui.platform.testTag
1011
import androidx.compose.ui.text.input.KeyboardType
1112
import androidx.compose.ui.text.input.PasswordVisualTransformation
1213
import androidx.compose.ui.tooling.preview.Preview
@@ -24,20 +25,23 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
2425
* @param label Label for the text field.
2526
* @param value Current text on the text field.
2627
* @param modifier Modifier for the composable.
28+
* @param passwordFieldTestTag The optional test tag associated with the inner password field.
2729
* @param cardStyle Indicates the type of card style to be applied.
2830
*/
2931
@Composable
3032
fun BitwardenHiddenPasswordField(
3133
label: String?,
3234
value: String,
3335
modifier: Modifier = Modifier,
36+
passwordFieldTestTag: String? = null,
3437
cardStyle: CardStyle? = null,
3538
) {
3639
CompositionLocalProvider(value = LocalTextToolbar provides BitwardenEmptyTextToolbar) {
3740
TextField(
3841
modifier = modifier
3942
.cardBackground(cardStyle = cardStyle)
40-
.cardPadding(cardStyle = cardStyle, vertical = 6.dp),
43+
.cardPadding(cardStyle = cardStyle, vertical = 6.dp)
44+
.run { passwordFieldTestTag?.let { testTag(tag = it) } ?: this },
4145
textStyle = BitwardenTheme.typography.sensitiveInfoSmall,
4246
label = label?.let { { Text(text = it) } },
4347
value = value,

app/src/main/java/com/x8bit/bitwarden/ui/platform/components/field/BitwardenPasswordField.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import androidx.compose.ui.focus.focusRequester
2626
import androidx.compose.ui.platform.LocalClipboardManager
2727
import androidx.compose.ui.platform.LocalTextToolbar
2828
import androidx.compose.ui.platform.TextToolbar
29+
import androidx.compose.ui.platform.testTag
2930
import androidx.compose.ui.res.stringResource
3031
import androidx.compose.ui.semantics.semantics
3132
import androidx.compose.ui.semantics.testTag
@@ -74,6 +75,7 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
7475
* @param imeAction the preferred IME action for the keyboard to have.
7576
* @param keyboardActions the callbacks of keyboard actions.
7677
* @param textToolbarType The type of [TextToolbar] to use on the text field.
78+
* @param passwordFieldTestTag The optional test tag associated with the inner password field.
7779
* @param cardStyle Indicates the type of card style to be applied.
7880
*/
7981
@Suppress("LongMethod", "CyclomaticComplexMethod")
@@ -94,6 +96,7 @@ fun BitwardenPasswordField(
9496
imeAction: ImeAction = ImeAction.Default,
9597
keyboardActions: KeyboardActions = KeyboardActions.Default,
9698
textToolbarType: TextToolbarType = TextToolbarType.DEFAULT,
99+
passwordFieldTestTag: String? = null,
97100
cardStyle: CardStyle? = null,
98101
) {
99102
val focusRequester = remember { FocusRequester() }
@@ -165,7 +168,9 @@ fun BitwardenPasswordField(
165168
onClick = { showPasswordChange.invoke(!showPassword) },
166169
)
167170
},
168-
modifier = Modifier.fillMaxWidth(),
171+
modifier = Modifier
172+
.run { passwordFieldTestTag?.let { testTag(tag = it) } ?: this }
173+
.fillMaxWidth(),
169174
)
170175
supportingTextContent?.let {
171176
Spacer(modifier = Modifier.height(height = 8.dp))
@@ -211,6 +216,7 @@ fun BitwardenPasswordField(
211216
* @param imeAction the preferred IME action for the keyboard to have.
212217
* @param keyboardActions the callbacks of keyboard actions.
213218
* @param textToolbarType The type of [TextToolbar] to use on the text field.
219+
* @param passwordFieldTestTag The optional test tag associated with the inner password field.
214220
* @param cardStyle Indicates the type of card style to be applied.
215221
*/
216222
@Composable
@@ -230,6 +236,7 @@ fun BitwardenPasswordField(
230236
imeAction: ImeAction = ImeAction.Default,
231237
keyboardActions: KeyboardActions = KeyboardActions.Default,
232238
textToolbarType: TextToolbarType = TextToolbarType.DEFAULT,
239+
passwordFieldTestTag: String? = null,
233240
cardStyle: CardStyle? = null,
234241
) {
235242
BitwardenPasswordField(
@@ -257,6 +264,7 @@ fun BitwardenPasswordField(
257264
imeAction = imeAction,
258265
keyboardActions = keyboardActions,
259266
textToolbarType = textToolbarType,
267+
passwordFieldTestTag = passwordFieldTestTag,
260268
cardStyle = cardStyle,
261269
)
262270
}
@@ -285,6 +293,7 @@ fun BitwardenPasswordField(
285293
* @param imeAction the preferred IME action for the keyboard to have.
286294
* @param keyboardActions the callbacks of keyboard actions.
287295
* @param textToolbarType The type of [TextToolbar] to use on the text field.
296+
* @param passwordFieldTestTag The optional test tag associated with the inner password field.
288297
* @param cardStyle Indicates the type of card style to be applied.
289298
*/
290299
@Composable
@@ -303,6 +312,7 @@ fun BitwardenPasswordField(
303312
imeAction: ImeAction = ImeAction.Default,
304313
keyboardActions: KeyboardActions = KeyboardActions.Default,
305314
textToolbarType: TextToolbarType = TextToolbarType.DEFAULT,
315+
passwordFieldTestTag: String? = null,
306316
cardStyle: CardStyle? = null,
307317
) {
308318
var showPassword by rememberSaveable { mutableStateOf(value = initialShowPassword) }
@@ -322,6 +332,7 @@ fun BitwardenPasswordField(
322332
imeAction = imeAction,
323333
keyboardActions = keyboardActions,
324334
textToolbarType = textToolbarType,
335+
passwordFieldTestTag = passwordFieldTestTag,
325336
cardStyle = cardStyle,
326337
)
327338
}
@@ -347,6 +358,7 @@ fun BitwardenPasswordField(
347358
* the password field.
348359
* @param imeAction the preferred IME action for the keyboard to have.
349360
* @param keyboardActions the callbacks of keyboard actions.
361+
* @param textFieldTestTag The optional test tag associated with the inner text field.
350362
* @param cardStyle Indicates the type of card style to be applied.
351363
*/
352364
@Composable
@@ -364,6 +376,7 @@ fun BitwardenPasswordField(
364376
keyboardType: KeyboardType = KeyboardType.Password,
365377
imeAction: ImeAction = ImeAction.Default,
366378
keyboardActions: KeyboardActions = KeyboardActions.Default,
379+
textFieldTestTag: String? = null,
367380
cardStyle: CardStyle? = null,
368381
) {
369382
var showPassword by rememberSaveable { mutableStateOf(initialShowPassword) }
@@ -382,6 +395,7 @@ fun BitwardenPasswordField(
382395
keyboardType = keyboardType,
383396
imeAction = imeAction,
384397
keyboardActions = keyboardActions,
398+
passwordFieldTestTag = textFieldTestTag,
385399
cardStyle = cardStyle,
386400
)
387401
}

app/src/main/java/com/x8bit/bitwarden/ui/platform/components/field/BitwardenPasswordFieldWithActions.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import androidx.compose.ui.Alignment
2020
import androidx.compose.ui.Modifier
2121
import androidx.compose.ui.platform.TextToolbar
2222
import androidx.compose.ui.semantics.semantics
23-
import androidx.compose.ui.semantics.testTag
2423
import androidx.compose.ui.tooling.preview.Preview
2524
import androidx.compose.ui.unit.dp
2625
import com.x8bit.bitwarden.R
@@ -95,10 +94,9 @@ fun BitwardenPasswordFieldWithActions(
9594
readOnly = readOnly,
9695
singleLine = singleLine,
9796
showPasswordTestTag = showPasswordTestTag,
97+
passwordFieldTestTag = passwordFieldTestTag,
9898
textToolbarType = textToolbarType,
99-
modifier = Modifier
100-
.semantics { passwordFieldTestTag?.let { testTag = it } }
101-
.weight(weight = 1f),
99+
modifier = Modifier.weight(weight = 1f),
102100
)
103101
BitwardenRowOfActions(
104102
modifier = Modifier.padding(paddingValues = actionsPadding),

app/src/main/java/com/x8bit/bitwarden/ui/platform/components/field/BitwardenTextField.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import kotlinx.collections.immutable.toImmutableList
7878
* @param visualTransformation Transforms the visual representation of the input [value].
7979
* @param keyboardType the preferred type of keyboard input.
8080
* @param textToolbarType The type of [TextToolbar] to use on the text field.
81+
* @param textFieldTestTag The optional test tag associated with the inner text field.
8182
* @param cardStyle Indicates the type of card style to be applied.
8283
*/
8384
@Composable
@@ -161,6 +162,7 @@ fun BitwardenTextField(
161162
* @param visualTransformation Transforms the visual representation of the input [value].
162163
* @param keyboardType the preferred type of keyboard input.
163164
* @param textToolbarType The type of [TextToolbar] to use on the text field.
165+
* @param textFieldTestTag The optional test tag associated with the inner text field.
164166
* @param cardStyle Indicates the type of card style to be applied.
165167
*/
166168
@Suppress("LongMethod", "CyclomaticComplexMethod")

app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/settings/exportvault/ExportVaultScreen.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ private fun ExportVaultScreenContent(
249249
modifier = Modifier.fillMaxWidth(),
250250
)
251251
},
252+
showPasswordTestTag = "FilePasswordEntry",
252253
cardStyle = CardStyle.Full,
253254
modifier = Modifier
254-
.testTag("FilePasswordEntry")
255255
.standardHorizontalMargin()
256256
.fillMaxWidth(),
257257
)
@@ -264,9 +264,9 @@ private fun ExportVaultScreenContent(
264264
onValueChange = onConfirmFilePasswordInputChanged,
265265
showPassword = showPassword,
266266
showPasswordChange = { showPassword = it },
267+
passwordFieldTestTag = "ConfirmFilePasswordEntry",
267268
cardStyle = CardStyle.Full,
268269
modifier = Modifier
269-
.testTag("ConfirmFilePasswordEntry")
270270
.standardHorizontalMargin()
271271
.fillMaxWidth(),
272272
)
@@ -321,9 +321,9 @@ private fun ExportVaultScreenContent(
321321
value = state.passwordInput,
322322
readOnly = state.policyPreventsExport,
323323
onValueChange = onPasswordInputChanged,
324+
textFieldTestTag = "MasterPasswordEntry",
324325
cardStyle = CardStyle.Full,
325326
modifier = Modifier
326-
.testTag("MasterPasswordEntry")
327327
.standardHorizontalMargin()
328328
.fillMaxWidth(),
329329
)

0 commit comments

Comments
 (0)