Skip to content

Commit 2427c86

Browse files
committed
use ancestor testID on TextField for Android EditText matching in change password test
1 parent a78720b commit 2427c86

2 files changed

Lines changed: 11 additions & 23 deletions

File tree

app/components/Views/ResetPassword/index.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -570,16 +570,13 @@ const ResetPassword = ({ navigation, route }: ResetPasswordProps) => {
570570
{strings('manual_backup_step_1.enter_current_password')}
571571
</Label>
572572
<TextField
573+
testID={ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID}
573574
placeholder={strings('password_reset.password_title')}
574575
onChangeText={onPasswordChange}
575576
value={password}
576-
accessibilityLabel={
577-
ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID
578-
}
579577
inputProps={{
580578
secureTextEntry: true,
581579
onSubmitEditing: reauthenticateWithPassword,
582-
testID: ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID,
583580
keyboardAppearance: themeAppearance,
584581
autoComplete: 'password',
585582
}}
@@ -648,16 +645,14 @@ const ResetPassword = ({ navigation, route }: ResetPasswordProps) => {
648645
{strings('reset_password.password')}
649646
</Label>
650647
<TextField
648+
testID={ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID}
651649
value={password}
652650
onChangeText={onPasswordChange}
653651
onFocus={() => setIsPasswordFieldFocused(true)}
654652
onBlur={() => setIsPasswordFieldFocused(false)}
655653
placeholder={strings(
656654
'reset_password.new_password_placeholder',
657655
)}
658-
accessibilityLabel={
659-
ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID
660-
}
661656
isError={isPasswordTooShort()}
662657
endAccessory={
663658
<TouchableOpacity onPress={() => toggleShowPassword(0)}>
@@ -677,7 +672,6 @@ const ResetPassword = ({ navigation, route }: ResetPasswordProps) => {
677672
}
678673
inputProps={{
679674
secureTextEntry: showPasswordIndex.includes(0),
680-
testID: ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID,
681675
onSubmitEditing: jumpToConfirmPassword,
682676
returnKeyType: 'next',
683677
autoComplete: 'password-new',
@@ -698,15 +692,15 @@ const ResetPassword = ({ navigation, route }: ResetPasswordProps) => {
698692
{strings('reset_password.confirm_password')}
699693
</Label>
700694
<TextField
695+
testID={
696+
ChoosePasswordSelectorsIDs.CONFIRM_PASSWORD_INPUT_ID
697+
}
701698
inputRef={confirmPasswordInput}
702699
value={confirmPassword}
703700
onChangeText={setConfirmPassword}
704701
placeholder={strings(
705702
'reset_password.confirm_password_placeholder',
706703
)}
707-
accessibilityLabel={
708-
ChoosePasswordSelectorsIDs.CONFIRM_PASSWORD_INPUT_ID
709-
}
710704
endAccessory={
711705
<TouchableOpacity onPress={() => toggleShowPassword(1)}>
712706
<Icon
@@ -725,8 +719,6 @@ const ResetPassword = ({ navigation, route }: ResetPasswordProps) => {
725719
}
726720
inputProps={{
727721
secureTextEntry: showPasswordIndex.includes(1),
728-
testID:
729-
ChoosePasswordSelectorsIDs.CONFIRM_PASSWORD_INPUT_ID,
730722
returnKeyType: 'done',
731723
autoComplete: 'password-new',
732724
autoCapitalize: 'none',

tests/page-objects/Settings/SecurityAndPrivacy/ChangePasswordView.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,15 @@ class ChangePasswordView {
1212
}
1313

1414
get passwordInput(): DetoxElement {
15-
return device.getPlatform() === 'ios'
16-
? Matchers.getElementByID(
17-
ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID,
18-
)
19-
: Matchers.getElementByLabel(
20-
ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID,
21-
);
15+
return Matchers.getEditTextWithAncestorTestId(
16+
ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID,
17+
);
2218
}
2319

2420
get confirmPasswordInput(): DetoxElement {
25-
return device.getPlatform() === 'ios'
26-
? Matchers.getElementByID(RESET_PASSWORD_CONFIRM_INPUT_BOX_ID)
27-
: Matchers.getElementByLabel(RESET_PASSWORD_CONFIRM_INPUT_BOX_ID);
21+
return Matchers.getEditTextWithAncestorTestId(
22+
RESET_PASSWORD_CONFIRM_INPUT_BOX_ID,
23+
);
2824
}
2925

3026
get iUnderstandCheckBox(): DetoxElement {

0 commit comments

Comments
 (0)