Add tenant contract doctor probe and automated regression test matrix

This commit is contained in:
gitea committed 2026-09-13 22:02:39 +08:00
1 parent e76af01480
commit 733ede97d9
12 files changed
+1741 -4

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
import { describe, expect, test } from "bun:test";
import { runCli } from "../runner.js";
describe("seal-use test regression CLI", () => {
test("fails with exit code 2 when unknown subaction is requested", async () => {
const result = await runCli(["test", "invalid-action"]);
expect(result.exitCode).toBe(2);
expect(result.stderr).toContain("未知的 test 子命令");
});
test("rejects when production enterprise has no bound test enterprise", async () => {
const result = await runCli(["test", "regression", "--corp", "ID01Nl1kQVYbKL"]);
expect(result.exitCode).toBe(2);
expect(result.stderr).toContain("未绑定测试靶场企业");
expect(result.stderr).toContain("硬性规定:回归测试严禁在生产环境直接运行");
});
test("executes dry-run regression preview on paired test enterprise", async () => {
const result = await runCli(["test", "regression", "--corp", "xiezihao", "--samples", "2", "--dry-run"]);
expect(result.exitCode).toBe(0);
const payload = JSON.parse(result.stdout);
expect(payload.ok).toBe(true);
expect(payload.verdict).toBe("DRY_RUN");
expect(payload.safeToPublish).toBe(true);
expect(payload.metrics.sampleCount).toBe(2);
expect(payload.sourceCorp.id).toBe("LyG3iezucw03fs");
expect(payload.targetCorp.id).toBe("xiezihao");
expect(payload.records.length).toBe(2);
expect(result.stderr).toContain("规则回归测试矩阵");
expect(result.stderr).toContain("DRY-RUN");
});
test("corps regression alias routes to test regression command", async () => {
const result = await runCli(["corps", "regression", "--corp", "xiezihao", "--samples", "2", "--dry-run"]);
expect(result.exitCode).toBe(0);
const payload = JSON.parse(result.stdout);
expect(payload.verdict).toBe("DRY_RUN");
expect(payload.targetCorp.id).toBe("xiezihao");
});
});