Skip to content

Commit

Permalink
fix: flaky sdk e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurgeron committed Oct 31, 2024
1 parent 448d6db commit 39d00f3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/app/playwright/commons/locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function getByAriaLabel(page: Page, selector: string) {
}

export async function waitAriaLabel(page: Page, selector: string) {
return page.waitForSelector(`[aria-label="${selector}"]`);
return page.waitForSelector(`[aria-label="${selector}"]`, { timeout: 15000 });
}

export function getInputByName(page: Page, name: string) {
Expand Down
10 changes: 9 additions & 1 deletion packages/app/playwright/crx/crx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,15 @@ test.describe('FuelWallet Extension', () => {
const authorizedAccount = await switchAccount(popupPage, 'Account 1');

await seedWallet(authorizedAccount.address, bn(100_000_000));
await hasText(popupPage, /0\.100/i);
await expect
.poll(
() =>
hasText(popupPage, /0\.100/i)
.then(() => true)
.catch(() => false),
{ timeout: 15000 }
)
.toBeTruthy();
});

await test.step('Send transfer using authorized Account', async () => {
Expand Down
16 changes: 12 additions & 4 deletions packages/app/playwright/crx/utils/popup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Page } from '@playwright/test';
import { type Page, expect } from '@playwright/test';

import { getByAriaLabel, hasText, visit, waitAriaLabel } from '../../commons';
import type { MockData } from '../../mocks';
Expand Down Expand Up @@ -27,16 +27,24 @@ export async function switchAccount(popupPage: Page, name: string) {

await getByAriaLabel(popupPage, 'Accounts').click();

await popupPage.waitForTimeout(5000);
await hasText(popupPage, name);
await expect
.poll(
() =>
hasText(popupPage, name)
.then(() => true)
.catch(() => false),
{ timeout: 15000 }
)
.toBeTruthy();

// Add position to click on the element and not on copy button
await getByAriaLabel(popupPage, name).click({
position: {
x: 10,
y: 10,
},
});
await popupPage.waitForTimeout(2000);

await waitAriaLabel(popupPage, `${name} selected`);

// Return account to be used on tests
Expand Down

0 comments on commit 39d00f3

Please sign in to comment.