From 01bc0e396e1aa3c7719d326d6c72c4ad933fa971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9lcio=20Franco?= Date: Wed, 11 Dec 2024 22:50:13 +0700 Subject: [PATCH] test: sync crx and lock test approach --- packages/app/playwright.crx-lock.config.ts | 7 ++---- packages/app/playwright/crx/crx.test.ts | 3 +-- packages/app/playwright/crx/lock.test.ts | 26 +++++++++++----------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/packages/app/playwright.crx-lock.config.ts b/packages/app/playwright.crx-lock.config.ts index 6e9f5c710..e7eb45367 100644 --- a/packages/app/playwright.crx-lock.config.ts +++ b/packages/app/playwright.crx-lock.config.ts @@ -1,13 +1,10 @@ -// biome-ignore lint/style/useNodejsImportProtocol: -import { join } from 'path'; import { defineConfig, devices } from '@playwright/test'; import { playwrightConfig } from './playwright.config'; - -const __dirname = new URL('.', import.meta.url).pathname; +import './load.envs.cts'; export default defineConfig({ ...playwrightConfig, - testMatch: join(__dirname, './playwright/crx/lock.test.ts'), + testMatch: 'playwright/crx/lock.test.ts', testIgnore: undefined, projects: [ { diff --git a/packages/app/playwright/crx/crx.test.ts b/packages/app/playwright/crx/crx.test.ts index f69eafb23..e6a1735cc 100644 --- a/packages/app/playwright/crx/crx.test.ts +++ b/packages/app/playwright/crx/crx.test.ts @@ -1,5 +1,5 @@ import type { NetworkData, Account as WalletAccount } from '@fuel-wallet/types'; -import { type Locator, type Page, expect } from '@playwright/test'; +import { type Locator, expect } from '@playwright/test'; import { delay, @@ -10,7 +10,6 @@ import { hasText, reload, seedWallet, - visit, waitAriaLabel, } from '../commons'; import { diff --git a/packages/app/playwright/crx/lock.test.ts b/packages/app/playwright/crx/lock.test.ts index fe442764c..f7b7f97ae 100644 --- a/packages/app/playwright/crx/lock.test.ts +++ b/packages/app/playwright/crx/lock.test.ts @@ -18,6 +18,18 @@ import { test } from './utils'; test.setTimeout(360_000); test.describe('Lock FuelWallet after inactivity', () => { + test('If user opens popup it should force open a sign-up page', async ({ + context, + extensionId, + }) => { + const popupPage = await context.newPage(); + await popupPage.goto(`chrome-extension://${extensionId}/popup.html`); + const page = await context.waitForEvent('page', { + predicate: (page) => page.url().includes('sign-up'), + }); + expect(page.url()).toContain('sign-up'); + }); + test('should lock the wallet after 1 minute of inactivity (config in .env file)', async ({ context, baseURL, @@ -50,19 +62,7 @@ test.describe('Lock FuelWallet after inactivity', () => { await test.step('Create wallet', async () => { const pages = context.pages(); - let page = pages.find((page) => page.url().includes('sign-up')); - - if (!page) { - page = await context.waitForEvent('page', { - predicate: (page) => page.url().includes('sign-up'), - timeout: 10000, // Adjust timeout as needed - }); - } - - if (!page) { - throw new Error('Sign-up page did not open'); - } - + const [page] = pages.filter((page) => page.url().includes('sign-up')); await reload(page); await getElementByText(page, /Create new wallet/i).click();