mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -06:00
fix(qa): parse qa e2e wrapper flags
This commit is contained in:
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user