Skip to content

Commit da222bd

Browse files
hieu-wieowhuggingbotchaitanyapotti
authored
test: e2e fix for seedless oauth flow cp-7.52.0 (#16782)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This PR fix e2e and performance test for #15883 <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Related issues** Fixes: + Update testId for Onboarding flow button + Add OnboardingSheet to flows + Update test utilities use in other module ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] 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)). Not required for external contributors. ## **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. --------- Co-authored-by: ieow <cwlee0@gmail.com> Co-authored-by: huggingbot <83656073+huggingbot@users.noreply.github.com> Co-authored-by: Chaitanya Potti <chaitanya.potti@gmail.com>
1 parent 0b4dd90 commit da222bd

File tree

17 files changed

+189
-52
lines changed

17 files changed

+189
-52
lines changed

app/components/Views/Onboarding/__snapshots__/index.test.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ exports[`Onboarding should render correctly 1`] = `
190190
"paddingHorizontal": 16,
191191
}
192192
}
193-
testID="wallet-setup-screen-import-from-seed-button-id"
193+
testID="wallet-setup-screen-have-an-existing-wallet-button-id"
194194
>
195195
<Text
196196
accessibilityRole="text"
@@ -422,7 +422,7 @@ exports[`Onboarding should render correctly with android 1`] = `
422422
"paddingHorizontal": 16,
423423
}
424424
}
425-
testID="wallet-setup-screen-import-from-seed-button-id"
425+
testID="wallet-setup-screen-have-an-existing-wallet-button-id"
426426
>
427427
<Text
428428
accessibilityRole="text"
@@ -653,7 +653,7 @@ exports[`Onboarding should render correctly with large device and iphoneX 1`] =
653653
"paddingHorizontal": 16,
654654
}
655655
}
656-
testID="wallet-setup-screen-import-from-seed-button-id"
656+
testID="wallet-setup-screen-have-an-existing-wallet-button-id"
657657
>
658658
<Text
659659
accessibilityRole="text"
@@ -883,7 +883,7 @@ exports[`Onboarding should render correctly with medium device and android 1`] =
883883
"paddingHorizontal": 16,
884884
}
885885
}
886-
testID="wallet-setup-screen-import-from-seed-button-id"
886+
testID="wallet-setup-screen-have-an-existing-wallet-button-id"
887887
>
888888
<Text
889889
accessibilityRole="text"

