Skip to content

Commit e47ad78

Browse files
wildleo91claude
andcommitted
fix(e2e): platform-aware chromium resolver + pin playwright CLI (Phase 0.3)
`tests/e2e/lib_helpers.cjs` and `tests/e2e/test_task8_modularization.mjs` both hard-coded `process.env.LOCALAPPDATA + "/ms-playwright/chromium-1208/ chrome-win64/chrome.exe"`. On a Linux CI runner LOCALAPPDATA is undefined, so chromium.launch() was asked to start `"undefined/ms-playwright/.../chrome.exe"` — Windows binary path on Linux, double bug. Latest e2e-smoke.yml run (25877702139) failed at the first smoke step with exactly this error. Replaced the hard-coded constant with a `resolveChromiumExecutable()` helper: 1. honor `PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH` env override 2. on Windows with LOCALAPPDATA set, preserve the legacy path so local dev keeps working 3. otherwise return `undefined` and let `playwright-core` auto-resolve from the standard `~/.cache/ms-playwright/` location Launch site only sets `executablePath` when the resolver returns a value, so playwright-core can use its bundled discovery on Linux CI. Second bug surfaced while reading the workflow log: `npx playwright install` was unpinned and pulled the latest playwright (1.60.0 in the failed run) — but package.json pins `playwright-core@1.59.1`. The CLI would have installed chromium at a revision playwright-core wouldn't look for at runtime. Pinned all three browser-install workflow steps (`e2e-smoke.yml`, `e2e-full.yml`, `a11y-audit.yml`) to `npx playwright@1.59.1 install --with-deps chromium` so the installed chromium revision matches what playwright-core resolves. Verification: - Local Windows: `node -e` of the resolver returns the existing `C:\Users\PC\AppData\Local\ms-playwright\chromium-1208\chrome-win64\ chrome.exe` path — local dev behavior unchanged. - Linux CI: resolver returns `undefined`, launch options omit `executablePath`, playwright-core discovers chromium installed by `npx playwright@1.59.1 install`. - Workflow green on next push will be the ground-truth signal; this commit is being pushed specifically to exercise it. Per Phase 0.3 of `docs/PUBLIC_RELEASE_PLAN.md` ("Fix e2e-smoke.yml Playwright `undefined` env var failure — Windows binary path appears on Linux runner"). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 53876d4 commit e47ad78

5 files changed

Lines changed: 47 additions & 7 deletions

File tree

.github/workflows/a11y-audit.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ jobs:
5252
run: npm ci
5353

5454
- name: Install Playwright browsers
55-
run: npx playwright install --with-deps chromium
55+
# Pin to the same minor as playwright-core in package.json
56+
# (currently 1.59.1) so the installed chromium revision matches
57+
# what playwright-core resolves at runtime. See e2e-smoke.yml
58+
# for the full explanation.
59+
run: npx playwright@1.59.1 install --with-deps chromium
5660

5761
- name: Start Splunk container
5862
run: docker compose up -d

.github/workflows/e2e-full.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ jobs:
6262
run: npm ci
6363

6464
- name: Install Playwright browsers
65-
run: npx playwright install --with-deps chromium
65+
# Pin to the same minor as playwright-core in package.json
66+
# (currently 1.59.1) so the installed chromium revision matches
67+
# what playwright-core resolves at runtime. See e2e-smoke.yml
68+
# for the full explanation.
69+
run: npx playwright@1.59.1 install --with-deps chromium
6670

6771
- name: Start Splunk container
6872
run: docker compose up -d

.github/workflows/e2e-smoke.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ jobs:
6464
# — we need an explicit install. Chromium is the only browser
6565
# tests/e2e/ uses (per lib_helpers.cjs), so we install just it
6666
# to keep CI runner provisioning fast.
67-
run: npx playwright install --with-deps chromium
67+
#
68+
# MUST pin to the same minor as playwright-core in package.json
69+
# (currently 1.59.1). Without a pin, `npx playwright install`
70+
# downloads the latest `playwright` CLI which installs a chromium
71+
# revision that playwright-core@1.59.x won't find at runtime.
72+
run: npx playwright@1.59.1 install --with-deps chromium
6873

6974
- name: Start Splunk container
7075
run: docker compose up -d

tests/e2e/lib_helpers.cjs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
/**
22
* Shared helpers for multi-role E2E tests.
33
*/
4+
const path = require("node:path");
45
const { chromium } = require("playwright-core");
5-
const CHROME = process.env.LOCALAPPDATA + "/ms-playwright/chromium-1208/chrome-win64/chrome.exe";
6+
7+
function resolveChromiumExecutable() {
8+
if (process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH) {
9+
return process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH;
10+
}
11+
if (process.platform === "win32" && process.env.LOCALAPPDATA) {
12+
return path.join(process.env.LOCALAPPDATA, "ms-playwright", "chromium-1208", "chrome-win64", "chrome.exe");
13+
}
14+
return undefined;
15+
}
16+
17+
const CHROME = resolveChromiumExecutable();
618
const BASE = "http://localhost:8000";
719
const REST = "https://localhost:8089";
820

@@ -40,7 +52,9 @@ function summary(label) {
4052
}
4153

4254
async function createSession(user, pass) {
43-
const browser = await chromium.launch({ headless: true, executablePath: CHROME });
55+
const launchOpts = { headless: true };
56+
if (CHROME) launchOpts.executablePath = CHROME;
57+
const browser = await chromium.launch(launchOpts);
4458
const context = await browser.newContext({ ignoreHTTPSErrors: true, viewport: { width: 1440, height: 900 } });
4559
const page = await context.newPage();
4660
page.__errors = [];

tests/e2e/test_task8_modularization.mjs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,19 @@
1616
* 9. Edge cases: concurrent actions, unusual characters, empty state
1717
*/
1818

19+
import path from "node:path";
1920
import { chromium } from "playwright-core";
2021

22+
function resolveChromiumExecutable() {
23+
if (process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH) {
24+
return process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH;
25+
}
26+
if (process.platform === "win32" && process.env.LOCALAPPDATA) {
27+
return path.join(process.env.LOCALAPPDATA, "ms-playwright", "chromium-1208", "chrome-win64", "chrome.exe");
28+
}
29+
return undefined;
30+
}
31+
2132
const BASE = "http://localhost:8000";
2233
const LOGIN_URL = `${BASE}/en-US/account/login`;
2334
const WM_URL = `${BASE}/en-US/app/wl_manager/whitelist_manager`;
@@ -94,8 +105,10 @@ async function getConsoleErrors() {
94105
// Main test runner
95106
// ══════════════════════════════════════════════════════════════════
96107
async function run() {
97-
const chromePath = process.env.LOCALAPPDATA + "/ms-playwright/chromium-1208/chrome-win64/chrome.exe";
98-
browser = await chromium.launch({ headless: true, executablePath: chromePath });
108+
const chromePath = resolveChromiumExecutable();
109+
const launchOpts = { headless: true };
110+
if (chromePath) launchOpts.executablePath = chromePath;
111+
browser = await chromium.launch(launchOpts);
99112
context = await browser.newContext({
100113
ignoreHTTPSErrors: true,
101114
viewport: { width: 1440, height: 900 }

0 commit comments

Comments
 (0)