Every browser-driven check in this repo launched Chromium and nothing else.
That is fine for most of the web client, whose behavior is React and Mantine.
It is not fine for the MCP Apps sandbox, which is built out of the primitives
that genuinely diverge between engines: a CSP <meta> injected as the first
<head> child of a srcdoc document, a nested sandboxed iframe, a
Permissions-Policy allow attribute, and postMessage origin discipline across
those two frames. Nothing else covers that surface — sandbox-csp.test.ts
asserts which policy STRING is built (environment-independent by
construction), and no Storybook story reaches the sandbox at all, since all
three App stories use a data: placeholder iframe and a mock bridge.
The engine is now a parameter:
SMOKE_BROWSER=webkit npm run smoke:web:app
SMOKE_BROWSER=firefox npm run smoke:web:engine # all three smokes
Unset means chromium, so `npm run ci` and `npm run smoke` are unchanged. An
unrecognized value is an error rather than a fallback — falling back would
report a green Chromium run under a job labelled "webkit", claiming coverage
that never ran — and a launch failure names the engine that failed and its own
`playwright install` invocation.
Selection, launching, and the fatal-vs-benign page-diagnostics split now live
in one shared scripts/lib/headless-browser.mjs. The three smokes had each
hand-rolled the diagnostics split and two had their own copy of loadChromium;
pack:verify goes through the same helper, pinned to Chromium explicitly since
it is a packaging check.
The npm scripts drop their `cd clients/web && npx playwright install chromium`
prefix for scripts/install-smoke-browser.mjs. The engine is a variable now, and
a ${VAR:-default} expansion does not expand under Windows' cmd.exe; npx is also
a .cmd shim there that a shell-free spawn cannot start, so this resolves the
Playwright CLI through resolveNodeBin — the #1939 problem solved the #1939 way.
CI gains a `Sandbox smokes (<engine>)` matrix job rather than matrixing `build`,
which also runs validate, the coverage gate, two verify gates and Storybook —
all engine-independent. Both publish jobs now need it.
WebKit is supported by the tooling but deliberately NOT in the CI matrix yet:
pointing the smokes at it immediately found #2132, a pre-existing Safari
incompatibility in the web client's SSE transport that strands the last message
on /api/mcp/events, so an MCP App never leaves "loading". That is a product bug
affecting real Safari users, with its own diagnosis and a verified fix, and it
is not a matrix change. Adding `webkit` here is a one-word diff once it lands.
An engine is either green in CI or absent from it; a continue-on-error job would
report coverage nobody is held to.
Signed-off-by: cliffhall <cliff@futurescale.com>
84 lines
2.9 KiB
JavaScript
84 lines
2.9 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Fetch the Playwright browser binary a headless web smoke is about to launch
|
|
* (#2086).
|
|
*
|
|
* This replaces the `cd clients/web && npx playwright install chromium` prefix
|
|
* each smoke's npm script used to carry. Two reasons it is a script rather than
|
|
* a longer npm-script line:
|
|
*
|
|
* - The engine is now a variable. `npx playwright install ${SMOKE_BROWSER:-…}`
|
|
* is a POSIX-shell expansion that does not expand under Windows' `cmd.exe`,
|
|
* which npm uses there — it would silently try to install a browser named
|
|
* `${SMOKE_BROWSER:-chromium}`.
|
|
* - `npx` is a `.cmd` shim on Windows, which a shell-free spawn cannot start.
|
|
* `resolveNodeBin` walks to the JS entry behind the package's `bin` and runs
|
|
* it with `process.execPath` instead — the same fix #1939 made for the
|
|
* verify scripts, and it keeps the resolution pinned to the repo's own
|
|
* Playwright rather than whatever `npx` might fetch.
|
|
*
|
|
* Usage: `node scripts/install-smoke-browser.mjs [engine]`. With no argument the
|
|
* engine comes from `SMOKE_BROWSER` (default `chromium`); pass one explicitly
|
|
* where the consumer's engine is fixed regardless of that variable, as
|
|
* `pack:verify` does.
|
|
*/
|
|
|
|
import { spawnSync } from "node:child_process";
|
|
import { join, resolve } from "node:path";
|
|
import {
|
|
SUPPORTED_BROWSERS,
|
|
resolveBrowserName,
|
|
} from "./lib/headless-browser.mjs";
|
|
import { resolveNodeBin } from "./lib/resolve-node-bin.mjs";
|
|
|
|
const repoRoot = resolve(import.meta.dirname, "..");
|
|
const webDir = join(repoRoot, "clients", "web");
|
|
|
|
const requested = process.argv[2];
|
|
let browserName;
|
|
try {
|
|
if (requested === undefined) {
|
|
browserName = resolveBrowserName();
|
|
} else if (SUPPORTED_BROWSERS.includes(requested)) {
|
|
browserName = requested;
|
|
} else {
|
|
throw new Error(
|
|
`unsupported browser "${requested}" — expected one of ${SUPPORTED_BROWSERS.join(", ")}`,
|
|
);
|
|
}
|
|
} catch (err) {
|
|
console.error(
|
|
`install-smoke-browser: ${err instanceof Error ? err.message : String(err)}`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
let cli;
|
|
try {
|
|
cli = resolveNodeBin("playwright", "playwright", webDir);
|
|
} catch (err) {
|
|
console.error(
|
|
"install-smoke-browser: could not resolve the Playwright CLI from clients/web — " +
|
|
`run \`npm install\` at the repo root (${err instanceof Error ? err.message : String(err)})`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
// `install` is a no-op when the binary is already present, so this is cheap on
|
|
// a warm machine and on a CI runner whose Playwright cache was restored.
|
|
const result = spawnSync(process.execPath, [cli, "install", browserName], {
|
|
cwd: webDir,
|
|
stdio: "inherit",
|
|
});
|
|
if (result.error) {
|
|
console.error(
|
|
`install-smoke-browser: could not run the Playwright CLI: ${result.error.message}`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
if (result.status !== 0) {
|
|
console.error(
|
|
`install-smoke-browser: \`playwright install ${browserName}\` exited ${result.status}`,
|
|
);
|
|
process.exit(result.status ?? 1);
|
|
}
|