-
Notifications
You must be signed in to change notification settings - Fork 476
Expand file tree
/
Copy pathonboardingSteps.page.ts
More file actions
144 lines (129 loc) · 5.61 KB
/
Copy pathonboardingSteps.page.ts
File metadata and controls
144 lines (129 loc) · 5.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import { Step } from "jest-allure2-reporter/api";
import { isIos } from "../../helpers/commonHelpers";
export default class OnboardingStepsPage {
getStartedButtonId = "onboarding-getStarted-button";
acceptAnalyticsButtonId = "enabled-accept-analytics-button";
exploreWithoutDeviceButtonId = "discoverLive-exploreWithoutADevice";
recoveryPhrase = "onboarding-useCase-recoveryPhrase";
setupLedger = "onboarding-setupLedger";
accessWallet = "onboarding-accessWallet";
currentSelectedLanguageId = "current-selected-language";
languageSelectButtonId = "language-select-button";
languageSelectDrawerTitleId = "language-select-drawer-title";
deviceCardBaseId = "onboarding-device-selection";
scrollListContainerId = "onboarding-view-scroll-list-container";
welcomeProgressBarId = "welcome-progress-bar";
languageSelectElementId = (language: string) => `language-select-${language}`;
deviceCardId = (title: string) => `${this.deviceCardBaseId}-${title}`;
deviceCardTitleId = (title: string) => `${this.deviceCardId(title)}-title`;
discoverLiveTitle = (index: number) => `onboarding-discoverLive-${index}-title`;
onboardingGetStartedButton = () => getElementById(this.getStartedButtonId);
acceptAnalyticsButton = () => getElementById(this.acceptAnalyticsButtonId);
noLedgerYetButton = () => getElementById("onboarding-noLedgerYet");
setupLedgerButton = () => getElementById(this.setupLedger);
accessWalletButton = () => getElementById(this.accessWallet);
deviceCardHeader = (title: string) => getElementById(`${this.deviceCardId(title)}-header`);
deviceCardText = (title: string) => getElementById(`${this.deviceCardId(title)}-text`);
deviceCardImage = (title: string) => getElementById(`${this.deviceCardId(title)}-image`);
@Step("Wait for onboarding to load")
async waitForOnboardingToLoad(): Promise<void> {
await waitForElementById(this.getStartedButtonId);
}
@Step("Expect 3 progress bars to be visible")
async expectProgressBarToBeVisible(): Promise<void> {
for (let i = 0; i < 3; i++) {
await detoxExpect(getElementById(this.welcomeProgressBarId, i)).toBeVisible();
}
}
@Step("Tap on Get Started button")
async tapOnGetStartedButton(): Promise<void> {
await tapById(this.getStartedButtonId);
}
@Step("Expect 'Get Started' button to be visible")
async expectGetStartedButtonToBeVisible(): Promise<void> {
await detoxExpect(this.onboardingGetStartedButton()).toBeVisible();
}
@Step("Expect current selected language")
async expectCurrentSelectedLanguageToBe(language: string): Promise<void> {
const text = await getTextOfElement(this.currentSelectedLanguageId);
jestExpect(text).toContain(language);
}
@Step("Select language")
async selectLanguage(language: string): Promise<void> {
await tapById(this.languageSelectButtonId);
await waitForElementById(this.languageSelectDrawerTitleId);
await tapById(this.languageSelectElementId(language.toLowerCase()));
}
@Step("Select starting option")
async selectStartingOption(
option: "setupLedger" | "accessWallet" | "noLedgerYet",
): Promise<void> {
switch (option) {
case "setupLedger":
await tapByElement(this.setupLedgerButton());
break;
case "accessWallet":
await tapByElement(this.accessWalletButton());
break;
case "noLedgerYet":
await tapByElement(this.noLedgerYetButton());
break;
}
}
@Step("Check device cards")
async checkDeviceCards(): Promise<void> {
const devices = [
{ id: "stax", name: "Stax" },
{ id: "europa", name: "Flex" },
{ id: "nanoX", name: "Nano X" },
{ id: "nanoSP", name: "Nano S Plus" },
{ id: "nanoS", name: "Nano S" },
];
for (const device of devices) {
if (device.id === "nanoS" || device.id === "nanoSP") {
await scrollToId(this.deviceCardId(device.id), this.scrollListContainerId, 100, "down");
}
await detoxExpect(getElementById(this.deviceCardId(device.id))).toBeVisible();
await detoxExpect(this.deviceCardHeader(device.id)).toHaveText("Ledger");
const titleId = await getTextOfElement(this.deviceCardTitleId(device.id));
const normalizedTitle = titleId
.replace(/\s+/g, " ")
.replace(/\u200B/g, "")
.trim();
jestExpect(normalizedTitle).toBe(device.name);
await detoxExpect(this.deviceCardImage(device.id)).toBeVisible();
if (isIos() && (device.name === "Nano S" || device.name === "Nano S Plus")) {
await detoxExpect(this.deviceCardText(device.id)).toHaveText("No iPhone compatibility");
}
}
}
@Step("Start onboarding")
async startOnboarding(): Promise<void> {
await waitForElementById(this.getStartedButtonId);
const getStarted = this.onboardingGetStartedButton();
await tapByElement(getStarted);
await waitForElementById(new RegExp(`${this.setupLedger}|${this.acceptAnalyticsButtonId}`));
try {
await this.acceptAnalytics();
} catch {
// Analytics prompt not enabled
}
}
@Step("Accept analytics")
async acceptAnalytics(): Promise<void> {
const analyticsBtn = this.acceptAnalyticsButton();
await tapByElement(analyticsBtn);
}
@Step("Choose no ledger yet")
async chooseNoLedgerYet(): Promise<void> {
const btn = this.noLedgerYetButton();
await tapByElement(btn);
}
@Step("Choose to explore app")
async chooseToExploreApp(): Promise<void> {
// DETOX: chooseNoLedgerYet navigates straight to discover live (no upsell modal).
await waitForElementById(this.discoverLiveTitle(3));
await waitForElementById(this.exploreWithoutDeviceButtonId);
await tapById(this.exploreWithoutDeviceButtonId);
}
}