1
1
import type { Locator , Page } from '@playwright/test' ;
2
2
import { expect } from '@playwright/test' ;
3
- import { BASE_URL , DEFAULT_SESSION_PARAMS } from '../constants' ;
3
+ import { BASE_URL , DEFAULT_SESSION_PARAMS , TIMEOUTS } from '../constants' ;
4
4
import { WalletValidator } from '../validators/WalletValidator' ;
5
5
import { WalletPage } from './WalletPage' ;
6
- import { TimingRecords } from '../types' ;
6
+ import { SupportedChain , TimingRecords } from '../types' ;
7
7
import { ModalValidator } from '../validators/ModalValidator' ;
8
8
9
9
export class ModalPage {
@@ -92,7 +92,7 @@ export class ModalPage {
92
92
await expect ( accountBtn , 'Account button should be visible' ) . toBeVisible ( ) ;
93
93
await expect ( accountBtn , 'Account button should be enabled' ) . toBeEnabled ( ) ;
94
94
await accountBtn . click ( ) ;
95
- const disconnectBtn = this . page . getByTestId ( 'disconnect- button' ) ;
95
+ const disconnectBtn = this . page . getByTestId ( 'button-disconnect ' ) ;
96
96
await expect ( disconnectBtn , 'Disconnect button should be visible' ) . toBeVisible ( ) ;
97
97
await expect ( disconnectBtn , 'Disconnect button should be enabled' ) . toBeEnabled ( ) ;
98
98
await disconnectBtn . click ( ) ;
@@ -125,20 +125,12 @@ export class ModalPage {
125
125
// await this.page.getByTestId('w3m-connecting-siwe-cancel').click();
126
126
// }
127
127
128
- async switchNetwork ( network : string ) {
129
- await this . openAccountModal ( ) ;
130
- await this . page . getByTestId ( 'w3m-account-select-network' ) . click ( ) ;
128
+ async switchNetwork ( network : SupportedChain ) {
131
129
await this . page . getByTestId ( `w3m-network-switch-${ network } ` ) . click ( ) ;
132
- // The state is chaing too fast and test runner doesn't wait the loading page. It's fastly checking the network selection button and detect that it's switched already.
133
- await this . page . waitForTimeout ( 300 ) ;
130
+ // The state is changing too fast and test runner doesn't wait for the loading page
131
+ await this . page . waitForTimeout ( TIMEOUTS . NETWORK_SWITCH ) ;
134
132
}
135
133
136
- // async clickWalletDeeplink() {
137
- // await this.connectButton.click();
138
- // await this.page.getByTestId('wallet-selector-react-wallet-v2').click();
139
- // await this.page.getByTestId('tab-desktop').click();
140
- // }
141
-
142
134
async openAccountModal ( ) {
143
135
await this . page . getByTestId ( 'account-button' ) . click ( ) ;
144
136
}
@@ -154,17 +146,9 @@ export class ModalPage {
154
146
async closeModal ( ) {
155
147
await this . page . getByTestId ( 'header-close' ) ?. click ?.( ) ;
156
148
// Wait for the modal fade out animation
157
- await this . page . waitForTimeout ( 300 ) ;
149
+ await this . page . waitForTimeout ( TIMEOUTS . ANIMATION ) ;
158
150
}
159
151
160
- // async switchNetworkWithNetworkButton(networkName: string) {
161
- // const networkButton = this.page.getByTestId('wui-network-button');
162
- // await networkButton.click();
163
-
164
- // const networkToSwitchButton = this.page.getByTestId(`w3m-network-switch-${networkName}`);
165
- // await networkToSwitchButton.click();
166
- // }
167
-
168
152
async openAllWallets ( ) {
169
153
const allWallets = this . page . getByTestId ( 'all-wallets' ) ;
170
154
await expect ( allWallets , 'All wallets should be visible' ) . toBeVisible ( ) ;
@@ -177,18 +161,6 @@ export class ModalPage {
177
161
await qrCodeButton . click ( ) ;
178
162
}
179
163
180
- // async clickAllWalletsListSearchItem(id: string) {
181
- // const allWalletsListSearchItem = this.page.getByTestId(`wallet-search-item-${id}`);
182
- // await expect(allWalletsListSearchItem).toBeVisible();
183
- // await allWalletsListSearchItem.click();
184
- // }
185
-
186
- // async clickTabWebApp() {
187
- // const tabWebApp = this.page.getByTestId('tab-webapp');
188
- // await expect(tabWebApp).toBeVisible();
189
- // await tabWebApp.click();
190
- // }
191
-
192
164
async clickHookDisconnectButton ( ) {
193
165
const disconnectHookButton = this . page . getByTestId ( 'disconnect-hook-button' ) ;
194
166
await expect ( disconnectHookButton ) . toBeVisible ( ) ;
@@ -216,64 +188,37 @@ export class ModalPage {
216
188
return this . page . evaluate ( ( ) => navigator . clipboard . readText ( ) ) ;
217
189
}
218
190
219
- // async clickOpenWebApp() {
220
- // let url = '';
221
-
222
- // const openButton = this.page.getByTestId('w3m-connecting-widget-secondary-button');
223
- // await expect(openButton).toBeVisible();
224
- // await expect(openButton).toHaveText('Open');
225
-
226
- // while (!url) {
227
- // await openButton.click();
228
- // await this.page.waitForTimeout(500);
229
-
230
- // const pages = this.page.context().pages();
231
-
232
- // // Check if more than 1 tab is open
233
- // if (pages.length > 1) {
234
- // const lastTab = pages[pages.length - 1];
235
-
236
- // if (lastTab) {
237
- // url = lastTab.url();
238
- // break;
239
- // }
240
- // }
241
- // }
242
-
243
- // return url;
244
- // }
245
-
246
191
async search ( value : string ) {
247
192
const searchInput = this . page . getByTestId ( 'wui-input-text' ) ;
248
193
await expect ( searchInput , 'Search input should be visible' ) . toBeVisible ( ) ;
249
194
await searchInput . click ( ) ;
250
195
await searchInput . fill ( value ) ;
251
196
}
252
197
253
- async openNetworks ( ) {
254
- await this . page . getByTestId ( 'w3m-account-select -network' ) . click ( ) ;
198
+ async goToNetworks ( ) {
199
+ await this . page . getByTestId ( 'button -network' ) . click ( ) ;
255
200
await expect ( this . page . getByText ( 'Select network' ) ) . toBeVisible ( ) ;
256
201
}
257
202
258
- // async openProfileView() {
259
- // await this.page.getByTestId('wui-profile-button').click();
260
- // }
261
-
262
- // async getAddress(): Promise<`0x${string}`> {
263
- // const address = await this.page.getByTestId('w3m-address').textContent();
264
- // expect(address, 'Address should be present').toBeTruthy();
265
-
266
- // return address as `0x${string}`;
267
- // }
203
+ async goToActivity ( ) {
204
+ await this . page . getByTestId ( 'button-activity' ) . click ( ) ;
205
+ }
268
206
269
- // async getChainId(): Promise<number> {
270
- // const chainId = await this.page.getByTestId('w3m-chain-id ').textContent ();
271
- // expect(chainId, 'Chain ID should be present').toBeTruthy();
207
+ async goBack ( ) {
208
+ await this . page . getByTestId ( 'button-back ' ) . click ( ) ;
209
+ }
272
210
273
- // return Number(chainId);
274
- // }
211
+ async expectLoaderVisible ( ) {
212
+ await expect (
213
+ this . page . getByTestId ( 'loading-spinner' ) ,
214
+ 'Loading spinner should be visible'
215
+ ) . toBeVisible ( ) ;
216
+ }
275
217
276
- // async switchNetworkWithHook() {
277
- // await this.page.getByTestId('switch-network-hook-button').click();
278
- // }
218
+ async expectLoaderHidden ( ) {
219
+ await expect (
220
+ this . page . getByTestId ( 'loading-spinner' ) ,
221
+ 'Loading spinner should be hidden'
222
+ ) . toBeHidden ( ) ;
223
+ }
279
224
}
0 commit comments