Skip to content

Commit

Permalink
Added basic check to check the extension loads and welcome is shown
Browse files Browse the repository at this point in the history
  • Loading branch information
tombeckenham committed Dec 10, 2024
1 parent ba78dd6 commit cd399ca
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"format": "prettier .",
"icon": "npx iconfont-h5",
"test": "vitest",
"test:e2e": "playwright test",
"test:e2e:ui": "playwright test --ui",
"test:unit": "vitest",
"pub": "node build/release.js",
"prepare": "husky",
"preinstall": "npx only-allow pnpm",
Expand Down
11 changes: 8 additions & 3 deletions src/ui/views/WelcomePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,16 @@ const WelcomePage = () => {
margin: '24px 0 44px',
}}
>
{/* {chrome.i18n.getMessage('appDescription')} {' '} */}
{chrome.i18n.getMessage('A_crypto_wallet_on_Flow')}
<Typography sx={{ color: 'primary.light', display: 'inline' }}>
<Box
component="span"
sx={{
color: 'primary.light',
display: 'inline',
}}
>
<span> {chrome.i18n.getMessage('Explorers_Collectors_and_Gamers')}</span>
</Typography>
</Box>
</Typography>

<Button
Expand Down
43 changes: 43 additions & 0 deletions tests/wallet.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import path from 'path';

import { test, expect, chromium } from '@playwright/test';

test.describe('Extension Tests', () => {

Check failure on line 5 in tests/wallet.spec.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

tests/wallet.spec.ts

Error: Playwright Test did not expect test.describe() to be called here. Most common reasons include: - You are calling test.describe() in a configuration file. - You are calling test.describe() in a file that is imported by the configuration file. - You have two different versions of @playwright/test. This usually happens when one of the dependencies in your package.json depends on @playwright/test. ❯ TestTypeImpl._currentSuite node_modules/playwright/lib/common/testType.js:72:13 ❯ TestTypeImpl._describe node_modules/playwright/lib/common/testType.js:104:24 ❯ Function.describe node_modules/playwright/lib/transform/transform.js:288:12 ❯ tests/wallet.spec.ts:5:6
test('extension is loaded', async () => {
// Get path to extension
const pathToExtension = path.join(__dirname, '../dist');

// Launch browser with extension
const context = await chromium.launchPersistentContext('/tmp/test-user-data-dir', {
headless: false,
args: [
`--disable-extensions-except=${pathToExtension}`,
`--load-extension=${pathToExtension}`,
],
});

// for manifest v3:
let [background] = context.serviceWorkers();
if (!background) background = await context.waitForEvent('serviceworker');

// Get extension ID from service worker URL
const extensionId = background.url().split('/')[2];

// Create a new page and navigate to extension
const page = await context.newPage();

// Navigate and wait for network to be idle
await page.goto(`chrome-extension://${extensionId}/index.html#/welcome`);

// Wait for the welcome page to be fully loaded
await page.waitForSelector('.welcomeBox', { state: 'visible' });

// Check for welcome page elements
await expect(page.getByText('Welcome to Flow Wallet')).toBeVisible();
await expect(page.getByText('Create a new wallet')).toBeVisible();
await expect(page.getByText('Sync with Mobile App')).toBeVisible();

// Cleanup
await context.close();
});
});

0 comments on commit cd399ca

Please sign in to comment.