diff --git a/.changeset/mean-monkeys-swim.md b/.changeset/mean-monkeys-swim.md new file mode 100644 index 000000000..dc6e77e15 --- /dev/null +++ b/.changeset/mean-monkeys-swim.md @@ -0,0 +1,5 @@ +--- +"fuels-wallet": patch +--- + +Update E2E setup diff --git a/.github/workflows/pr-tests-e2e-assets.yml b/.github/workflows/pr-tests-e2e-assets.yml index b8a5ed94f..2d7b75ca2 100644 --- a/.github/workflows/pr-tests-e2e-assets.yml +++ b/.github/workflows/pr-tests-e2e-assets.yml @@ -12,8 +12,8 @@ concurrency: jobs: tests-e2e-assets: name: Test - timeout-minutes: 10 runs-on: buildjet-8vcpu-ubuntu-2204 + timeout-minutes: 10 steps: - uses: actions/checkout@v3 - uses: FuelLabs/github-actions/setups/node@master diff --git a/package.json b/package.json index e88a941ca..640880ce2 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "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:assets": "NODE_ENV=test pnpm playwright test --config=packages/e2e-assets/playwright.config.ts", + "test:e2e:assets": "NODE_ENV=test pnpm playwright test --config=packages/app/playwright.assets.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 --", "ts:check": "turbo run ts:check", diff --git a/packages/app/playwright.assets.config.ts b/packages/app/playwright.assets.config.ts new file mode 100644 index 000000000..2d746e63b --- /dev/null +++ b/packages/app/playwright.assets.config.ts @@ -0,0 +1,17 @@ +import { defineConfig, devices } from '@playwright/test'; +import { playwrightConfig } from './playwright.config'; +import './load.envs.cts'; + +export default defineConfig({ + ...playwrightConfig, + testMatch: 'playwright/crx/assets.test.ts', + testIgnore: undefined, + projects: [ + { + name: 'chromium', + use: { + ...devices['Desktop Chromium'], + }, + }, + ], +}); diff --git a/packages/app/playwright.config.ts b/packages/app/playwright.config.ts index 24932d420..556729c4c 100644 --- a/packages/app/playwright.config.ts +++ b/packages/app/playwright.config.ts @@ -49,7 +49,7 @@ export const playwrightConfig: PlaywrightTestConfig = { }, }, ], - testIgnore: ['playwright/crx/lock.test.ts'], + testIgnore: ['playwright/crx/lock.test.ts', 'playwright/crx/assets.test.ts'], }; export default defineConfig(playwrightConfig); diff --git a/packages/e2e-assets/playwright/crx/assets.test.ts b/packages/app/playwright/crx/assets.test.ts similarity index 100% rename from packages/e2e-assets/playwright/crx/assets.test.ts rename to packages/app/playwright/crx/assets.test.ts diff --git a/packages/e2e-assets/.env.example b/packages/e2e-assets/.env.example deleted file mode 100644 index 67d8cf381..000000000 --- a/packages/e2e-assets/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -READONLY_TESTNET_ASSETS_VIEW='this mnemonic is available in the project secrets' -PORT=3000 \ No newline at end of file diff --git a/packages/e2e-assets/.gitignore b/packages/e2e-assets/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/e2e-assets/CHANGELOG.md b/packages/e2e-assets/CHANGELOG.md deleted file mode 100644 index ea46aafb9..000000000 --- a/packages/e2e-assets/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -# @fuel-wallet/e2e-assets - -## 0.44.1 diff --git a/packages/e2e-assets/load.envs.cts b/packages/e2e-assets/load.envs.cts deleted file mode 100644 index 08d15bd80..000000000 --- a/packages/e2e-assets/load.envs.cts +++ /dev/null @@ -1,44 +0,0 @@ -import { readFileSync } from 'node:fs'; -import { resolve } from 'node:path'; -import { config } from 'dotenv'; - -function getVersion() { - const packageJson = JSON.parse( - readFileSync(resolve(__dirname, './package.json')).toString() - ); - return { - version: packageJson.version, - database: packageJson.database, - }; -} - -function getEnvName() { - if (process.env.NODE_ENV === 'production') { - return '.env.production'; - } -} - -// Load from more specific env file to generic -> -// biome-ignore lint/complexity/noForEach: -[getEnvName(), '.env'].forEach((envFile) => { - if (!envFile) return; - config({ - path: resolve(__dirname, envFile), - }); -}); - -export function getPublicEnvs() { - const WHITELIST = ['NODE_ENV', 'PUBLIC_URL']; - return Object.fromEntries( - Object.entries(process.env).filter(([key]) => - WHITELIST.some((k) => k === key || key.match(/^VITE_/)) - ) - ); -} - -// Export the version to be used on database -// and application level -const versions = getVersion(); -process.env.PORT = '3000'; -process.env.VITE_APP_VERSION = process.env.VITE_APP_VERSION || versions.version; -process.env.VITE_DATABASE_VERSION = versions.database; diff --git a/packages/e2e-assets/package.json b/packages/e2e-assets/package.json deleted file mode 100644 index 2d34d97fe..000000000 --- a/packages/e2e-assets/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "@fuel-wallet/e2e-assets", - "private": true, - "version": "0.44.1", - "type": "module", - "devDependencies": { - "@playwright/test": "1.46.1" - } -} diff --git a/packages/e2e-assets/playwright.config.ts b/packages/e2e-assets/playwright.config.ts deleted file mode 100644 index 377530072..000000000 --- a/packages/e2e-assets/playwright.config.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { defineConfig } from '@playwright/test'; -import './load.envs.cts'; -const PORT = process.env.PORT || 3000; -const IS_CI = process.env.CI; - -export default defineConfig({ - workers: 2, - retries: IS_CI ? 1 : 0, - testMatch: 'playwright/**/*.test.ts', - testDir: 'playwright/', - outputDir: 'playwright-results/', - maxFailures: IS_CI ? 2 : undefined, - reporter: [ - ['list', { printSteps: true }], - ['html', { outputFolder: './playwright-html/' }], - ], - webServer: { - command: 'NODE_ENV=test pnpm -w run dev:crx', - reuseExistingServer: true, - timeout: 20000, - url: `http://localhost:${PORT}`, - }, - use: { - baseURL: `http://localhost:${PORT}/`, - trace: 'on-first-retry', - actionTimeout: 5000, - permissions: ['clipboard-read', 'clipboard-write'], - screenshot: 'only-on-failure', - headless: false, - }, -}); diff --git a/packages/e2e-assets/playwright/commons/index.ts b/packages/e2e-assets/playwright/commons/index.ts deleted file mode 100644 index ab82b019f..000000000 --- a/packages/e2e-assets/playwright/commons/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './locator'; -export * from './text'; diff --git a/packages/e2e-assets/playwright/commons/locator.ts b/packages/e2e-assets/playwright/commons/locator.ts deleted file mode 100644 index f4cec0e1f..000000000 --- a/packages/e2e-assets/playwright/commons/locator.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { Page } from '@playwright/test'; - -export function getByAriaLabel(page: Page, selector: string) { - return page.locator(`[aria-label="${selector}"]`); -} - -export async function waitAriaLabel(page: Page, selector: string) { - return page.waitForSelector(`[aria-label="${selector}"]`); -} - -export function getInputByName(page: Page, name: string) { - return page.locator(`input[name="${name}"]`); -} - -export function getInputByValue(page: Page, value: string) { - return page.locator(`input[value='${value}']`); -} diff --git a/packages/e2e-assets/playwright/commons/text.ts b/packages/e2e-assets/playwright/commons/text.ts deleted file mode 100644 index a623fbe89..000000000 --- a/packages/e2e-assets/playwright/commons/text.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { Page } from '@playwright/test'; -import { expect } from '@playwright/test'; - -export async function hasText( - page: Page, - text: string | RegExp, - position = 0, - timeout = 5000 -) { - const textFound = page.getByText(text).nth(position); - await expect(textFound).toHaveText(text, { - useInnerText: true, - timeout, - }); - return textFound; -} - -export async function hasNoText( - page: Page, - text: string | RegExp, - position = 0 -) { - return await expect(page.getByText(text).nth(position)).rejects.toThrow(); -} - -export async function hasAriaLabel(page: Page, value: string) { - const selector = await page.waitForSelector(`[aria-label="${value}"]`); - expect(await selector.getAttribute('aria-label')).toBe(value); -} diff --git a/packages/e2e-assets/tsconfig.node.json b/packages/e2e-assets/tsconfig.node.json deleted file mode 100644 index 2ed78c171..000000000 --- a/packages/e2e-assets/tsconfig.node.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "allowJs": true, - "composite": true, - "module": "ESNext", - "moduleResolution": "Node", - "allowSyntheticDefaultImports": true, - "resolveJsonModule": true, - "target": "es2017", - "outDir": "dist-crx" - }, - "include": [ - "load.envs.cts", - "env.d.ts", - "playwright/**/*.ts", - "./package.json" - ] -}