Skip to content

Commit

Permalink
test: Move onboarding testIDs to Selectors folder inside e2e (#7610)
Browse files Browse the repository at this point in the history
## **Description**
Move the testIDs in each page object in the onboarding folder to the
appropriate selectors folder. Relocate testIDs mostly used on the
Onboarding folder from the app/constants/test-ids.js file to the same
selectors folder.

## **Related issues**

Fixes: #7559 

## **Screenshots/Recordings**

Bitrise Smoke test build:
https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/5a99a91a-4c59-474f-9ea1-9aebc58fe869
Wdio test build:
https://app.bitrise.io/build/4c903484-72cc-4c56-a112-4bb4089537cd

- [ ] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've clearly explained what problem this PR is solving and how it
is solved.
- [ ] I've linked related issues
- [ ] I've included manual testing steps
- [ ] I've included screenshots/recordings if applicable
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
- [ ] I’ve properly set the pull request status:
  - [ ] In case it's not yet "ready for review", I've set it to "draft".
- [ ] In case it's "ready for review", I've changed it from "draft" to
"non-draft".

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
SamuelSalas committed Oct 27, 2023
1 parent 6e1035d commit 3022144
Show file tree
Hide file tree
Showing 16 changed files with 110 additions and 154 deletions.
35 changes: 21 additions & 14 deletions app/components/Views/ChoosePassword/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,10 @@ import AUTHENTICATION_TYPE from '../../../constants/userProperties';
import { ThemeContext, mockTheme } from '../../../util/theme';
import AnimatedFox from 'react-native-animated-fox';

import {
CREATE_PASSWORD_CONTAINER_ID,
CREATE_PASSWORD_INPUT_BOX_ID,
CONFIRM_PASSWORD_INPUT_BOX_ID,
IOS_I_UNDERSTAND_BUTTON_ID,
ANDROID_I_UNDERSTAND_BUTTON_ID,
} from '../../../constants/test-ids';
import { LoginOptionsSwitch } from '../../UI/LoginOptionsSwitch';
import generateTestId from '../../../../wdio/utils/generateTestId';
import navigateTermsOfUse from '../../../util/termsOfUse/termsOfUse';
import { ChoosePasswordSelectorsIDs } from '../../../../e2e/selectors/Onboarding/ChoosePassword.selectors';

const createStyles = (colors) =>
StyleSheet.create({
Expand Down Expand Up @@ -634,7 +628,7 @@ class ChoosePassword extends PureComponent {
contentContainerStyle={styles.keyboardScrollableWrapper}
resetScrollToCoords={{ x: 0, y: 0 }}
>
<View testID={CREATE_PASSWORD_CONTAINER_ID}>
<View testID={ChoosePasswordSelectorsIDs.CONTAINER_ID}>
<View style={styles.content}>
<Text variant={TextVariant.HeadingLG} style={styles.title}>
{strings('choose_password.title')}
Expand Down Expand Up @@ -668,7 +662,10 @@ class ChoosePassword extends PureComponent {
secureTextEntry={secureTextEntry}
placeholder=""
placeholderTextColor={colors.text.muted}
{...generateTestId(Platform, CREATE_PASSWORD_INPUT_BOX_ID)}
{...generateTestId(
Platform,
ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID,
)}
onSubmitEditing={this.jumpToConfirmPassword}
returnKeyType="next"
autoCapitalize="none"
Expand Down Expand Up @@ -709,8 +706,12 @@ class ChoosePassword extends PureComponent {
secureTextEntry={secureTextEntry}
placeholder={''}
placeholderTextColor={colors.text.muted}
testID={CONFIRM_PASSWORD_INPUT_BOX_ID}
accessibilityLabel={CONFIRM_PASSWORD_INPUT_BOX_ID}
testID={
ChoosePasswordSelectorsIDs.CONFIRM_PASSWORD_INPUT_ID
}
accessibilityLabel={
ChoosePasswordSelectorsIDs.CONFIRM_PASSWORD_INPUT_ID
}
onSubmitEditing={this.onPressCreate}
returnKeyType={'done'}
autoCapitalize="none"
Expand Down Expand Up @@ -745,14 +746,20 @@ class ChoosePassword extends PureComponent {
false: colors.border.default,
}}
boxType="square"
testID={IOS_I_UNDERSTAND_BUTTON_ID}
accessibilityLabel={IOS_I_UNDERSTAND_BUTTON_ID}
testID={
ChoosePasswordSelectorsIDs.IOS_I_UNDERSTAND_BUTTON_ID
}
accessibilityLabel={
ChoosePasswordSelectorsIDs.IOS_I_UNDERSTAND_BUTTON_ID
}
/>
<Text
style={styles.label}
variant={TextVariant.BodySM}
onPress={this.setSelection}
testID={ANDROID_I_UNDERSTAND_BUTTON_ID}
testID={
ChoosePasswordSelectorsIDs.ANDROID_I_UNDERSTAND_BUTTON_ID
}
>
{strings('choose_password.i_understand')}{' '}
<Text
Expand Down
4 changes: 2 additions & 2 deletions app/components/Views/ImportFromSecretRecoveryPhrase/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ import {
IMPORT_FROM_SEED_SCREEN_PASSWORD_STRENGTH_ID,
IMPORT_FROM_SEED_SCREEN_CONFIRM_PASSWORD_CHECK_ICON_ID,
} from '../../../../wdio/screen-objects/testIDs/Screens/ImportFromSeedScreen.testIds';
import { IMPORT_PASSWORD_CONTAINER_ID } from '../../../constants/test-ids';
import createStyles from './styles';
import { Authentication } from '../../../core';
import AUTHENTICATION_TYPE from '../../../constants/userProperties';
Expand All @@ -73,6 +72,7 @@ import {
updateAuthTypeStorageFlags,
} from '../../../util/authentication';
import navigateTermsOfUse from '../../../util/termsOfUse/termsOfUse';
import { ImportFromSeedSelectorsIDs } from '../../../../e2e/selectors/Onboarding/ImportFromSeed.selectors';

const MINIMUM_SUPPORTED_CLIPBOARD_VERSION = 9;

Expand Down Expand Up @@ -424,7 +424,7 @@ const ImportFromSecretRecoveryPhrase = ({
style={styles.wrapper}
resetScrollToCoords={{ x: 0, y: 0 }}
>
<View testID={IMPORT_PASSWORD_CONTAINER_ID}>
<View testID={ImportFromSeedSelectorsIDs.CONTAINER_ID}>
<Text
style={styles.title}
{...generateTestId(Platform, IMPORT_FROM_SEED_SCREEN_TITLE_ID)}
Expand Down
11 changes: 5 additions & 6 deletions app/components/Views/ResetPassword/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ import { Authentication } from '../../../core';
import AUTHENTICATION_TYPE from '../../../constants/userProperties';
import { ThemeContext, mockTheme } from '../../../util/theme';
import AnimatedFox from 'react-native-animated-fox';
import {
CREATE_PASSWORD_CONTAINER_ID,
IOS_I_UNDERSTAND_BUTTON_ID,
} from '../../../constants/test-ids';
import {
RESET_PASSWORD_INPUT_ID,
RESET_PASSWORD_INPUT_BOX_ID,
Expand All @@ -66,6 +62,7 @@ import { recreateVaultWithNewPassword } from '../../../core/Vault';
import generateTestId from '../../../../wdio/utils/generateTestId';
import Logger from '../../../util/Logger';
import { selectSelectedAddress } from '../../../selectors/preferencesController';
import { ChoosePasswordSelectorsIDs } from '../../../../e2e/selectors/Onboarding/ChoosePassword.selectors';

const createStyles = (colors) =>
StyleSheet.create({
Expand Down Expand Up @@ -647,7 +644,7 @@ class ResetPassword extends PureComponent {
contentContainerStyle={styles.keyboardScrollableWrapper}
resetScrollToCoords={{ x: 0, y: 0 }}
>
<View testID={CREATE_PASSWORD_CONTAINER_ID}>
<View testID={ChoosePasswordSelectorsIDs.CONTAINER_ID}>
<View style={styles.content}>
<Text variant={TextVariant.HeadingLG} style={styles.title}>
{strings('reset_password.title')}
Expand Down Expand Up @@ -753,7 +750,9 @@ class ResetPassword extends PureComponent {
false: colors.border.default,
}}
boxType="square"
testID={IOS_I_UNDERSTAND_BUTTON_ID}
testID={
ChoosePasswordSelectorsIDs.IOS_I_UNDERSTAND_BUTTON_ID
}
/>
<Text
variant={TextVariant.BodyMD}
Expand Down
10 changes: 0 additions & 10 deletions app/constants/test-ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ export const CONNECT_BUTTON_ID = 'connect-approve-button';
export const ADD_ADDRESS_MODAL_CONTAINER_ID = 'add-address-modal';
export const ENTER_ALIAS_INPUT_BOX_ID = 'address-alias-input';

export const CREATE_PASSWORD_INPUT_BOX_ID = 'create-password-first-input-field';
export const CREATE_PASSWORD_CONTAINER_ID = 'create-password-screen';
export const CONFIRM_PASSWORD_INPUT_BOX_ID =
'create-password-second-input-field';

export const CHANGE_PASSWORD_TITLE_ID = 'change-password-section';
export const CHANGE_PASSWORD_BUTTON_ID = 'change-password-button-id';
export const CONFIRM_CHANGE_PASSWORD_INPUT_BOX_ID =
Expand All @@ -33,11 +28,6 @@ export const REVEAL_SECRET_RECOVERY_PHRASE_BUTTON_ID = 'reveal-seed-button';
export const SUBMIT_BUTTON_ID = 'submit-button';
export const BACK_ARROW_BUTTON_ID = 'burger-menu-title-back-arrow-button';

export const IOS_I_UNDERSTAND_BUTTON_ID = 'password-understand-box';
export const ANDROID_I_UNDERSTAND_BUTTON_ID = 'i-understand-text';

export const IMPORT_PASSWORD_CONTAINER_ID = 'import-from-seed-screen';

export const BROWSER_URL_MODAL_ID = 'browser-url-modal';
export const CLEAR_COOKIES_SECTION = 'clear-cookies-section';
export const APPROVE_NETWORK_MODAL_ID = 'approve-network-modal';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import TestHelpers from '../../../../helpers';
import { IOS_I_UNDERSTAND_BUTTON_ID } from '../../../../../app/constants/test-ids';
import {
RESET_PASSWORD_INPUT_ID,
RESET_PASSWORD_INPUT_BOX_ID,
Expand All @@ -9,6 +8,7 @@ import {
} from '../../../../../wdio/screen-objects/testIDs/Screens/ChangePasswordScreensIDs.testIds';

import messages from '../../../../../locales/languages/en.json';
import { ChoosePasswordSelectorsIDs } from '../../../../selectors/Onboarding/ChoosePassword.selectors';

const CHANGE_PASSWORD_TEXT = messages.manual_backup_step_1.confirm_password;
const CONFIRM_BUTTON_TEXT = messages.account_backup_step_4.confirm;
Expand Down Expand Up @@ -41,7 +41,9 @@ export default class ChangePasswordView {

static async tapIUnderstandCheckBox() {
if (device.getPlatform() === 'ios') {
await TestHelpers.tap(IOS_I_UNDERSTAND_BUTTON_ID);
await TestHelpers.tap(
ChoosePasswordSelectorsIDs.IOS_I_UNDERSTAND_BUTTON_ID,
);
} else {
// Tap by the I understand text
await TestHelpers.delay(1000);
Expand Down
39 changes: 14 additions & 25 deletions e2e/pages/Onboarding/CreatePasswordView.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,48 @@
import TestHelpers from '../../helpers';

import {
CREATE_PASSWORD_CONTAINER_ID,
CREATE_PASSWORD_INPUT_BOX_ID,
CONFIRM_PASSWORD_INPUT_BOX_ID,
IOS_I_UNDERSTAND_BUTTON_ID,
ANDROID_I_UNDERSTAND_BUTTON_ID,
} from '../../../app/constants/test-ids';

const CREATE_PASSWORD_BUTTON_ID = 'submit-button';
const REMEMBER_ME_ID = 'remember-me-toggle';
import { ChoosePasswordSelectorsIDs } from '../../selectors/Onboarding/ChoosePassword.selectors';

export default class CreatePasswordView {
static async toggleRememberMe() {
await TestHelpers.tap(REMEMBER_ME_ID);
}

static async enterPassword(password) {
await TestHelpers.typeTextAndHideKeyboard(
CREATE_PASSWORD_INPUT_BOX_ID,
ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID,
password,
);
}

static async reEnterPassword(password) {
await TestHelpers.typeTextAndHideKeyboard(
CONFIRM_PASSWORD_INPUT_BOX_ID,
ChoosePasswordSelectorsIDs.CONFIRM_PASSWORD_INPUT_ID,
password,
);
}

static async tapIUnderstandCheckBox() {
if (device.getPlatform() === 'ios') {
await TestHelpers.tap(IOS_I_UNDERSTAND_BUTTON_ID);
await TestHelpers.tap(
ChoosePasswordSelectorsIDs.IOS_I_UNDERSTAND_BUTTON_ID,
);
} else {
// Tap by the I understand text
await TestHelpers.delay(2000);
await TestHelpers.tap(ANDROID_I_UNDERSTAND_BUTTON_ID);
await TestHelpers.tap(
ChoosePasswordSelectorsIDs.ANDROID_I_UNDERSTAND_BUTTON_ID,
);
}
}

static async tapCreatePasswordButton() {
if (device.getPlatform() === 'ios') {
await TestHelpers.waitAndTap(CREATE_PASSWORD_BUTTON_ID);
await TestHelpers.waitAndTap(ChoosePasswordSelectorsIDs.SUBMIT_BUTTON_ID);
} else {
await TestHelpers.waitAndTapByLabel(CREATE_PASSWORD_BUTTON_ID);
await TestHelpers.waitAndTapByLabel(
ChoosePasswordSelectorsIDs.SUBMIT_BUTTON_ID,
);
}
}

// Assertions
static async isVisible() {
await TestHelpers.checkIfVisible(CREATE_PASSWORD_CONTAINER_ID);
}

static async isNotVisible() {
await TestHelpers.checkIfNotVisible(CREATE_PASSWORD_CONTAINER_ID);
await TestHelpers.checkIfVisible(ChoosePasswordSelectorsIDs.CONTAINER_ID);
}
}
56 changes: 5 additions & 51 deletions e2e/pages/Onboarding/ImportWalletView.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,24 @@
import TestHelpers from '../../helpers';
import messages from '../../../locales/languages/en.json';

import {
CREATE_PASSWORD_INPUT_BOX_ID,
CONFIRM_PASSWORD_INPUT_BOX_ID,
IOS_I_UNDERSTAND_BUTTON_ID,
ANDROID_I_UNDERSTAND_BUTTON_ID,
IMPORT_PASSWORD_CONTAINER_ID,
} from '../../../app/constants/test-ids';
import { IMPORT_FROM_SEED_SCREEN_SEED_PHRASE_INPUT_ID } from '../../../wdio/screen-objects/testIDs/Screens/ImportFromSeedScreen.testIds';

const REMEMBER_ME_ID = 'remember-me-toggle';
const CREATE_PASSWORD_BUTTON_ID = 'submit-button';

const Incorrect_Password_Length =
messages.import_from_seed.password_length_error;
const Invalid_Seed_Error = messages.import_from_seed.invalid_seed_phrase;
import { ChoosePasswordSelectorsIDs } from '../../selectors/Onboarding/ChoosePassword.selectors';
import { ImportFromSeedSelectorsIDs } from '../../selectors/Onboarding/ImportFromSeed.selectors';

export default class ImportWalletView {
static async enterPassword(password) {
await TestHelpers.typeTextAndHideKeyboard(
CREATE_PASSWORD_INPUT_BOX_ID,
ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID,
password,
);
}

static async reEnterPassword(password) {
await TestHelpers.typeTextAndHideKeyboard(
CONFIRM_PASSWORD_INPUT_BOX_ID,
ChoosePasswordSelectorsIDs.CONFIRM_PASSWORD_INPUT_ID,
password,
);
}

static async tapIUnderstandCheckBox() {
if (device.getPlatform() === 'ios') {
await TestHelpers.tap(IOS_I_UNDERSTAND_BUTTON_ID);
} else {
// Tap by the I understand text
await TestHelpers.delay(1000);
await TestHelpers.tap(ANDROID_I_UNDERSTAND_BUTTON_ID);
}
}

static async tapCreatePasswordButton() {
await TestHelpers.tap(CREATE_PASSWORD_BUTTON_ID);
}

static async tapOKAlertButton() {
await TestHelpers.tapAlertWithButton('OK');
}

static async enterSecretRecoveryPhrase(secretRecoveryPhrase) {
if (device.getPlatform() === 'android') {
await TestHelpers.replaceTextInField(
Expand All @@ -70,23 +39,8 @@ export default class ImportWalletView {
await TestHelpers.clearField(IMPORT_FROM_SEED_SCREEN_SEED_PHRASE_INPUT_ID);
}

static async toggleRememberMe() {
await TestHelpers.tap(REMEMBER_ME_ID);
}

// Assertions
static async isVisible() {
await TestHelpers.checkIfVisible(IMPORT_PASSWORD_CONTAINER_ID);
}

static async isNotVisible() {
await TestHelpers.checkIfNotVisible(IMPORT_PASSWORD_CONTAINER_ID);
}

static async secretRecoveryPhraseErrorIsVisible() {
await TestHelpers.checkIfElementByTextIsVisible(Invalid_Seed_Error);
}
static async passwordLengthErrorIsVisible() {
await TestHelpers.checkIfElementByTextIsVisible(Incorrect_Password_Length);
await TestHelpers.checkIfVisible(ImportFromSeedSelectorsIDs.CONTAINER_ID);
}
}

0 comments on commit 3022144

Please sign in to comment.