Files
rea/src/contracts/workflowInputContracts.test.ts

65 lines
2.3 KiB
TypeScript
Raw Permalink Normal View History

2026-07-30 04:20:10 +00:00
import { describe, expect, it } from "vitest";
import { traceJavaScriptSemanticsRequestSchema } from "./javascript/applicationWorkflowInputContracts.js";
import { JAVASCRIPT_FEATURE_TRACE_EXAMPLE } from "./javascript/javascriptApplicationWorkflowExamples.js";
2026-07-30 04:20:10 +00:00
import {
MANAGED_APPLICATION_GRAPH_EXAMPLE,
MANAGED_MEMBER_COMPARISON_EXAMPLE,
MANAGED_NATIVE_VERIFICATION_EXAMPLE,
} from "./managed/managedWorkflowExamples.js";
import {
compareManagedMembersReferenceInputSchema,
2026-07-30 04:20:10 +00:00
managedApplicationGraphReferenceInputSchema,
managedNativeVerificationReferenceInputSchema,
} from "./managed/managedWorkflowToolContracts.js";
2026-07-30 04:20:10 +00:00
describe("workflow input contracts", () => {
it("rejects application Evidence ID references and duplicate inline records", () => {
2026-07-30 04:20:10 +00:00
const query = {
seed: { kind: "literal" as const, value: "renderer" },
direction: "callers" as const,
};
expect(
traceJavaScriptSemanticsRequestSchema.safeParse({ query }).success,
).toBe(false);
2026-07-30 04:20:10 +00:00
const evidence = JAVASCRIPT_FEATURE_TRACE_EXAMPLE.application;
expect(
traceJavaScriptSemanticsRequestSchema.safeParse({
application: evidence,
application_evidence_id: evidence.evidence_id,
query,
}).success,
).toBe(false);
2026-07-30 04:20:10 +00:00
});
it("rejects duplicate inline managed Evidence records", () => {
2026-07-30 04:20:10 +00:00
expect(
compareManagedMembersReferenceInputSchema.safeParse({
left: MANAGED_MEMBER_COMPARISON_EXAMPLE.left,
right: MANAGED_MEMBER_COMPARISON_EXAMPLE.left,
2026-07-30 04:20:10 +00:00
}).success,
).toBe(false);
expect(
managedNativeVerificationReferenceInputSchema.safeParse({
managed_boundaries:
MANAGED_NATIVE_VERIFICATION_EXAMPLE.managed_boundaries,
native_observations: [
MANAGED_NATIVE_VERIFICATION_EXAMPLE.native_observations[0],
MANAGED_NATIVE_VERIFICATION_EXAMPLE.native_observations[0],
],
2026-07-30 04:20:10 +00:00
}).success,
).toBe(false);
expect(
managedApplicationGraphReferenceInputSchema.safeParse({
managed_artifact: MANAGED_APPLICATION_GRAPH_EXAMPLE.managed_members,
managed_members: MANAGED_APPLICATION_GRAPH_EXAMPLE.managed_members,
2026-07-30 04:20:10 +00:00
}).success,
).toBe(false);
expect(
managedApplicationGraphReferenceInputSchema.safeParse({}).success,
).toBe(false);
});
});