forked from longtao.wu/droboticflow
50 lines
2.0 KiB
JavaScript
50 lines
2.0 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { readFileSync } from "node:fs";
|
|
import { browserExecutableOptions } from "../../scripts/lib/browser-executable.mjs";
|
|
|
|
test("browser selection respects both explicit variables and reports invalid configuration", () => {
|
|
const exists = (p) => p === "/explicit" || p === "/legacy";
|
|
assert.deepEqual(
|
|
browserExecutableOptions({ env: { BROWSER_EXECUTABLE: "/explicit", BROWSER_PATH: "/legacy" }, exists }),
|
|
{ executablePath: "/explicit" },
|
|
);
|
|
assert.deepEqual(browserExecutableOptions({ env: { BROWSER_PATH: "/legacy" }, exists }), {
|
|
executablePath: "/legacy",
|
|
});
|
|
assert.throws(
|
|
() => browserExecutableOptions({ env: { BROWSER_EXECUTABLE: "/missing" }, exists }),
|
|
/Configured browser/,
|
|
);
|
|
});
|
|
|
|
test("installed browsers work without downloads and installed Mac Edge takes precedence over a cached bundle", () => {
|
|
assert.equal(
|
|
browserExecutableOptions({ env: {}, bundled: "/bundled", exists: (p) => p === "/bundled" }).executablePath,
|
|
"/bundled",
|
|
);
|
|
const edge = "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge";
|
|
assert.equal(
|
|
browserExecutableOptions({ env: {}, platform: "darwin", exists: (p) => p === edge }).executablePath,
|
|
edge,
|
|
);
|
|
assert.equal(
|
|
browserExecutableOptions({
|
|
env: {},
|
|
platform: "darwin",
|
|
bundled: "/bundled",
|
|
exists: (p) => p === edge || p === "/bundled",
|
|
}).executablePath,
|
|
edge,
|
|
);
|
|
assert.throws(() => browserExecutableOptions({ env: {}, exists: () => false }), /playwright install chromium/);
|
|
});
|
|
|
|
test("gated browser fixtures use the shared resolver and worktree-local Vite cache", () => {
|
|
for (const name of ["review-pool-search-replica", "review-authoring-permissions", "review-decision-failure"]) {
|
|
const source = readFileSync(new URL(`../browser/${name}.mjs`, import.meta.url), "utf8");
|
|
assert.match(source, /browserExecutableOptions\(\)/);
|
|
assert.match(source, /cacheDir: "local-data\/test-results\/vite-/);
|
|
}
|
|
});
|