Skip to content

Commit

Permalink
refactor(e2e-assets): streamline asset tests and enhance page navigat…
Browse files Browse the repository at this point in the history
…ion handling
  • Loading branch information
nelitow committed Dec 12, 2024
1 parent 466f3d4 commit f564556
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
8 changes: 0 additions & 8 deletions packages/e2e-assets/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,4 @@ export default defineConfig({
screenshot: 'only-on-failure',
headless: false,
},
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chromium'],
},
},
],
});
37 changes: 25 additions & 12 deletions packages/e2e-assets/playwright/crx/assets.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { expect, test } from '@playwright/test';
import { type Page, expect, test } from '@playwright/test';
import { hasText, waitAriaLabel } from '../commons';

test.describe('Check assets', () => {
test('should show valid asset values', async ({ page }) => {
await page.goto('http://localhost:3000');
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
await page.goto('http://localhost:3000', {
waitUntil: 'domcontentloaded',
});

await test.step('Import wallet', async () => {
await page.getByRole('heading', { name: 'Import seed phrase' }).click();
Expand All @@ -13,10 +17,10 @@ test.describe('Check assets', () => {

const words = mnemonic.split(' ');
for (const [index, word] of words.entries()) {
console.log(`Filling word ${index + 1}: ${word}`);
const locator = page.locator('div').filter({
hasText: new RegExp(`^${index + 1}$`),
});
console.log(`Filling word ${index + 1}: ${word}`);
const input = locator.getByLabel('Type your text');
await input.fill(word);
console.log(`Filled word ${index + 1}`);
Expand All @@ -32,14 +36,23 @@ test.describe('Check assets', () => {
await page.getByLabel('Selected Network').click();
await page.getByText('Fuel Sepolia Testnet').click();
await waitAriaLabel(page, 'Account 1 selected');
expect(
await page.getByText('0.002000', { exact: true }).isVisible()
).toBeTruthy();
expect(
await page.getByText('USDCIcon AlertTriangle').isVisible()
).toBeTruthy();
expect(await page.getByText('1 SCAM').isVisible()).toBeTruthy();
await page.close();
});
});

test.describe.configure({ mode: 'parallel' });
test('should show valid asset value 0.002000', async () => {
expect(
await page.getByText('0.002000', { exact: true }).isVisible()
).toBeTruthy();
});

test('should show USDCIcon AlertTriangle', async () => {
expect(
await page.getByText('USDCIcon AlertTriangle').isVisible()
).toBeTruthy();
});

test('should show 1 SCAM', async () => {
expect(await page.getByText('1 SCAM').isVisible()).toBeTruthy();
});
});

0 comments on commit f564556

Please sign in to comment.