Skip to content

Commit

Permalink
test: sync crx and lock test approach
Browse files Browse the repository at this point in the history
  • Loading branch information
helciofranco committed Dec 11, 2024
1 parent 896c1a8 commit 01bc0e3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
7 changes: 2 additions & 5 deletions packages/app/playwright.crx-lock.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// biome-ignore lint/style/useNodejsImportProtocol: <explanation>
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: [
{
Expand Down
3 changes: 1 addition & 2 deletions packages/app/playwright/crx/crx.test.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -10,7 +10,6 @@ import {
hasText,
reload,
seedWallet,
visit,
waitAriaLabel,
} from '../commons';
import {
Expand Down
26 changes: 13 additions & 13 deletions packages/app/playwright/crx/lock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 01bc0e3

Please sign in to comment.