37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const testEvidenceReportSchema = z
|
|
.object({
|
|
schemaVersion: z.literal(2),
|
|
sourceRoot: z.string().min(1),
|
|
status: z.enum(["PASS", "FAIL"]),
|
|
facts: z
|
|
.object({
|
|
scannedFiles: z.number().int().nonnegative(),
|
|
visualBaselines: z.number().int().nonnegative(),
|
|
sharedScenarios: z.number().int().nonnegative(),
|
|
declaredScenarioExecutions: z.number().int().nonnegative(),
|
|
executedScenarioExecutions: z.number().int().nonnegative(),
|
|
})
|
|
.strict(),
|
|
failures: z.array(z.string()),
|
|
})
|
|
.strict()
|
|
.superRefine((report, context) => {
|
|
const passed = report.status === "PASS";
|
|
if (passed !== (report.failures.length === 0)) {
|
|
context.addIssue({ code: "custom", path: ["status"], message: "status must agree with failures" });
|
|
}
|
|
if (
|
|
passed &&
|
|
report.facts.declaredScenarioExecutions !==
|
|
report.facts.executedScenarioExecutions
|
|
) {
|
|
context.addIssue({
|
|
code: "custom",
|
|
path: ["facts", "executedScenarioExecutions"],
|
|
message: "PASS requires exact declared/executed scenario agreement",
|
|
});
|
|
}
|
|
});
|