test(mcp): share output-schema client fixtures (#16903)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-05 10:38:51 +08:00
1 parent 4428de6a35
commit e40773bbd3
1 file changed
+10 -16
+10 -16
View File
@@ -33,14 +33,17 @@ const createServer = (outputSchemaProfile: McpOutputSchemaProfile) =>
outputSchemaProfile,
);
const createSchemaClient = (name: string) =>
new Client(
{ name, version: "1" },
{ jsonSchemaValidator: createMcpSchemaValidation() },
);
it("rejects canonical-invalid output when output schema advertisements are off", async () => {
const server = createServer("off");
const [clientTransport, serverTransport] =
InMemoryTransport.createLinkedPair();
const client = new Client(
{ name: "schema-profile-test", version: "1" },
{ jsonSchemaValidator: createMcpSchemaValidation() },
);
const client = createSchemaClient("schema-profile-test");
const contract = {
...toolContract("comment"),
name: "output_schema_fixture",
@@ -86,10 +89,7 @@ it("strips nested guidance from compact output schemas and preserves result fiel
);
const [clientTransport, serverTransport] =
InMemoryTransport.createLinkedPair();
const client = new Client(
{ name: "compact-output-test", version: "1" },
{ jsonSchemaValidator: createMcpSchemaValidation() },
);
const client = createSchemaClient("compact-output-test");
const contract = {
...toolContract("comment"),
name: "compact_output_schema_fixture",
@@ -211,10 +211,7 @@ it("rejects canonical-invalid output that the reduced advertisement accepts", as
const server = createServer("compact");
const [clientTransport, serverTransport] =
InMemoryTransport.createLinkedPair();
const client = new Client(
{ name: "reduced-output-test", version: "1" },
{ jsonSchemaValidator: createMcpSchemaValidation() },
);
const client = createSchemaClient("reduced-output-test");
const contract = {
...toolContract("comment"),
name: "reduced_output_schema_fixture",
@@ -331,10 +328,7 @@ it("omits output schemas by default and still delivers validated structured resu
{ kind: "session", session },
{ environment: { HOME: process.env.HOME }, logger: silentLogger },
);
const client = new Client(
{ name: "default-output-profile", version: "1" },
{ jsonSchemaValidator: createMcpSchemaValidation() },
);
const client = createSchemaClient("default-output-profile");
onTestFinished(async () => {
await client.close();
await server.close();