test: consolidate redundant assertions into boundary workflows
Remove getter, enum, cloned-projection, cache-identity, and obsolete profile assertions along with the shadow JSON Schema engine and dead test-only APIs. Retain producer, filesystem, SDK, lifecycle, integrity, and malformed-format coverage. Document the priority of real end-to-end workflows, boundary integration, and producer goldens.
This commit is contained in:
@@ -3,7 +3,6 @@ import { Ajv2020 } from "ajv/dist/2020.js";
|
||||
import { expect, it } from "vitest";
|
||||
import { z } from "zod";
|
||||
|
||||
import { inlineLocalJsonSchemaReferences } from "../../tests/fixtures/localJsonSchemaReferences.js";
|
||||
import { toolContract } from "./toolContracts.js";
|
||||
import { toolOutputSchemaWithMetadata } from "./toolSchemaMetadata.js";
|
||||
|
||||
@@ -52,35 +51,9 @@ it.each(["draft-2020-12", "draft-07"] as const)(
|
||||
expect(canonical.safeParse(valid).success).toBe(true);
|
||||
for (const sample of samples)
|
||||
expect(validate(sample)).toBe(canonical.safeParse(sample).success);
|
||||
expect(inlineLocalJsonSchemaReferences(advertised)).toEqual(
|
||||
inlineLocalJsonSchemaReferences(
|
||||
canonical["~standard"].jsonSchema.output({ target }),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("keeps schema data containing reference-shaped objects untouched", () => {
|
||||
const literal = { $ref: "https://example.invalid/value" };
|
||||
const expanded = inlineLocalJsonSchemaReferences({
|
||||
$defs: {
|
||||
"a/b": {
|
||||
type: "object",
|
||||
properties: { $defs: { const: literal } },
|
||||
examples: [literal],
|
||||
},
|
||||
},
|
||||
$ref: "#/$defs/a~1b",
|
||||
description: "Keep the caller-facing annotation",
|
||||
});
|
||||
expect(expanded).toEqual({
|
||||
type: "object",
|
||||
properties: { $defs: { const: literal } },
|
||||
examples: [literal],
|
||||
description: "Keep the caller-facing annotation",
|
||||
});
|
||||
});
|
||||
|
||||
it.each(["draft-2020-12", "draft-07"] as const)(
|
||||
"preserves layered native-selector string patterns through %s references",
|
||||
(target) => {
|
||||
@@ -110,68 +83,5 @@ it.each(["draft-2020-12", "draft-07"] as const)(
|
||||
const sample = { before: value, after: "setFoo:" };
|
||||
expect(validate(sample)).toBe(canonical.safeParse(sample).success);
|
||||
}
|
||||
expect(inlineLocalJsonSchemaReferences(advertised)).toEqual(
|
||||
inlineLocalJsonSchemaReferences(
|
||||
canonical["~standard"].jsonSchema.output({ target }),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("rejects unresolved and cyclic references rather than concealing schema drift", () => {
|
||||
expect(() =>
|
||||
inlineLocalJsonSchemaReferences({ $ref: "#/$defs/missing" }),
|
||||
).toThrow("Missing schema reference");
|
||||
expect(() =>
|
||||
inlineLocalJsonSchemaReferences({
|
||||
$defs: { loop: { $ref: "#/$defs/loop" } },
|
||||
$ref: "#/$defs/loop",
|
||||
}),
|
||||
).toThrow("Recursive schema reference");
|
||||
});
|
||||
|
||||
it("intersects referenced numeric bounds and rejects conflicting validation keywords", () => {
|
||||
expect(
|
||||
inlineLocalJsonSchemaReferences({
|
||||
$defs: { bounded: { type: "number", minimum: 1, maximum: 10 } },
|
||||
$ref: "#/$defs/bounded",
|
||||
minimum: 0,
|
||||
maximum: 9,
|
||||
}),
|
||||
).toEqual({ type: "number", minimum: 1, maximum: 9 });
|
||||
expect(() =>
|
||||
inlineLocalJsonSchemaReferences({
|
||||
$defs: { strict: { type: "object" } },
|
||||
$ref: "#/$defs/strict",
|
||||
type: "string",
|
||||
}),
|
||||
).toThrow("Conflicting schema reference sibling: type");
|
||||
});
|
||||
|
||||
it("preserves strict-object evaluation scope across references and singleton intersections", () => {
|
||||
const strict = {
|
||||
type: "object",
|
||||
properties: { value: { type: "string" } },
|
||||
additionalProperties: false,
|
||||
};
|
||||
const schemas = [
|
||||
{
|
||||
$defs: { strict },
|
||||
$ref: "#/$defs/strict",
|
||||
additionalProperties: false,
|
||||
},
|
||||
{ allOf: [strict], additionalProperties: false },
|
||||
];
|
||||
for (const schema of schemas) {
|
||||
const expanded = z
|
||||
.record(z.string(), z.unknown())
|
||||
.parse(inlineLocalJsonSchemaReferences(schema));
|
||||
const ajv = new Ajv2020({ strict: false });
|
||||
const original = ajv.compile(schema);
|
||||
const normalized = ajv.compile(expanded);
|
||||
expect(original({})).toBe(true);
|
||||
expect(original({ value: "kept" })).toBe(false);
|
||||
for (const sample of [{}, { value: "kept" }, { unexpected: true }, null])
|
||||
expect(normalized(sample)).toBe(original(sample));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user