|
| 1 | +// Qa report cli tests cover source entrypoint operator errors. |
| 2 | +import { spawnSync } from "node:child_process"; |
| 3 | +import path from "node:path"; |
| 4 | +import { describe, expect, it } from "vitest"; |
| 5 | + |
| 6 | +const repoRoot = path.resolve(__dirname, "../.."); |
| 7 | + |
| 8 | +function runSourceScript(scriptPath: string, ...args: string[]) { |
| 9 | +return spawnSync(process.execPath, ["--import", "tsx", scriptPath, ...args], { |
| 10 | +cwd: repoRoot, |
| 11 | +encoding: "utf8", |
| 12 | +}); |
| 13 | +} |
| 14 | + |
| 15 | +function expectNoNodeStack(stderr: string) { |
| 16 | +expect(stderr).not.toContain("Node.js"); |
| 17 | +expect(stderr).not.toContain("\n at "); |
| 18 | +} |
| 19 | + |
| 20 | +describe("QA report source CLIs", () => { |
| 21 | +it("prints QA coverage help without an error", () => { |
| 22 | +const result = runSourceScript("scripts/qa-coverage-report.ts", "--help"); |
| 23 | + |
| 24 | +expect(result.status).toBe(0); |
| 25 | +expect(result.stdout).toContain("Usage: openclaw qa coverage"); |
| 26 | +expect(result.stderr).toBe(""); |
| 27 | +}); |
| 28 | + |
| 29 | +it("prints QA parity help without an error", () => { |
| 30 | +const result = runSourceScript("scripts/qa-parity-report.ts", "--help"); |
| 31 | + |
| 32 | +expect(result.status).toBe(0); |
| 33 | +expect(result.stdout).toContain("Usage: openclaw qa parity-report"); |
| 34 | +expect(result.stderr).toBe(""); |
| 35 | +}); |
| 36 | + |
| 37 | +it("reports unknown QA coverage options without a Node stack trace", () => { |
| 38 | +const result = runSourceScript("scripts/qa-coverage-report.ts", "--wat"); |
| 39 | + |
| 40 | +expect(result.status).toBe(1); |
| 41 | +expect(result.stdout).toBe(""); |
| 42 | +expect(result.stderr.trim()).toBe("Unknown qa coverage option: --wat"); |
| 43 | +expectNoNodeStack(result.stderr); |
| 44 | +}); |
| 45 | + |
| 46 | +it("reports unknown QA parity options without a Node stack trace", () => { |
| 47 | +const result = runSourceScript("scripts/qa-parity-report.ts", "--wat"); |
| 48 | + |
| 49 | +expect(result.status).toBe(1); |
| 50 | +expect(result.stdout).toBe(""); |
| 51 | +expect(result.stderr.trim()).toBe("Unknown qa parity-report option: --wat"); |
| 52 | +expectNoNodeStack(result.stderr); |
| 53 | +}); |
| 54 | + |
| 55 | +it("reports missing QA parity inputs without a Node stack trace", () => { |
| 56 | +const result = runSourceScript("scripts/qa-parity-report.ts"); |
| 57 | + |
| 58 | +expect(result.status).toBe(1); |
| 59 | +expect(result.stdout).toBe(""); |
| 60 | +expect(result.stderr.trim()).toBe("--candidate-summary is required."); |
| 61 | +expectNoNodeStack(result.stderr); |
| 62 | +}); |
| 63 | + |
| 64 | +it("reports missing runtime-axis QA parity summary without a Node stack trace", () => { |
| 65 | +const result = runSourceScript("scripts/qa-parity-report.ts", "--runtime-axis"); |
| 66 | + |
| 67 | +expect(result.status).toBe(1); |
| 68 | +expect(result.stdout).toBe(""); |
| 69 | +expect(result.stderr.trim()).toBe("--summary is required when --runtime-axis is set."); |
| 70 | +expectNoNodeStack(result.stderr); |
| 71 | +}); |
| 72 | +}); |