fix(qa): parse qa e2e wrapper flags

This commit is contained in:
Vincent Koc
2026-06-20 21:28:12 +02:00
parent 7b9ddbda99
commit a49f3f9362
2 changed files with 125 additions and 4 deletions
+50 -1
View File
@@ -1,7 +1,12 @@
// Qa E2E tests cover qa e2e script behavior.
import { describe, expect, it, vi } from "vitest";
import type { QaSelfCheckResult } from "../../extensions/qa-lab/api.js";
import { enablePrivateQaScriptEnv, main, resolveQaE2eOutputPath } from "../../scripts/qa-e2e.js";
import {
enablePrivateQaScriptEnv,
main,
parseQaE2eArgs,
resolveQaE2eOutputPath,
} from "../../scripts/qa-e2e.js";
function makeSelfCheckResult(status: "pass" | "fail"): QaSelfCheckResult {
return {
@@ -44,6 +49,50 @@ describe("qa-e2e script", () => {
it("resolves the default self-check report path", () => {
expect(resolveQaE2eOutputPath([])).toBe(".artifacts/qa-e2e/self-check.md");
expect(resolveQaE2eOutputPath([".artifacts/custom.md"])).toBe(".artifacts/custom.md");
expect(resolveQaE2eOutputPath(["--output", ".artifacts/custom.md"])).toBe(
".artifacts/custom.md",
);
expect(resolveQaE2eOutputPath(["--", ".artifacts/custom.md"])).toBe(".artifacts/custom.md");
});
it("prints help before enabling private QA or loading QA Lab", async () => {
const env: NodeJS.ProcessEnv = {};
const loadRuntime = vi.fn(async () => {
throw new Error("runtime loaded");
});
const writeStdout = vi.fn();
await expect(main(["--help"], { env, loadRuntime, writeStdout })).resolves.toBe(0);
expect(loadRuntime).not.toHaveBeenCalled();
expect(writeStdout).toHaveBeenCalledWith(expect.stringContaining("Usage: pnpm qa:e2e"));
expect(env.OPENCLAW_BUILD_PRIVATE_QA).toBeUndefined();
});
it("rejects unknown options before enabling private QA or loading QA Lab", async () => {
const env: NodeJS.ProcessEnv = {};
const loadRuntime = vi.fn(async () => {
throw new Error("runtime loaded");
});
await expect(main(["--wat"], { env, loadRuntime })).rejects.toThrow(
"Unknown qa:e2e option: --wat",
);
expect(loadRuntime).not.toHaveBeenCalled();
expect(env.OPENCLAW_BUILD_PRIVATE_QA).toBeUndefined();
});
it("parses explicit output flags and package-manager separators", () => {
expect(parseQaE2eArgs(["--output=.artifacts/custom.md"])).toEqual({
help: false,
outputPath: ".artifacts/custom.md",
});
expect(parseQaE2eArgs(["--", ".artifacts/from-separator.md"])).toEqual({
help: false,
outputPath: ".artifacts/from-separator.md",
});
expect(() => parseQaE2eArgs(["--output", "--help"])).toThrow("--output requires a value");
});
it.each([