fix(test): install playwright deps after host validation failure

This commit is contained in:
Vincent Koc
2026-06-04 20:24:49 -07:00
parent 72547a1ac6
commit 48c19590eb
2 changed files with 88 additions and 31 deletions

View File

@@ -193,6 +193,56 @@ describe("ensurePlaywrightChromium", () => {
);
});
it("retries with Linux system dependencies when the Chromium install reports missing host deps", () => {
const logs: string[] = [];
const spawnSync = vi
.fn()
.mockReturnValueOnce({ status: 23 })
.mockReturnValueOnce({ status: 0 })
.mockReturnValueOnce({ status: 0 });
let existsCalls = 0;
expect(
ensurePlaywrightChromium({
cwd: "/repo",
env: { CI: "1", PATH: "/bin" },
executablePath: "/cache/chromium/chrome",
existsSync: () => ++existsCalls > 1,
getuid: () => 501,
log: (line: string) => logs.push(line),
platform: "linux",
spawnSync,
stdio: "pipe",
systemExecutablePath: "",
}),
).toBe(0);
expect(spawnSync).toHaveBeenNthCalledWith(
1,
"pnpm",
["--dir", "ui", "exec", "playwright", "install", "chromium"],
{
cwd: "/repo",
env: { CI: "1", PATH: "/bin" },
shell: false,
stdio: "pipe",
windowsVerbatimArguments: undefined,
},
);
expect(spawnSync).toHaveBeenNthCalledWith(
2,
"pnpm",
["--dir", "ui", "exec", "playwright", "install", "--with-deps", "chromium"],
{
cwd: "/repo",
env: { CI: "1", PATH: "/bin" },
shell: false,
stdio: "pipe",
windowsVerbatimArguments: undefined,
},
);
expect(logs.join("\n")).toContain("installing Linux system dependencies");
});
it("does not install Linux system dependencies for an unprivileged local lane", () => {
const spawnSync = vi
.fn()