Skip to content

Commit 728ec72

Browse files
Merge pull request #316 from reown-com/fix/transaction-load
fix: load transactions only when needed
2 parents b43f2ab + 342e438 commit 728ec72

File tree

14 files changed

+203
-130
lines changed

14 files changed

+203
-130
lines changed

.changeset/empty-mangos-push.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@reown/appkit-coinbase-ethers-react-native': patch
3+
'@reown/appkit-coinbase-wagmi-react-native': patch
4+
'@reown/appkit-scaffold-utils-react-native': patch
5+
'@reown/appkit-auth-ethers-react-native': patch
6+
'@reown/appkit-auth-wagmi-react-native': patch
7+
'@reown/appkit-scaffold-react-native': patch
8+
'@reown/appkit-ethers5-react-native': patch
9+
'@reown/appkit-common-react-native': patch
10+
'@reown/appkit-ethers-react-native': patch
11+
'@reown/appkit-wagmi-react-native': patch
12+
'@reown/appkit-core-react-native': patch
13+
'@reown/appkit-siwe-react-native': patch
14+
'@reown/appkit-ui-react-native': patch
15+
'@reown/appkit-wallet-react-native': patch
16+
---
17+
18+
fix: load transactions when needed

.maestro/w3m-connect-flow.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ appId: com.walletconnect.web3modal.rnclisdk
5757
id: 'account-button'
5858

5959
- tapOn:
60-
id: 'w3m-account-select-network'
60+
id: 'button-network'
6161

6262
- tapOn:
6363
text: 'Polygon'
@@ -68,7 +68,7 @@ appId: com.walletconnect.web3modal.rnclisdk
6868
text: 'Polygon'
6969

7070
- tapOn:
71-
id: 'disconnect-button'
71+
id: 'button-disconnect'
7272

7373
- assertVisible:
7474
id: 'connect-button'

apps/native/tests/shared/constants/index.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,20 @@ export const DEFAULT_SESSION_PARAMS: SessionParams = {
88
optAccounts: ['1', '2'],
99
accept: true
1010
};
11-
export const DEFAULT_CHAIN_NAME = process.env.DEFAULT_CHAIN_NAME || 'Ethereum';
11+
12+
export const TEST_CHAINS = {
13+
POLYGON: 'Polygon',
14+
ETHEREUM: 'Ethereum',
15+
GNOSIS: 'Gnosis'
16+
} as const;
17+
18+
export type SupportedChain = (typeof TEST_CHAINS)[keyof typeof TEST_CHAINS];
19+
20+
export const TIMEOUTS = {
21+
ANIMATION: 300,
22+
NETWORK_SWITCH: 500,
23+
CONNECTION: 5000,
24+
SESSION_PROPOSAL: 30000
25+
} as const;
26+
27+
export const DEFAULT_CHAIN_NAME = process.env.DEFAULT_CHAIN_NAME || TEST_CHAINS.ETHEREUM;

apps/native/tests/shared/constants/timeouts.ts

-1
This file was deleted.

apps/native/tests/shared/pages/ModalPage.ts

+27-82
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { Locator, Page } from '@playwright/test';
22
import { expect } from '@playwright/test';
3-
import { BASE_URL, DEFAULT_SESSION_PARAMS } from '../constants';
3+
import { BASE_URL, DEFAULT_SESSION_PARAMS, TIMEOUTS } from '../constants';
44
import { WalletValidator } from '../validators/WalletValidator';
55
import { WalletPage } from './WalletPage';
6-
import { TimingRecords } from '../types';
6+
import { SupportedChain, TimingRecords } from '../types';
77
import { ModalValidator } from '../validators/ModalValidator';
88

99
export 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
}

apps/native/tests/shared/pages/WalletPage.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,23 @@ export class WalletPage {
117117
await this.page.waitForLoadState();
118118
const sessionsButton = this.page.getByTestId('sessions');
119119
await sessionsButton.click();
120-
const sessionCard = this.page.getByTestId(`session-card`);
121-
await sessionCard.click();
122-
const disconnectButton = this.page.getByText('Delete');
123-
await disconnectButton.click();
120+
121+
// Try to disconnect all visible session cards
122+
while (true) {
123+
const sessionCards = this.page.getByTestId('session-card');
124+
const count = await sessionCards.count();
125+
126+
if (count === 0) {
127+
break;
128+
}
129+
130+
// Click the first card and disconnect it
131+
await sessionCards.first().click();
132+
const disconnectButton = this.page.getByText('Delete');
133+
await disconnectButton.click();
134+
135+
// Wait a bit for the disconnection to complete
136+
await this.page.waitForTimeout(500);
137+
}
124138
}
125139
}

apps/native/tests/shared/types/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { TEST_CHAINS } from '../constants';
2+
13
export interface SessionParams {
24
reqAccounts: string[];
35
optAccounts: string[];
@@ -7,3 +9,5 @@ export interface SessionParams {
79
export type TimingRecords = { item: string; timeMs: number }[];
810

911
export type CaipNetworkId = `${string}:${string}`;
12+
13+
export type SupportedChain = (typeof TEST_CHAINS)[keyof typeof TEST_CHAINS];
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { MAXIMUM_WAIT_CONNECTIONS } from '../constants/timeouts';
1+
import { TIMEOUTS } from '../constants';
22

33
export function getMaximumWaitConnections(): number {
44
if (process.env.CI) {
5-
return MAXIMUM_WAIT_CONNECTIONS;
5+
return TIMEOUTS.SESSION_PROPOSAL;
66
}
77

8-
return MAXIMUM_WAIT_CONNECTIONS * 2;
8+
return TIMEOUTS.SESSION_PROPOSAL * 2;
99
}

apps/native/tests/shared/validators/ModalValidator.ts

+1-16
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,6 @@ export class ModalValidator {
8282
await expect(address, 'Correct address should be present').toHaveText(expectedAddress);
8383
}
8484

85-
// async expectNetwork(network: string) {
86-
// const networkButton = this.page.getByTestId('w3m-account-select-network');
87-
// await expect(networkButton, `Network button should contain text ${network}`).toHaveText(
88-
// network,
89-
// {
90-
// timeout: 5000
91-
// }
92-
// );
93-
// }
94-
9585
async expectAcceptedSign() {
9686
await expect(this.page.getByText('Signature successful')).toBeVisible({
9787
timeout: 30 * 1000
@@ -103,7 +93,7 @@ export class ModalValidator {
10393
}
10494

10595
async expectSwitchedNetwork(network: string) {
106-
const switchNetworkButton = this.page.getByTestId(`w3m-account-select-network-text`);
96+
const switchNetworkButton = this.page.getByTestId(`account-select-network-text`);
10797
await expect(switchNetworkButton).toContainText(network);
10898
}
10999

@@ -132,11 +122,6 @@ export class ModalValidator {
132122
await expect(getAWalletView).toBeVisible();
133123
}
134124

135-
// async expectHeaderText(text: string) {
136-
// const headerText = this.page.getByTestId('header-text');
137-
// await expect(headerText).toHaveText(text);
138-
// }
139-
140125
async expectNetworksDisabled(name: string) {
141126
const disabledNetworkButton = this.page.getByTestId(`w3m-network-switch-${name}`);
142127
disabledNetworkButton.click();

0 commit comments

Comments
 (0)