Skip to content

Commit 52a635a

Browse files
authored
test: improve timeout handling and page navigation in e2e tests (#1852)
# Checklist - [x] I've added error handling for all actions/requests, and verified how this error will show on UI. (or there was no error handling) - [x] I've reviewed all the copy changed/added in this PR, using AI if needed. (or there was no copy changes) - [x] I've included the reference to the issues being closed from Github and/or Linear (or there was no issues) - [x] I've changed the Docs to reflect my changes (or it was not needed) - [x] I've put docs links where it may be helpful (or it was not needed) - [x] I checked the resulting UI both in Light and Dark mode (or no UI changes were made) - [x] I **reviewed** the **entire PR** myself (preferably, on GH UI)
1 parent d3b7a9b commit 52a635a

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

.changeset/cool-teachers-drive.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"fuels-wallet": patch
3+
---
4+
5+
test: improve timeout handling and page navigation in e2e tests

packages/app/playwright/commons/logout.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import type { Page } from '@playwright/test';
22

3+
import { expect } from '@fuels/playwright-utils';
34
import { getButtonByText } from './button';
45
import { getByAriaLabel } from './locator';
56
import { hasText } from './text';
67

78
export const logout = async (page: Page) => {
9+
await expect
10+
.poll(async () => () => getByAriaLabel(page, 'Menu'), { timeout: 1000 })
11+
.not.toThrow();
812
await getByAriaLabel(page, 'Menu').click();
913
await page.locator(`[data-key="settings"]`).click();
1014
await page.locator(`[data-key="logout"]`).click();

packages/app/playwright/crx/crx.test.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { NetworkData, Account as WalletAccount } from '@fuel-wallet/types';
2-
import { type Locator, expect } from '@playwright/test';
2+
import { type Locator, Page, expect } from '@playwright/test';
33

44
import {
55
delay,
@@ -92,6 +92,7 @@ test.describe('FuelWallet Extension', () => {
9292
const popupPage = await context.newPage();
9393
const pagePromise = context.waitForEvent('page', {
9494
predicate: (page) => page.url().includes('sign-up'),
95+
timeout: 10_000,
9596
});
9697
await popupPage.goto(`chrome-extension://${extensionId}/popup.html`);
9798
const page = await pagePromise;
@@ -298,6 +299,7 @@ test.describe('FuelWallet Extension', () => {
298299
});
299300
const connectPage = await context.waitForEvent('page', {
300301
predicate: (page) => page.url().includes(extensionId),
302+
timeout: 10_000,
301303
});
302304

303305
await expect
@@ -359,6 +361,7 @@ test.describe('FuelWallet Extension', () => {
359361
);
360362
const selectNetworkPage = await context.waitForEvent('page', {
361363
predicate: (page) => page.url().includes(extensionId),
364+
timeout: 10_000,
362365
});
363366
await hasText(selectNetworkPage, 'Switching To');
364367
await hasText(selectNetworkPage, network.name);
@@ -386,6 +389,7 @@ test.describe('FuelWallet Extension', () => {
386389

387390
const selectNetworkPage = await context.waitForEvent('page', {
388391
predicate: (page) => page.url().includes(extensionId),
392+
timeout: 10_000,
389393
});
390394

391395
await hasText(selectNetworkPage, 'Review the Network to be added:');
@@ -591,6 +595,7 @@ test.describe('FuelWallet Extension', () => {
591595
);
592596
const signMessageRequest = await context.waitForEvent('page', {
593597
predicate: (page) => page.url().includes(extensionId),
598+
timeout: 10_000,
594599
});
595600
// Confirm signature
596601
await hasText(signMessageRequest, message);
@@ -686,6 +691,7 @@ test.describe('FuelWallet Extension', () => {
686691
// Wait for approve transaction page to show
687692
const approveTransactionPage = await context.waitForEvent('page', {
688693
predicate: (page) => page.url().includes(extensionId),
694+
timeout: 10_000,
689695
});
690696

691697
// Approve transaction
@@ -791,6 +797,7 @@ test.describe('FuelWallet Extension', () => {
791797

792798
const addAssetPage = await context.waitForEvent('page', {
793799
predicate: (page) => page.url().includes(extensionId),
800+
timeout: 10_000,
794801
});
795802
await hasText(addAssetPage, 'Review the Assets to be added:');
796803
await getButtonByText(addAssetPage, /add assets/i).click();
@@ -814,6 +821,7 @@ test.describe('FuelWallet Extension', () => {
814821

815822
const addAssetPage = await context.waitForEvent('page', {
816823
predicate: (page) => page.url().includes(extensionId),
824+
timeout: 10_000,
817825
});
818826
await hasText(addAssetPage, 'Review the Assets to be added:');
819827
await getButtonByText(addAssetPage, /add assets/i).click();

packages/app/playwright/crx/lock.test.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ test.describe('Lock FuelWallet after inactivity', () => {
2323
extensionId,
2424
}) => {
2525
const popupPage = await context.newPage();
26-
await popupPage.goto(`chrome-extension://${extensionId}/popup.html`);
27-
const page = await context.waitForEvent('page', {
26+
const pagePromise = context.waitForEvent('page', {
2827
predicate: (page) => page.url().includes('sign-up'),
28+
timeout: 10_000,
2929
});
30-
expect(page.url()).toContain('sign-up');
30+
await popupPage.goto(`chrome-extension://${extensionId}/popup.html`);
31+
expect((await pagePromise).url()).toContain('sign-up');
3132
});
3233

3334
test('should lock the wallet after 1 minute of inactivity (config in .env file)', async ({

0 commit comments

Comments
 (0)