11import type { Locator , Page } from '@playwright/test' ;
22import { expect } from '@playwright/test' ;
3- import { BASE_URL , DEFAULT_SESSION_PARAMS } from '../constants' ;
3+ import { BASE_URL , DEFAULT_SESSION_PARAMS , TIMEOUTS } from '../constants' ;
44import { WalletValidator } from '../validators/WalletValidator' ;
55import { WalletPage } from './WalletPage' ;
6- import { TimingRecords } from '../types' ;
6+ import { SupportedChain , TimingRecords } from '../types' ;
77import { ModalValidator } from '../validators/ModalValidator' ;
88
99export class ModalPage {
@@ -92,7 +92,7 @@ export class ModalPage {
9292 await expect ( accountBtn , 'Account button should be visible' ) . toBeVisible ( ) ;
9393 await expect ( accountBtn , 'Account button should be enabled' ) . toBeEnabled ( ) ;
9494 await accountBtn . click ( ) ;
95- const disconnectBtn = this . page . getByTestId ( 'disconnect- button' ) ;
95+ const disconnectBtn = this . page . getByTestId ( 'button-disconnect ' ) ;
9696 await expect ( disconnectBtn , 'Disconnect button should be visible' ) . toBeVisible ( ) ;
9797 await expect ( disconnectBtn , 'Disconnect button should be enabled' ) . toBeEnabled ( ) ;
9898 await disconnectBtn . click ( ) ;
@@ -125,20 +125,12 @@ export class ModalPage {
125125 // await this.page.getByTestId('w3m-connecting-siwe-cancel').click();
126126 // }
127127
128- async switchNetwork ( network : string ) {
129- await this . openAccountModal ( ) ;
130- await this . page . getByTestId ( 'w3m-account-select-network' ) . click ( ) ;
128+ async switchNetwork ( network : SupportedChain ) {
131129 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 ) ;
134132 }
135133
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-
142134 async openAccountModal ( ) {
143135 await this . page . getByTestId ( 'account-button' ) . click ( ) ;
144136 }
@@ -154,17 +146,9 @@ export class ModalPage {
154146 async closeModal ( ) {
155147 await this . page . getByTestId ( 'header-close' ) ?. click ?.( ) ;
156148 // Wait for the modal fade out animation
157- await this . page . waitForTimeout ( 300 ) ;
149+ await this . page . waitForTimeout ( TIMEOUTS . ANIMATION ) ;
158150 }
159151
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-
168152 async openAllWallets ( ) {
169153 const allWallets = this . page . getByTestId ( 'all-wallets' ) ;
170154 await expect ( allWallets , 'All wallets should be visible' ) . toBeVisible ( ) ;
@@ -177,18 +161,6 @@ export class ModalPage {
177161 await qrCodeButton . click ( ) ;
178162 }
179163
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-
192164 async clickHookDisconnectButton ( ) {
193165 const disconnectHookButton = this . page . getByTestId ( 'disconnect-hook-button' ) ;
194166 await expect ( disconnectHookButton ) . toBeVisible ( ) ;
@@ -216,64 +188,37 @@ export class ModalPage {
216188 return this . page . evaluate ( ( ) => navigator . clipboard . readText ( ) ) ;
217189 }
218190
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-
246191 async search ( value : string ) {
247192 const searchInput = this . page . getByTestId ( 'wui-input-text' ) ;
248193 await expect ( searchInput , 'Search input should be visible' ) . toBeVisible ( ) ;
249194 await searchInput . click ( ) ;
250195 await searchInput . fill ( value ) ;
251196 }
252197
253- async openNetworks ( ) {
254- await this . page . getByTestId ( 'w3m-account-select -network' ) . click ( ) ;
198+ async goToNetworks ( ) {
199+ await this . page . getByTestId ( 'button -network' ) . click ( ) ;
255200 await expect ( this . page . getByText ( 'Select network' ) ) . toBeVisible ( ) ;
256201 }
257202
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+ }
268206
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+ }
272210
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+ }
275217
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+ }
279224}
0 commit comments