diff --git a/.github/actions/e2e-tests-contracts/action.yaml b/.github/actions/e2e-tests-contracts/action.yaml index 08e5bb4df..f011bc52b 100644 --- a/.github/actions/e2e-tests-contracts/action.yaml +++ b/.github/actions/e2e-tests-contracts/action.yaml @@ -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 diff --git a/.github/workflows/tests-devnet.yaml b/.github/workflows/tests-devnet.yaml index 69bd06d8a..3d2578ae4 100644 --- a/.github/workflows/tests-devnet.yaml +++ b/.github/workflows/tests-devnet.yaml @@ -9,6 +9,9 @@ on: push: branches: - master + pull_request: + branches: + - master concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/tests-testnet.yaml b/.github/workflows/tests-testnet.yaml index 2bbbded77..aa35f690f 100644 --- a/.github/workflows/tests-testnet.yaml +++ b/.github/workflows/tests-testnet.yaml @@ -9,6 +9,9 @@ on: push: branches: - master + pull_request: + branches: + - master concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/package.json b/package.json index 962aacb1e..c275e7df4 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/app/playwright/commons/locator.ts b/packages/app/playwright/commons/locator.ts index f4cec0e1f..57adcb2c4 100644 --- a/packages/app/playwright/commons/locator.ts +++ b/packages/app/playwright/commons/locator.ts @@ -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) { diff --git a/packages/app/playwright/crx/crx.test.ts b/packages/app/playwright/crx/crx.test.ts index e660f6c8e..8fe2610db 100644 --- a/packages/app/playwright/crx/crx.test.ts +++ b/packages/app/playwright/crx/crx.test.ts @@ -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 () => { diff --git a/packages/app/playwright/crx/utils/popup.ts b/packages/app/playwright/crx/utils/popup.ts index 52a432074..2aed413dd 100644 --- a/packages/app/playwright/crx/utils/popup.ts +++ b/packages/app/playwright/crx/utils/popup.ts @@ -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'; @@ -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); diff --git a/packages/e2e-contract-tests/playwright/e2e/DepositHalfEth.test.ts b/packages/e2e-contract-tests/playwright/e2e/DepositHalfEth.test.ts index 406076ab8..73dc1359a 100644 --- a/packages/e2e-contract-tests/playwright/e2e/DepositHalfEth.test.ts +++ b/packages/e2e-contract-tests/playwright/e2e/DepositHalfEth.test.ts @@ -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 diff --git a/packages/e2e-contract-tests/playwright/e2e/ForwardAndMintMulticall.test.ts b/packages/e2e-contract-tests/playwright/e2e/ForwardAndMintMulticall.test.ts index dc186e133..4cc85b5b6 100644 --- a/packages/e2e-contract-tests/playwright/e2e/ForwardAndMintMulticall.test.ts +++ b/packages/e2e-contract-tests/playwright/e2e/ForwardAndMintMulticall.test.ts @@ -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 diff --git a/packages/e2e-contract-tests/playwright/e2e/ForwardCustomAsset.test.ts b/packages/e2e-contract-tests/playwright/e2e/ForwardCustomAsset.test.ts index 6a927e276..764b7152e 100644 --- a/packages/e2e-contract-tests/playwright/e2e/ForwardCustomAsset.test.ts +++ b/packages/e2e-contract-tests/playwright/e2e/ForwardCustomAsset.test.ts @@ -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(); diff --git a/packages/e2e-contract-tests/playwright/e2e/ForwardEth.test.ts b/packages/e2e-contract-tests/playwright/e2e/ForwardEth.test.ts index 946b6a6c0..cae15dce8 100644 --- a/packages/e2e-contract-tests/playwright/e2e/ForwardEth.test.ts +++ b/packages/e2e-contract-tests/playwright/e2e/ForwardEth.test.ts @@ -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())); diff --git a/packages/e2e-contract-tests/playwright/e2e/ForwardHalfAndExternalMint.test.ts b/packages/e2e-contract-tests/playwright/e2e/ForwardHalfAndExternalMint.test.ts index 8d10363b0..62e6216c6 100644 --- a/packages/e2e-contract-tests/playwright/e2e/ForwardHalfAndExternalMint.test.ts +++ b/packages/e2e-contract-tests/playwright/e2e/ForwardHalfAndExternalMint.test.ts @@ -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 diff --git a/packages/e2e-contract-tests/playwright/e2e/ForwardHalfAndMint.test.ts b/packages/e2e-contract-tests/playwright/e2e/ForwardHalfAndMint.test.ts index cdd03e2ea..fc65bb319 100644 --- a/packages/e2e-contract-tests/playwright/e2e/ForwardHalfAndMint.test.ts +++ b/packages/e2e-contract-tests/playwright/e2e/ForwardHalfAndMint.test.ts @@ -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 diff --git a/packages/e2e-contract-tests/playwright/e2e/ForwardHalfCustomAsset.test.ts b/packages/e2e-contract-tests/playwright/e2e/ForwardHalfCustomAsset.test.ts index 4578206e2..b00d9b343 100644 --- a/packages/e2e-contract-tests/playwright/e2e/ForwardHalfCustomAsset.test.ts +++ b/packages/e2e-contract-tests/playwright/e2e/ForwardHalfCustomAsset.test.ts @@ -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(); diff --git a/packages/e2e-contract-tests/playwright/e2e/MintAsset.test.ts b/packages/e2e-contract-tests/playwright/e2e/MintAsset.test.ts index 4656ae499..7442cbe7d 100644 --- a/packages/e2e-contract-tests/playwright/e2e/MintAsset.test.ts +++ b/packages/e2e-contract-tests/playwright/e2e/MintAsset.test.ts @@ -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()); @@ -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 = diff --git a/packages/playwright-utils/src/playwright-utils/fuelWalletTestHelper.ts b/packages/playwright-utils/src/playwright-utils/fuelWalletTestHelper.ts index ba6d63b97..2730bb510 100644 --- a/packages/playwright-utils/src/playwright-utils/fuelWalletTestHelper.ts +++ b/packages/playwright-utils/src/playwright-utils/fuelWalletTestHelper.ts @@ -1,4 +1,4 @@ -import type { BrowserContext, Locator } from '@playwright/test'; +import type { BrowserContext, Locator, Page } from '@playwright/test'; import { expect } from '../fixtures'; import { FUEL_MNEMONIC, FUEL_WALLET_PASSWORD } from '../mocks'; @@ -46,12 +46,13 @@ export class FuelWalletTestHelper { }) { const { url, chainId } = fuelProvider; const popupNotSignedUpPage = await context.newPage(); + const signupPageAsync = context.waitForEvent('page', { + predicate: (page) => page.url().includes('sign-up'), + }); await popupNotSignedUpPage.goto( `chrome-extension://${fuelExtensionId}/popup.html` ); - const signupPage = await context.waitForEvent('page', { - predicate: (page) => page.url().includes('sign-up'), - }); + const signupPage = await signupPageAsync; expect(signupPage.url()).toContain('sign-up'); await popupNotSignedUpPage.close(); @@ -141,8 +142,8 @@ export class FuelWalletTestHelper { if (!walletNotificationPage) { walletNotificationPage = await this.context.waitForEvent('page', { - predicate: (page) => page.url().includes('/popup'), - timeout: 5000, + predicate: (page) => page.url().includes('/popup.html?'), + timeout: 15000, }); } @@ -173,8 +174,7 @@ export class FuelWalletTestHelper { { timeout: 5000 } ) .toBeTruthy(); - await walletPage.waitForTimeout(2000); - await menuButton!.click(); + await menuButton!.click({ delay: 2000 }); const settingsButton = walletPage .getByRole('menuitem') @@ -291,7 +291,9 @@ export class FuelWalletTestHelper { 'Add new network' ); await expectButtonToBeEnabled(addNewNetworkButton); - await addNewNetworkButton.click(); + await addNewNetworkButton.click({ + delay: 1000, + }); } async switchNetwork(chainName: string) {