From e40773bbd397174530dc077c46df755da966884d Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 5 Dec 2026 10:38:51 +0800 Subject: [PATCH] test(mcp): share output-schema client fixtures (#16903) --- .../boundary/mcp/outputSchemaProfile.test.ts | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tests/boundary/mcp/outputSchemaProfile.test.ts b/tests/boundary/mcp/outputSchemaProfile.test.ts index 464169b5c1b..24db7f17fb1 100644 --- a/tests/boundary/mcp/outputSchemaProfile.test.ts +++ b/tests/boundary/mcp/outputSchemaProfile.test.ts @@ -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();