Skip to content

Commit e6dc47f

Browse files
committed
fix(ci): repair Playwright E2E types and install all matrix browsers
- Use context.pages() instead of invalid pages[] indexing - Drop custom browserName worker fixture; derive browser from project name - Install chromium, firefox, and msedge in browser-test workflow Made-with: Cursor
1 parent c3fec51 commit e6dc47f

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

.github/workflows/browser-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
run: cd browser && npm ci
103103

104104
- name: Install Playwright browsers
105-
run: cd browser && npx playwright install --with-deps chromium
105+
run: cd browser && npx playwright install --with-deps chromium firefox msedge
106106

107107
- name: Download build artifacts
108108
uses: actions/download-artifact@v4

browser/e2e/helpers/launch-ext.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ export async function launchFirefoxExtension(
8282
/**
8383
* Extended test fixture that provides a fresh extension context.
8484
* Use this in your spec files instead of plain `test`.
85+
* Which browser loads the extension follows `playwright.config` project
86+
* (`--project=chromium|firefox|edge`).
8587
*
8688
* @example
8789
* import { test as extTest } from './helpers/launch-ext';
@@ -95,22 +97,29 @@ export interface ExtensionFixtures {
9597
extensionContext: BrowserContext;
9698
}
9799

98-
export const test = base.extend<ExtensionFixtures>({
99-
// Default to Chromium; override with test.use({ browserName: 'firefox' })
100-
browserName: ["chromium", { option: true }],
100+
function extensionBrowserFromProject(
101+
projectName: string,
102+
): "chromium" | "firefox" | "edge" {
103+
if (projectName === "firefox") return "firefox";
104+
if (projectName === "edge") return "edge";
105+
return "chromium";
106+
}
101107

102-
extensionContext: async ({ browserName }, use) => {
108+
export const test = base.extend<ExtensionFixtures>({
109+
extensionContext: async ({}, use, testInfo) => {
110+
const browserName = extensionBrowserFromProject(testInfo.project.name);
103111
const context =
104112
browserName === "firefox"
105113
? await launchFirefoxExtension()
106-
: await launchChromiumExtension(browserName as "chromium" | "edge");
114+
: await launchChromiumExtension(browserName);
107115

108116
await use(context);
109117
await context.close();
110118
},
111119

112120
extensionPage: async ({ extensionContext }, use) => {
113-
const page = extensionContext.pages[0] ?? await extensionContext.newPage();
121+
const pages = extensionContext.pages();
122+
const page = pages[0] ?? (await extensionContext.newPage());
114123
await use(page);
115124
},
116125
});

browser/e2e/options.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import { test, expect } from "./helpers/launch-ext";
1111

1212
test.describe("Options Page", () => {
13-
test.beforeEach(async ({ extensionPage, browserName }) => {
13+
test.beforeEach(async ({ extensionPage }) => {
1414
// Navigate to the options page using chrome-extension:// URL
1515
const pages = extensionPage.context().pages();
1616
const optionsPage = pages.find(

0 commit comments

Comments
 (0)