app/components/Views/Onboarding/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ class Onboarding extends PureComponent {
694694
<Button
695695
variant={ButtonVariants.Secondary}
696696
onPress={() => this.handleCtaActions('existing')}
697-
testID={OnboardingSelectorIDs.IMPORT_SEED_BUTTON}
697+
testID={OnboardingSelectorIDs.EXISTING_WALLET_BUTTON}
698698
width={ButtonWidthTypes.Full}
699699
size={Device.isMediumDevice() ? ButtonSize.Md : ButtonSize.Lg}
700700
label={

app/components/Views/Onboarding/index.test.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ describe('Onboarding', () => {
277277
fireEvent.press(createWalletButton);
278278
});
279279

280-
it('should click on import seed button', () => {
280+
it('should click on have an existing wallet button', () => {
281281
(Device.isAndroid as jest.Mock).mockReturnValue(true);
282282
(Device.isIos as jest.Mock).mockReturnValue(false);
283283
(Device.isLargeDevice as jest.Mock).mockReturnValue(false);
@@ -292,7 +292,7 @@ describe('Onboarding', () => {
292292
);
293293

294294
const importSeedButton = getByTestId(
295-
OnboardingSelectorIDs.IMPORT_SEED_BUTTON,
295+
OnboardingSelectorIDs.EXISTING_WALLET_BUTTON,
296296
);
297297
fireEvent.press(importSeedButton);
298298
});
@@ -374,8 +374,7 @@ describe('Onboarding', () => {
374374
afterEach(() => {
375375
mockSeedlessOnboardingEnabled.mockReset();
376376
});
377-
378-
it('should navigate to onboarding sheet when import wallet is pressed for new user', async () => {
377+
it('should navigate to onboarding sheet when have an existing wallet button is pressed for new user', async () => {
379378
mockSeedlessOnboardingEnabled.mockReturnValue(true);
380379
(StorageWrapper.getItem as jest.Mock).mockResolvedValue(null);
381380

@@ -388,7 +387,7 @@ describe('Onboarding', () => {
388387
);
389388

390389
const importSeedButton = getByTestId(
391-
OnboardingSelectorIDs.IMPORT_SEED_BUTTON,
390+
OnboardingSelectorIDs.EXISTING_WALLET_BUTTON,
392391
);
393392

394393
await act(async () => {
@@ -421,7 +420,7 @@ describe('Onboarding', () => {
421420
);
422421

423422
const importSeedButton = getByTestId(
424-
OnboardingSelectorIDs.IMPORT_SEED_BUTTON,
423+
OnboardingSelectorIDs.EXISTING_WALLET_BUTTON,
425424
);
426425

427426
await act(async () => {
@@ -650,7 +649,7 @@ describe('Onboarding', () => {
650649
);
651650

652651
const importSeedButton = getByTestId(
653-
OnboardingSelectorIDs.IMPORT_SEED_BUTTON,
652+
OnboardingSelectorIDs.EXISTING_WALLET_BUTTON,
654653
);
655654
await act(async () => {
656655
fireEvent.press(importSeedButton);
@@ -743,7 +742,7 @@ describe('Onboarding', () => {
743742
);
744743

745744
const importSeedButton = getByTestId(
746-
OnboardingSelectorIDs.IMPORT_SEED_BUTTON,
745+
OnboardingSelectorIDs.EXISTING_WALLET_BUTTON,
747746
);
748747
await act(async () => {
749748
fireEvent.press(importSeedButton);
@@ -838,7 +837,7 @@ describe('Onboarding', () => {
838837
);
839838

840839
const importSeedButton = getByTestId(
841-
OnboardingSelectorIDs.IMPORT_SEED_BUTTON,
840+
OnboardingSelectorIDs.EXISTING_WALLET_BUTTON,
842841
);
843842
await act(async () => {
844843
fireEvent.press(importSeedButton);
@@ -904,7 +903,7 @@ describe('Onboarding', () => {
904903
);
905904

906905
const importSeedButton = getByTestId(
907-
OnboardingSelectorIDs.IMPORT_SEED_BUTTON,
906+
OnboardingSelectorIDs.EXISTING_WALLET_BUTTON,
908907
);
909908
await act(async () => {
910909
fireEvent.press(importSeedButton);
@@ -954,7 +953,7 @@ describe('Onboarding', () => {
954953
);
955954

956955
const importSeedButton = getByTestId(
957-
OnboardingSelectorIDs.IMPORT_SEED_BUTTON,
956+
OnboardingSelectorIDs.EXISTING_WALLET_BUTTON,
958957
);
959958
await act(async () => {
960959
fireEvent.press(importSeedButton);

app/components/Views/OnboardingSheet/__snapshots__/index.test.tsx.snap

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ exports[`OnboardingSheet Snapshots renders correctly with createWallet=false (im
128128
"rowGap": 16,
129129
}
130130
}
131+
testID="onboarding-sheet"
131132
>
132133
<Text
133134
accessibilityRole="text"
@@ -176,7 +177,7 @@ exports[`OnboardingSheet Snapshots renders correctly with createWallet=false (im
176177
"paddingHorizontal": 16,
177178
}
178179
}
179-
testID="wallet-setup-screen-create-new-wallet-button-id"
180+
testID="onboarding-sheet-google-login-button-id"
180181
>
181182
<View
182183
style={
@@ -232,7 +233,7 @@ exports[`OnboardingSheet Snapshots renders correctly with createWallet=false (im
232233
"paddingHorizontal": 16,
233234
}
234235
}
235-
testID="wallet-setup-screen-import-from-seed-button-id"
236+
testID="onboarding-sheet-apple-login-button-id"
236237
>
237238
<View
238239
style={
@@ -341,7 +342,7 @@ exports[`OnboardingSheet Snapshots renders correctly with createWallet=false (im
341342
"paddingHorizontal": 16,
342343
}
343344
}
344-
testID="wallet-setup-screen-import-from-seed-button-id"
345+
testID="onboarding-sheet-import-seed-button-id"
345346
>
346347
<Text
347348
accessibilityRole="text"
@@ -493,6 +494,7 @@ exports[`OnboardingSheet Snapshots renders correctly with createWallet=true (cre
493494
"rowGap": 16,
494495
}
495496
}
497+
testID="onboarding-sheet"
496498
>
497499
<Text
498500
accessibilityRole="text"
@@ -541,7 +543,7 @@ exports[`OnboardingSheet Snapshots renders correctly with createWallet=true (cre
541543
"paddingHorizontal": 16,
542544
}
543545
}
544-
testID="wallet-setup-screen-create-new-wallet-button-id"
546+
testID="onboarding-sheet-google-login-button-id"
545547
>
546548
<View
547549
style={
@@ -597,7 +599,7 @@ exports[`OnboardingSheet Snapshots renders correctly with createWallet=true (cre
597599
"paddingHorizontal": 16,
598600
}
599601
}
600-
testID="wallet-setup-screen-import-from-seed-button-id"
602+
testID="onboarding-sheet-apple-login-button-id"
601603
>
602604
<View
603605
style={
@@ -706,7 +708,7 @@ exports[`OnboardingSheet Snapshots renders correctly with createWallet=true (cre
706708
"paddingHorizontal": 16,
707709
}
708710
}
709-
testID="wallet-setup-screen-import-from-seed-button-id"
711+
testID="onboarding-sheet-import-seed-button-id"
710712
>
711713
<Text
712714
accessibilityRole="text"

app/components/Views/OnboardingSheet/index.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import Text, {
1414
} from '../../../component-library/components/Texts/Text';
1515
import { strings } from '../../../../locales/i18n';
1616
import { useTheme } from '../../../util/theme';
17-
import { OnboardingSelectorIDs } from '../../../../e2e/selectors/Onboarding/Onboarding.selectors';
1817
import { AppThemeKey, Colors } from '../../../util/theme/models';
1918
import GoogleIcon from 'images/google.svg';
2019
import AppleIcon from 'images/apple.svg';
2120
import AppleWhiteIcon from 'images/apple-white.svg';
21+
import { OnboardingSheetSelectorIDs } from '../../../../e2e/selectors/Onboarding/OnboardingSheet.selectors';
2222

2323
export interface OnboardingSheetParams {
2424
onPressCreate?: () => void;
@@ -114,15 +114,18 @@ const OnboardingSheet = (props: OnboardingSheetProps) => {
114114

115115
return (
116116
<BottomSheet ref={sheetRef}>
117-
<View style={styles.bottomSheetContainer}>
117+
<View
118+
style={styles.bottomSheetContainer}
119+
testID={OnboardingSheetSelectorIDs.CONTAINER_ID}
120+
>
118121
<Text variant={TextVariant.HeadingMD} color={TextColor.Default}>
119122
{strings('onboarding.bottom_sheet_title')}
120123
</Text>
121124
<View style={styles.buttonWrapper}>
122125
<Button
123126
variant={ButtonVariants.Secondary}
124127
onPress={onPressContinueWithGoogleAction}
125-
testID={OnboardingSelectorIDs.NEW_WALLET_BUTTON}
128+
testID={OnboardingSheetSelectorIDs.GOOGLE_LOGIN_BUTTON}
126129
label={
127130
<View style={styles.buttonLabel}>
128131
<GoogleIcon
@@ -148,7 +151,7 @@ const OnboardingSheet = (props: OnboardingSheetProps) => {
148151
<Button
149152
variant={ButtonVariants.Secondary}
150153
onPress={onPressContinueWithAppleAction}
151-
testID={OnboardingSelectorIDs.IMPORT_SEED_BUTTON}
154+
testID={OnboardingSheetSelectorIDs.APPLE_LOGIN_BUTTON}
152155
label={
153156
<View style={styles.buttonLabel}>
154157
{isDark ? (
@@ -192,7 +195,7 @@ const OnboardingSheet = (props: OnboardingSheetProps) => {
192195
<Button
193196
variant={ButtonVariants.Secondary}
194197
onPress={createWallet ? onPressCreateAction : onPressImportAction}
195-
testID={OnboardingSelectorIDs.IMPORT_SEED_BUTTON}
198+
testID={OnboardingSheetSelectorIDs.IMPORT_SEED_BUTTON}
196199
label={
197200
createWallet
198201
? strings('onboarding.continue_with_srp')
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import Matchers from '../../utils/Matchers';
2+
import Gestures from '../../utils/Gestures';
3+
import { OnboardingSheetSelectorIDs } from '../../selectors/Onboarding/OnboardingSheet.selectors';
4+
5+
class OnboardingSheet {
6+
get container() {
7+
return Matchers.getElementByID(OnboardingSheetSelectorIDs.CONTAINER_ID);
8+
}
9+
10+
get googleLoginButton() {
11+
return Matchers.getElementByID(
12+
OnboardingSheetSelectorIDs.GOOGLE_LOGIN_BUTTON,
13+
);
14+
}
15+
16+
get appleLoginButton() {
17+
return Matchers.getElementByID(
18+
OnboardingSheetSelectorIDs.APPLE_LOGIN_BUTTON,
19+
);
20+
}
21+
22+
get importSeedButton() {
23+
return Matchers.getElementByID(
24+
OnboardingSheetSelectorIDs.IMPORT_SEED_BUTTON,
25+
);
26+
}
27+
28+
async tapGoogleLoginButton() {
29+
await Gestures.waitAndTap(this.googleLoginButton);
30+
}
31+
32+
async tapAppleLoginButton() {
33+
await Gestures.waitAndTap(this.appleLoginButton);
34+
}
35+
36+
async tapImportSeedButton() {
37+
await Gestures.waitAndTap(this.importSeedButton);
38+
}
39+
}
40+
41+
export default new OnboardingSheet();

e2e/pages/Onboarding/OnboardingView.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ class OnboardingView {
77
return Matchers.getElementByID(OnboardingSelectorIDs.CONTAINER_ID);
88
}
99

10-
get importSeedButton(): DetoxElement {
11-
return Matchers.getElementByID(OnboardingSelectorIDs.IMPORT_SEED_BUTTON);
10+
get existingWalletButton() {
11+
return Matchers.getElementByID(
12+
OnboardingSelectorIDs.EXISTING_WALLET_BUTTON,
13+
);
1214
}
1315

1416
get newWalletButton(): DetoxElement {
@@ -19,9 +21,9 @@ class OnboardingView {
1921
await Gestures.waitAndTap(this.newWalletButton);
2022
}
2123

22-
async tapImportWalletFromSeedPhrase(): Promise<void> {
23-
await Gestures.waitAndTap(this.importSeedButton, {
24-
elemDescription: 'Onboarding Import Seed Phrase Button',
24+
async tapHaveAnExistingWallet() {
25+
await Gestures.waitAndTap(this.existingWalletButton, {
26+
elemDescription: 'Onboarding Have an Existing Wallet Button',
2527
});
2628
}
2729
}

e2e/selectors/Onboarding/Onboarding.selectors.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import enContent from '../../../locales/languages/en.json';
22

33
export const OnboardingSelectorIDs = {
44
CONTAINER_ID: 'onboarding-screen',
5-
IMPORT_SEED_BUTTON: 'wallet-setup-screen-import-from-seed-button-id',
65
NEW_WALLET_BUTTON: 'wallet-setup-screen-create-new-wallet-button-id',
6+
EXISTING_WALLET_BUTTON:
7+
'wallet-setup-screen-have-an-existing-wallet-button-id',
78
SCREEN_TITLE: 'wallet-setup-screen-title-id',
89
SCREEN_DESCRIPTION: 'wallet-setup-screen-description-id',
910
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const OnboardingSheetSelectorIDs = {
2+
CONTAINER_ID: 'onboarding-sheet',
3+
GOOGLE_LOGIN_BUTTON: 'onboarding-sheet-google-login-button-id',
4+
APPLE_LOGIN_BUTTON: 'onboarding-sheet-apple-login-button-id',
5+
IMPORT_SEED_BUTTON: 'onboarding-sheet-import-seed-button-id',
6+
};

e2e/specs/quarantine/permission-system-delete-wallet.failing.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import ProtectYourWalletModal from '../../pages/Onboarding/ProtectYourWalletModa
2121
import OnboardingSuccessView from '../../pages/Onboarding/OnboardingSuccessView';
2222
import Assertions from '../../utils/Assertions';
2323
import ToastModal from '../../pages/wallet/ToastModal';
24+
import OnboardingSheet from '../../pages/Onboarding/OnboardingSheet';
25+
const SEEDLESS_ONBOARDING_ENABLED =
26+
process.env.SEEDLESS_ONBOARDING_ENABLED === 'true';
2427

2528
const PASSWORD = '12345678';
2629

@@ -76,6 +79,10 @@ describe(Regression('Permission System'), () => {
7679
await TestHelpers.delay(3000);
7780
}
7881
await OnboardingView.tapCreateWallet();
82+
if (SEEDLESS_ONBOARDING_ENABLED) {
83+
await Assertions.checkIfVisible(OnboardingSheet.container);
84+
await OnboardingSheet.tapImportSeedButton();
85+
}
7986

8087
// Create new wallet
8188
await Assertions.checkIfVisible(MetaMetricsOptIn.container);

0 commit comments

Comments
 (0)