Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: flaky e2e contracts #1643

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
10 changes: 0 additions & 10 deletions .github/actions/e2e-tests-contracts/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ runs:
using: 'composite'
steps:


- name: Build Application
shell: bash
run: pnpm build:all
env:
## increase node.js m memory limit for building
## with sourcemaps
NODE_OPTIONS: "--max-old-space-size=4096"
NODE_ENV: test

# E2E tests running with Playwright
- name: Install Playwright Browsers (${{ inputs.browser }})
shell: bash
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests-devnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
push:
branches:
- master
pull_request:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
push:
branches:
- master
pull_request:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"build:all": "turbo run build:all",
"build:docs": "turbo run build:docs",
"build:web": "turbo run build:web",
"build:crx": "turbo run build:crx",
"build:crx": "turbo run build:crx --concurrency=100%",
"build:app": "turbo run build:app",
"build:libs": "turbo run build",
"changeset": "changeset",
Expand Down
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: 30000 });
}

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 @@ -719,7 +719,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
21 changes: 13 additions & 8 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 { expect } from '@fuels/playwright-utils';
import { getByAriaLabel, hasText, visit, waitAriaLabel } from '../../commons';
Expand Down Expand Up @@ -29,21 +29,26 @@ export async function switchAccount(popupPage: Page, name: string) {
await popupPage.waitForTimeout(2000);
await getByAriaLabel(popupPage, 'Accounts').click();

await hasText(popupPage, name);
// Add position to click on the element and not on copy button
await popupPage.waitForTimeout(5000);
await getByAriaLabel(popupPage, name).click();

await expect
.poll(
() =>
waitAriaLabel(popupPage, `${name} selected`)
hasText(popupPage, name)
.then(() => true)
.catch(() => false),
{ timeout: 30000 }
{ 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 waitAriaLabel(popupPage, `${name} selected`);

// Return account to be used on tests
account = await getAccountByName(popupPage, name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,35 @@ test.describe('Deposit Half ETH', () => {

const depositHalfButton = getButtonByText(page, 'Deposit Half ETH', true);
await expectButtonToBeEnabled(depositHalfButton);
await depositHalfButton.click();

await depositHalfButton.click({
delay: 1000,
});
const walletNotificationPage =
await fuelWalletTestHelper.getWalletPopupPage();

// Test if asset name is defined (not unknown)
checkAriaLabelsContainsText(
await checkAriaLabelsContainsText(
walletNotificationPage,
'Asset Name',
'Ethereum'
);
// Test if sender name is defined (not unknown)
checkAriaLabelsContainsText(walletNotificationPage, 'Sender Name', '');
await checkAriaLabelsContainsText(
walletNotificationPage,
'Sender Name',
''
);

// test forward asset name is shown
await hasText(walletNotificationPage, 'Ethereum');
await expect
.poll(
async () =>
await hasText(walletNotificationPage, 'Ethereum')
.then(() => true)
.catch(() => false),
{ timeout: 15000 }
)
.toBeTruthy();
// test forward asset id is shown
await hasText(walletNotificationPage, shortAddress(await getBaseAssetId()));
// test forward eth amount is correct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,36 @@ test.describe('Forward and Mint Multicall', () => {
'Deposit And Mint Multicall'
);
await expectButtonToBeEnabled(forwardHalfAndMintButton);
await forwardHalfAndMintButton.click();
await forwardHalfAndMintButton.click({
delay: 1000,
});

const walletNotificationPage =
await fuelWalletTestHelper.getWalletPopupPage();

// Test if asset name is defined (not unknown)
checkAriaLabelsContainsText(
await checkAriaLabelsContainsText(
walletNotificationPage,
'Asset Name',
'Ethereum'
);
// Test if sender name is defined (not unknown)
checkAriaLabelsContainsText(walletNotificationPage, 'Sender Name', '');
await checkAriaLabelsContainsText(
walletNotificationPage,
'Sender Name',
''
);

// test forward asset name is shown
await hasText(walletNotificationPage, 'Ethereum');
await expect
.poll(
async () =>
await hasText(walletNotificationPage, 'Ethereum')
.then(() => true)
.catch(() => false),
{ timeout: 15000 }
)
.toBeTruthy();
// test forward asset id is shown
await hasText(walletNotificationPage, shortAddress(await getBaseAssetId()));
// test forward eth amount is correct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ test.describe('Forward Custom Asset', () => {
'Forward Custom Asset'
);
await expectButtonToBeEnabled(forwardCustomAssetButton);
await forwardCustomAssetButton.click();
await forwardCustomAssetButton.click({
delay: 1000,
});

const walletNotificationPage =
await fuelWalletTestHelper.getWalletPopupPage();
Expand Down
22 changes: 18 additions & 4 deletions packages/e2e-contract-tests/playwright/e2e/ForwardEth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,36 @@ test.describe('Forward Eth', () => {

const forwardEthButton = getButtonByText(page, 'Forward ETH');
await expectButtonToBeEnabled(forwardEthButton);
await forwardEthButton.click();
await forwardEthButton.click({
delay: 1000,
});

const walletNotificationPage =
await fuelWalletTestHelper.getWalletPopupPage();

// Test if asset name is defined (not unknown)
checkAriaLabelsContainsText(
await checkAriaLabelsContainsText(
walletNotificationPage,
'Asset Name',
'Ethereum'
);
// Test if sender name is defined (not unknown)
checkAriaLabelsContainsText(walletNotificationPage, 'Sender Name', '');
await checkAriaLabelsContainsText(
walletNotificationPage,
'Sender Name',
''
);

// test the asset name is shown
await hasText(walletNotificationPage, 'Ethereum');
await expect
.poll(
async () =>
await hasText(walletNotificationPage, 'Ethereum')
.then(() => true)
.catch(() => false),
{ timeout: 15000 }
)
.toBeTruthy();

// test asset id is correct
await hasText(walletNotificationPage, shortAddress(await getBaseAssetId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,36 @@ test.describe('Forward Half ETH and Mint External Custom Asset', () => {
'Forward Half And External Mint'
);
await expectButtonToBeEnabled(forwardHalfAndMintButton);
await forwardHalfAndMintButton.click();
await forwardHalfAndMintButton.click({
delay: 1000,
});

const walletNotificationPage =
await fuelWalletTestHelper.getWalletPopupPage();

// Test if asset name is defined (not unknown)
checkAriaLabelsContainsText(
await checkAriaLabelsContainsText(
walletNotificationPage,
'Asset Name',
'Ethereum'
);
// Test if sender name is defined (not unknown)
checkAriaLabelsContainsText(walletNotificationPage, 'Sender Name', '');
await checkAriaLabelsContainsText(
walletNotificationPage,
'Sender Name',
''
);

// test forward asset name is shown
await hasText(walletNotificationPage, 'Ethereum');
await expect
.poll(
async () =>
await hasText(walletNotificationPage, 'Ethereum')
.then(() => true)
.catch(() => false),
{ timeout: 15000 }
)
.toBeTruthy();
// test forward asset id is shown
await hasText(walletNotificationPage, shortAddress(await getBaseAssetId()));
// test forward eth amount is correct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,36 @@ test.describe('Forward Half ETH and Mint Custom Asset', () => {
'Forward Half And Mint'
);
await expectButtonToBeEnabled(forwardHalfAndMintButton);
await forwardHalfAndMintButton.click();
await forwardHalfAndMintButton.click({
delay: 1000,
});

const walletNotificationPage =
await fuelWalletTestHelper.getWalletPopupPage();

// Test if asset name is defined (not unknown)
checkAriaLabelsContainsText(
await checkAriaLabelsContainsText(
walletNotificationPage,
'Asset Name',
'Ethereum'
);
// Test if sender name is defined (not unknown)
checkAriaLabelsContainsText(walletNotificationPage, 'Sender Name', '');
await checkAriaLabelsContainsText(
walletNotificationPage,
'Sender Name',
''
);

// test forward asset name is shown
await hasText(walletNotificationPage, 'Ethereum');
await expect
.poll(
async () =>
await hasText(walletNotificationPage, 'Ethereum')
.then(() => true)
.catch(() => false),
{ timeout: 15000 }
)
.toBeTruthy();
// test forward asset id is shown
await hasText(walletNotificationPage, shortAddress(await getBaseAssetId()));
// test forward eth amount is correct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ test.describe('Forward Half Custom Asset', () => {
'Forward Half Custom Asset'
);
await expectButtonToBeEnabled(forwardHalfCustomAssetButton);
await forwardHalfCustomAssetButton.click();
await forwardHalfCustomAssetButton.click({
delay: 1000,
});

const walletNotificationPage =
await fuelWalletTestHelper.getWalletPopupPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ test.describe('Mint Assets', () => {

const mintButton = getButtonByText(page, 'Mint', true);
await expectButtonToBeEnabled(mintButton);
await mintButton.click();
await mintButton.click({
delay: 1000,
});

// test asset is correct
const assetId = calculateAssetId(MAIN_CONTRACT_ID, await getBaseAssetId());
Expand Down Expand Up @@ -126,7 +128,9 @@ test.describe('Mint Assets', () => {
const mintButton = getButtonByText(page, 'Mint Asset configuration');

await expectButtonToBeEnabled(mintButton);
await mintButton.click();
await mintButton.click({
delay: 1000,
});

// test asset is correct
const walletNotificationPage =
Expand Down
Loading
Loading