Skip to content

Commit

Permalink
test(e2e): Fix Chrome Beta channel (#1691)
Browse files Browse the repository at this point in the history
  • Loading branch information
nelitow authored Dec 10, 2024
1 parent 473067c commit 33f3d77
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 52 deletions.
7 changes: 7 additions & 0 deletions .changeset/dry-flies-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"fuels-wallet": patch
---

### Changed

Updated nanoid to the latest versions for better performance and security.
19 changes: 2 additions & 17 deletions .github/actions/e2e-tests-contracts/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,9 @@ runs:
NODE_OPTIONS: "--max-old-space-size=4096"
NODE_ENV: test

- name: Cache Playwright browsers
uses: actions/cache@v3
- uses: ./.github/actions/setup-playwright
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ inputs.browser }}
restore-keys: |
${{ runner.os }}-playwright-
# E2E tests running with Playwright
- name: Install Playwright Browsers
shell: bash
run: |
pnpm playwright install --with-deps chromium chrome-beta --force
- name: Install Playwright Browsers (${{ inputs.browser }})
if: inputs.browser != '' && inputs.browser != 'chromium'
shell: bash
run: npx playwright install --with-deps ${{ inputs.browser }}
browser: ${{ inputs.browser }}

- name: Run E2E Contract Tests
shell: bash
Expand Down
33 changes: 33 additions & 0 deletions .github/actions/setup-playwright/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'E2E Contract Tests'

inputs:
providerUrl:
description: Provider URL (e.g., https://testnet.fuel.network/v1/graphql)
required: true
masterMnemonic:
description: Mnemonic of the master wallet that will fund the tests
required: true
genesisSecret:
description: Secret of genesis to fund the master wallet
required: false
browser:
description: Browser to run tests on (chromium, chrome-beta, or both)
required: false
default: chromium

runs:
using: 'composite'
steps:
- name: Cache Playwright browsers
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ inputs.browser }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Install Playwright Browsers
shell: bash
continue-on-error: true
run: |
pnpm playwright install --with-deps ${{ inputs.browser }}
3 changes: 2 additions & 1 deletion .github/workflows/pr-tests-e2e-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
providerUrl: "http://localhost:4000/v1/graphql"
masterMnemonic: ${{ secrets.VITE_MASTER_WALLET_MNEMONIC }}
genesisSecret: "0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298"
browser: 'chromium'

- uses: actions/upload-artifact@v4
if: always()
Expand All @@ -58,7 +59,7 @@ jobs:
tests-e2e-contracts-beta:
name: Test (Chrome Beta)
runs-on: buildjet-8vcpu-ubuntu-2204
timeout-minutes: 10
timeout-minutes: 15
continue-on-error: true
steps:
- uses: actions/checkout@v4
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/pr-tests-e2e-crx-lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,7 @@ jobs:
## with sourcemaps
NODE_OPTIONS: "--max-old-space-size=4096"

- name: Install Playwright Browsers
shell: bash
run: |
pnpm playwright install --with-deps chromium chrome-beta --force
# E2E tests running with Playwright
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- uses: ./.github/actions/setup-playwright

- name: Run E2E Tests
run: xvfb-run --auto-servernum -- pnpm test:e2e:crx-lock
Expand Down
64 changes: 53 additions & 11 deletions .github/workflows/pr-tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ concurrency:

jobs:
tests-e2e:
name: Test
timeout-minutes: 20
name: Test (Chrome Stable)
timeout-minutes: 15
runs-on: buildjet-8vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
Expand All @@ -38,14 +38,7 @@ jobs:
## with sourcemaps
NODE_OPTIONS: "--max-old-space-size=4096"

- name: Install Playwright Browsers
shell: bash
run: |
pnpm playwright install --with-deps chromium chrome-beta --force
# E2E tests running with Playwright
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- uses: ./.github/actions/setup-playwright

- name: Run E2E Tests
run: xvfb-run --auto-servernum -- pnpm test:e2e
Expand All @@ -56,7 +49,56 @@ jobs:
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-app-report
name: playwright-app-report-stable
path: packages/app/playwright-results
retention-days: 30

- name: Stop Test Node
run: pnpm node:clean

tests-e2e-beta:
name: Test (Chrome Beta)
timeout-minutes: 15
runs-on: buildjet-8vcpu-ubuntu-2204
continue-on-error: true
steps:
- uses: actions/checkout@v3
- uses: FuelLabs/github-actions/setups/node@master
with:
node-version: 20.11.0
pnpm-version: 9.5.0
- uses: FuelLabs/github-actions/setups/docker@master
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Start Test Node
run: pnpm node:up

