|
1 | 1 | // Qa E2E tests cover qa e2e script behavior. |
2 | | -import { describe, expect, it } from "vitest"; |
3 | | -import { enablePrivateQaScriptEnv, resolveQaE2eOutputPath } from "../../scripts/qa-e2e.js"; |
| 2 | +import { describe, expect, it, vi } from "vitest"; |
| 3 | +import type { QaSelfCheckResult } from "../../extensions/qa-lab/api.js"; |
| 4 | +import { enablePrivateQaScriptEnv, main, resolveQaE2eOutputPath } from "../../scripts/qa-e2e.js"; |
| 5 | + |
| 6 | +function makeSelfCheckResult(status: "pass" | "fail"): QaSelfCheckResult { |
| 7 | + return { |
| 8 | + outputPath: "/tmp/qa-self-check.md", |
| 9 | + report: "", |
| 10 | + checks: [{ name: "QA self-check scenario", status }], |
| 11 | + scenarioResult: { |
| 12 | + name: "QA self-check scenario", |
| 13 | + status, |
| 14 | + steps: [], |
| 15 | + }, |
| 16 | + }; |
| 17 | +} |
4 | 18 |
|
5 | 19 | describe("qa-e2e script", () => { |
6 | 20 | it("enables private QA plugin SDK subpaths before loading QA Lab", () => { |
@@ -31,4 +45,31 @@ describe("qa-e2e script", () => { |
31 | 45 | expect(resolveQaE2eOutputPath([])).toBe(".artifacts/qa-e2e/self-check.md"); |
32 | 46 | expect(resolveQaE2eOutputPath([".artifacts/custom.md"])).toBe(".artifacts/custom.md"); |
33 | 47 | }); |
| 48 | + |
| 49 | + it.each([ |
| 50 | + { status: "pass" as const, exitCode: 0 }, |
| 51 | + { status: "fail" as const, exitCode: 1 }, |
| 52 | + ])("exits with $exitCode when the self-check status is $status", async ({ status, exitCode }) => { |
| 53 | + const result = makeSelfCheckResult(status); |
| 54 | + const runQaE2eSelfCheck = vi.fn(async () => result); |
| 55 | + const isQaSelfCheckSuccessful = vi.fn(() => status === "pass"); |
| 56 | + const writeStdout = vi.fn(); |
| 57 | + const env: NodeJS.ProcessEnv = {}; |
| 58 | + |
| 59 | + await expect( |
| 60 | + main([".artifacts/custom.md"], { |
| 61 | + env, |
| 62 | + loadRuntime: async () => ({ |
| 63 | + isQaSelfCheckSuccessful, |
| 64 | + runQaE2eSelfCheck, |
| 65 | + }), |
| 66 | + writeStdout, |
| 67 | + }), |
| 68 | + ).resolves.toBe(exitCode); |
| 69 | + |
| 70 | + expect(runQaE2eSelfCheck).toHaveBeenCalledWith({ outputPath: ".artifacts/custom.md" }); |
| 71 | + expect(isQaSelfCheckSuccessful).toHaveBeenCalledWith(result); |
| 72 | + expect(writeStdout).toHaveBeenCalledWith("QA self-check report: /tmp/qa-self-check.md\n"); |
| 73 | + expect(env.OPENCLAW_BUILD_PRIVATE_QA).toBe("1"); |
| 74 | + }); |
34 | 75 | }); |
0 commit comments