mirror of
https://github.com/hanzoai/extension.git
synced 2026-10-31 21:57:06 +00:00
Nothing ran e2e/, so a sidebar that threw on its first paint reached main with every check green. ci.yml now drives the built extension in Chromium after the bundle budgets. publish.yml builds, runs the unit suite, the budgets and the e2e, and only then reads credentials and uploads. Its summary says the checks failed, rather than blaming missing credentials. The fixture opened a headed window, which a runner with no display cannot do. It now uses the chromium channel, whose headless mode loads extensions, and takes Playwright's headless option, so --headed still shows the window. Headless, the suite is 76 passed and 2 skipped (the live IAM login, which needs a password); with CI set it is 74 and 4. turn.spec fails headless against the old Chat and passes on the fixed one. Co-authored-by: Hanzo Dev <[email protected]>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { test as base, chromium, type BrowserContext } from '@playwright/test';
|
|
import path from 'path';
|
|
|
|
const extensionPath = path.resolve(__dirname, '../../../dist/chrome');
|
|
|
|
// Custom fixture that launches a persistent browser context with the extension loaded.
|
|
//
|
|
// The `chromium` channel is the full browser, and its headless mode loads
|
|
// extensions; the default headless shell does not. So the suite runs on a
|
|
// runner with no display, and `--headed` still opens the window.
|
|
export const test = base.extend<{
|
|
context: BrowserContext;
|
|
extensionId: string;
|
|
}>({
|
|
context: async ({ headless }, use) => {
|
|
const context = await chromium.launchPersistentContext('', {
|
|
channel: 'chromium',
|
|
headless,
|
|
args: [
|
|
`--disable-extensions-except=${extensionPath}`,
|
|
`--load-extension=${extensionPath}`,
|
|
'--no-first-run',
|
|
'--disable-default-apps',
|
|
'--disable-gpu',
|
|
],
|
|
});
|
|
await use(context);
|
|
await context.close();
|
|
},
|
|
|
|
extensionId: async ({ context }, use) => {
|
|
// Wait for the service worker to register
|
|
let [background] = context.serviceWorkers();
|
|
if (!background) {
|
|
background = await context.waitForEvent('serviceworker');
|
|
}
|
|
|
|
// Extract extension ID from service worker URL
|
|
// URL format: chrome-extension://<id>/background.js
|
|
const extensionId = background.url().split('/')[2];
|
|
await use(extensionId);
|
|
},
|
|
});
|
|
|
|
export { expect } from '@playwright/test';
|