- name: Generate .env
run: cp packages/app/.env.example packages/app/.env

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

- uses: ./.github/actions/setup-playwright
with:
browser: 'chrome-beta'

- name: Run E2E Tests
run: xvfb-run --auto-servernum -- pnpm test:e2e:beta
timeout-minutes: 15
env:
NODE_ENV: test

- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-app-report-beta
path: packages/app/playwright-results
retention-days: 30

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"test:ci": "turbo run test --parallel -- --ci --testLocationInResults --json --coverage",
"test:clear": "pnpm -r exec jest --clearCache",
"test:coverage": "turbo run test --parallel -- --coverage",
"test:e2e": "NODE_ENV=test pnpm build:crx && playwright test --config=packages/app/playwright.config.ts",
"test:e2e": "NODE_ENV=test pnpm build:crx && playwright test --config=packages/app/playwright.config.ts --project=chromium",
"test:e2e:beta": "NODE_ENV=test pnpm build:crx && playwright test --config=packages/app/playwright.config.ts --project=chrome-beta",
"test:e2e:crx-lock": "NODE_ENV=test pnpm build:crx && playwright test --config=packages/app/playwright.crx-lock.config.ts",
"test:e2e:contracts": "NODE_ENV=test pnpm build:crx && pnpm --filter=@fuel-wallet/e2e-contract-tests test:e2e",
"test:appfile": "pnpm --filter=fuels-wallet test --",
Expand Down Expand Up @@ -125,7 +126,8 @@
"fuels": "0.96.1",
"secp256k1@=5.0.0": ">=5.0.1",
"elliptic@<6.6.0": ">=6.6.0",
"cross-spawn@<7.0.5": ">=7.0.5"
"cross-spawn@<7.0.5": ">=7.0.5",
"nanoid@<3.3.8": "3.3.8"
}
}
}
26 changes: 23 additions & 3 deletions packages/app/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { join } from 'node:path';
import { type PlaywrightTestConfig, defineConfig } from '@playwright/test';
// biome-ignore lint/style/useNodejsImportProtocol: <explanation>
import {
type PlaywrightTestConfig,
defineConfig,
devices,
} from '@playwright/test';
import './load.envs';
import './load.envs.cts';

const PORT = process.env.PORT;
Expand All @@ -12,7 +18,7 @@ export const playwrightConfig: PlaywrightTestConfig = {
testDir: 'playwright/',
outputDir: 'playwright-results/',
// stop on first failure
maxFailures: IS_CI ? 1 : undefined,
maxFailures: IS_CI ? 2 : undefined,
reporter: [
['list', { printSteps: true }],
['html', { outputFolder: './playwright-html/' }],
Expand All @@ -31,7 +37,21 @@ export const playwrightConfig: PlaywrightTestConfig = {
screenshot: 'only-on-failure',
headless: false,
},
// ignore lock test because it takes too long and it will be tested in a separate config
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chromium'],
},
},
{
name: 'chrome-beta',
use: {
channel: 'chrome-beta',
...devices['Desktop Chrome'],
},
},
],
testIgnore: ['playwright/crx/lock.test.ts'],
};

Expand Down
10 changes: 9 additions & 1 deletion packages/app/playwright.crx-lock.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// biome-ignore lint/style/useNodejsImportProtocol: <explanation>
import { join } from 'path';
import { defineConfig } from '@playwright/test';
import { defineConfig, devices } from '@playwright/test';
import { playwrightConfig } from './playwright.config';

const __dirname = new URL('.', import.meta.url).pathname;
Expand All @@ -9,4 +9,12 @@ export default defineConfig({
...playwrightConfig,
testMatch: join(__dirname, './playwright/crx/lock.test.ts'),
testIgnore: undefined,
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chromium'],
},
},
],
});
4 changes: 2 additions & 2 deletions packages/e2e-contract-tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const IS_CI = process.env.CI;
const config: PlaywrightTestConfig = defineConfig({
testDir: './playwright',
outputDir: './playwright-results/',
retries: IS_CI ? 1 : 0,
retries: IS_CI ? 2 : 0,
workers: 1,
timeout: 60_000,
timeout: 120_000,
reporter: [['html', { printSteps: true }]],
webServer: {
command: `pnpm dev:e2e-contracts --port ${process.env.PORT}`,
Expand Down
15 changes: 8 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 33f3d77

Please sign in to comment.