-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathDappConnectionModal.ts
More file actions
153 lines (136 loc) · 4.62 KB
/
Copy pathDappConnectionModal.ts
File metadata and controls
153 lines (136 loc) · 4.62 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
149
150
151
152
153
import {
encapsulated,
EncapsulatedElementType,
asPlaywrightElement,
} from '../../framework/EncapsulatedElement';
import { encapsulatedAction } from '../../framework/encapsulatedAction';
import PlaywrightMatchers from '../../framework/PlaywrightMatchers';
import UnifiedGestures from '../../framework/UnifiedGestures';
import { getDriver } from '../../framework/PlaywrightUtilities';
import { ConnectAccountBottomSheetSelectorsIDs } from '../../../app/components/Views/AccountConnect/ConnectAccountBottomSheet.testIds';
import { ConnectedAccountsSelectorsIDs } from '../../../app/components/Views/AccountConnect/ConnectedAccountModal.testIds';
import { AccountCellIds } from '../../../app/component-library/components-temp/MultichainAccounts/AccountCell/AccountCell.testIds';
import { CellComponentSelectorsIDs } from '../../../app/component-library/components/Cells/Cell/CellComponent.testIds';
import { sleep } from '../../framework';
class DappConnectionModal {
get connectButton(): EncapsulatedElementType {
return encapsulated({
appium: () =>
PlaywrightMatchers.getElementById(
ConnectAccountBottomSheetSelectorsIDs.CONNECT_BUTTON,
),
});
}
get updateAccountsButton(): EncapsulatedElementType {
return encapsulated({
appium: () =>
PlaywrightMatchers.getElementById(
ConnectAccountBottomSheetSelectorsIDs.SELECT_MULTI_BUTTON,
),
});
}
get editAccountsButton(): EncapsulatedElementType {
return encapsulated({
appium: {
android: () =>
PlaywrightMatchers.getElementByXPath(
'//android.view.ViewGroup[@content-desc="Edit accounts"]',
),
ios: () =>
PlaywrightMatchers.getElementById(
ConnectedAccountsSelectorsIDs.ACCOUNT_LIST_BOTTOM_SHEET,
),
},
});
}
get permissionsTabButton(): EncapsulatedElementType {
return encapsulated({
appium: () =>
PlaywrightMatchers.getElementByXPath(
'//android.view.ViewGroup[@content-desc="Permissions"]',
),
});
}
get editNetworksButton(): EncapsulatedElementType {
return encapsulated({
appium: () =>
PlaywrightMatchers.getElementByXPath(
'(//android.widget.TextView[@text="Edit"])[2]',
),
});
}
get updateNetworksButton(): EncapsulatedElementType {
return encapsulated({
appium: () =>
PlaywrightMatchers.getElementByXPath(
'//android.widget.Button[@content-desc="Update"]',
),
});
}
getAccountButton(accountName: string): EncapsulatedElementType {
return encapsulated({
appium: () =>
PlaywrightMatchers.getElementByXPath(
`//android.widget.TextView[@resource-id="${AccountCellIds.ADDRESS}" and @text="${accountName}"]`,
),
});
}
getNetworkButton(networkName: string): EncapsulatedElementType {
return encapsulated({
appium: () =>
PlaywrightMatchers.getElementByXPath(
`//android.widget.TextView[@resource-id="${CellComponentSelectorsIDs.BASE_TITLE}" and @text="${networkName}"]`,
),
});
}
async tapConnectButton({
shouldCooldown = false,
timeToCooldown = 1000,
}: {
shouldCooldown?: boolean;
timeToCooldown?: number;
} = {}): Promise<void> {
await UnifiedGestures.waitAndTap(this.connectButton);
if (shouldCooldown) {
await sleep(timeToCooldown);
}
}
async tapEditAccountsButton(): Promise<void> {
await UnifiedGestures.tap(this.editAccountsButton);
}
async tapAccountButton(accountName: string): Promise<void> {
await UnifiedGestures.tap(this.getAccountButton(accountName));
}
async tapUpdateAccountsButton(): Promise<void> {
await UnifiedGestures.tap(this.updateAccountsButton);
}
async tapPermissionsTabButton(): Promise<void> {
await UnifiedGestures.tap(this.permissionsTabButton);
}
async tapEditNetworksButton(): Promise<void> {
await UnifiedGestures.tap(this.editNetworksButton);
}
async tapNetworkButton(networkName: string): Promise<void> {
await encapsulatedAction({
appium: async () => {
const drv = getDriver();
await drv.execute('mobile: scrollGesture', {
left: 0,
top: 0,
width: 1000,
height: 1000,
direction: 'down',
percent: 1.0,
});
const networkButton = await asPlaywrightElement(
this.getNetworkButton(networkName),
);
await networkButton.click();
},
});
}
async tapUpdateNetworksButton(): Promise<void> {
await UnifiedGestures.tap(this.updateNetworksButton);
}
}
export default new DappConnectionModal();