-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathCreatePasswordView.ts
More file actions
148 lines (134 loc) · 4.51 KB
/
CreatePasswordView.ts
File metadata and controls
148 lines (134 loc) · 4.51 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
145
146
147
148
import { ChoosePasswordSelectorsIDs } from '../../../app/components/Views/ChoosePassword/ChoosePassword.testIds';
import {
CREATE_PASSWORD_INPUT_FIRST_FIELD,
CONFIRM_PASSWORD_INPUT_FIRST_FIELD,
} from '../../../wdio/screen-objects/testIDs/Screens/WalletSetupScreen.testIds';
import Matchers from '../../framework/Matchers';
import Gestures from '../../framework/Gestures';
import UnifiedGestures from '../../framework/UnifiedGestures';
import {
encapsulated,
EncapsulatedElementType,
asPlaywrightElement,
asDetoxElement,
} from '../../framework/EncapsulatedElement';
import { encapsulatedAction } from '../../framework/encapsulatedAction';
import PlaywrightMatchers from '../../framework/PlaywrightMatchers';
import { getDriver } from '../../framework/PlaywrightUtilities';
import enContent from '../../../locales/languages/en.json';
import PlaywrightGestures from '../../framework/PlaywrightGestures';
class CreatePasswordView {
get container(): DetoxElement {
return Matchers.getElementByID(ChoosePasswordSelectorsIDs.CONTAINER_ID);
}
get newPasswordInput(): EncapsulatedElementType {
return encapsulated({
detox: () =>
Matchers.getElementByID(
ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID,
),
appium: {
android: () =>
PlaywrightMatchers.getElementById(CREATE_PASSWORD_INPUT_FIRST_FIELD),
ios: () =>
PlaywrightMatchers.getElementByXPath(
'(//XCUIElementTypeOther[@name="textfield"])[1]',
),
},
});
}
get confirmPasswordInput(): EncapsulatedElementType {
return encapsulated({
detox: () =>
Matchers.getElementByID(
ChoosePasswordSelectorsIDs.CONFIRM_PASSWORD_INPUT_ID,
),
appium: {
android: () =>
PlaywrightMatchers.getElementById(CONFIRM_PASSWORD_INPUT_FIRST_FIELD),
ios: () =>
PlaywrightMatchers.getElementByXPath(
'(//XCUIElementTypeOther[@name="textfield"])[2]',
),
},
});
}
get iUnderstandCheckbox(): EncapsulatedElementType {
return encapsulated({
detox: () =>
Matchers.getElementByID(
ChoosePasswordSelectorsIDs.I_UNDERSTAND_CHECKBOX_ID,
),
appium: () =>
PlaywrightMatchers.getElementById(
ChoosePasswordSelectorsIDs.I_UNDERSTAND_CHECKBOX_ID,
),
});
}
get iUnderstandCheckboxNewWallet(): DetoxElement {
return Matchers.getElementByID(
ChoosePasswordSelectorsIDs.I_UNDERSTAND_CHECKBOX_ID,
);
}
get submitButton(): EncapsulatedElementType {
return encapsulated({
detox: () =>
Matchers.getElementByID(ChoosePasswordSelectorsIDs.SUBMIT_BUTTON_ID),
appium: () =>
PlaywrightMatchers.getElementById(
ChoosePasswordSelectorsIDs.SUBMIT_BUTTON_ID,
),
});
}
get passwordError(): DetoxElement {
return Matchers.getElementByText(enContent.import_from_seed.password_error);
}
async resetPasswordInputs(): Promise<void> {
await Gestures.typeText(this.newPasswordInput as DetoxElement, '', {
hideKeyboard: true,
});
await Gestures.typeText(this.confirmPasswordInput as DetoxElement, '', {
hideKeyboard: true,
});
}
async enterPassword(password: string): Promise<void> {
await UnifiedGestures.typeText(this.newPasswordInput, password, {
description: 'Create Password New Password Input',
});
}
async reEnterPassword(password: string): Promise<void> {
await UnifiedGestures.typeText(this.confirmPasswordInput, password, {
description: 'Create Password Confirm Password Input',
});
}
async tapIUnderstandCheckBox(): Promise<void> {
await encapsulatedAction({
detox: async () => {
await Gestures.tap(asDetoxElement(this.iUnderstandCheckbox), {
elemDescription: 'Create Password - I Understand Checkbox',
});
},
appium: async () => {
const drv = getDriver();
await drv.hideKeyboard();
await PlaywrightGestures.tap(
await asPlaywrightElement(this.iUnderstandCheckbox),
);
},
});
}
async tapCreatePasswordButton(): Promise<void> {
await UnifiedGestures.waitAndTap(this.submitButton, {
description: 'Create Password Submit Button',
});
}
async isVisible(): Promise<void> {
await encapsulatedAction({
appium: async () => {
const el = await asPlaywrightElement(this.newPasswordInput);
await el.waitForDisplayed({ timeout: 10000 });
},
});
}
}
export default new CreatePasswordView();