From 567b54eaf72d571d21ccb1f511d0668125aa1535 Mon Sep 17 00:00:00 2001 From: czlonkowski <56956555+czlonkowski@users.noreply.github.com> Date: Thu, 7 Aug 2025 21:21:17 +0200 Subject: [PATCH] fix: update integration tests for new validation error format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed 3 failing integration tests in error-handling.test.ts - Tests now expect structured validation error format - Updated expectations for empty search query, malformed workflow, and missing parameters - All integration tests now passing (249 tests total) The new validation system produces more detailed error messages in the format 'tool_name: Validation failed: • field: message' which is more helpful for debugging and AI agents. --- data/nodes.db | Bin 12296192 -> 12296192 bytes .../mcp-protocol/error-handling.test.ts | 49 +++++++++--------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/data/nodes.db b/data/nodes.db index ca64d1358bca013e94fb7cdc41809eaccee75609..2d23c534e9097a8100ff88a7b85e98739afca621 100644 GIT binary patch delta 709 zcmWmARa2D#7)9alaKu)Qo!H&2*xlWVf!(_7R;*f^wLix3C-}N&o|%2U z3M>C)7lv!i>t}u^Nv)qrk}gh?Bs)oRH(c-0FDvu=b3vn2(b#meuUArKsZ?=MWmeNu z`RTLy=~T!H|9_Q`9jbS=pFimzM)^}9|nYhVNe(xhLq>0 z^Ip8mM2i2b5?Lxjd3mN_*xwv0^GYj+mXv zGDW7!G?^|lWTwoL*)m7w$~>7b3uK`zlEtz_mP)=XljX8PR!V`alGUQlX6N<%NbG5$~ieN z7v!Q`lFM>MuF5sJE;pn|ZptmWEqCOu+>`tAK#Jv|Jd(#!B2VP0Jd@}0LQ3VOypq@Q iM&8Ohc`qO2qkNLj@tIt0SvJW}{ delta 846 zcmWmAXIISu0LStF?cS`YE21*8_ef^8?43O_viIKm5@n`j3mIjFQrz&Q7vXg{UVsNa ze&>A7`91!|ntvz8D9cPut_p&rA3+d~2SJb+1Zls@hvXzASJfA$g(~vG84abO#!x6; z(VUQ8R1hvH2!}}E|BsMJ3tG~O*0dpswzMOe6r!{zl@4?yjZSnXoeVPRLRY%coh*9L zlV0?u4}IxJe+Dp+K@4UHLm9?!vKc`RBN@eL#xRy~@q%z}b!|=IglKVdZcX#}s;Dae z7g4B*%6POc_fJYq_RnZ}exxK4o4`aSF_|e$Wg2-*X9hEw#cbv)hZbwRpOUh<09R8zwn-tvz3e4v((eBv{8)boV~8u`jM;xzG{AMr@+=ijV<4c8rb diff --git a/tests/integration/mcp-protocol/error-handling.test.ts b/tests/integration/mcp-protocol/error-handling.test.ts index 02649e8..4012c32 100644 --- a/tests/integration/mcp-protocol/error-handling.test.ts +++ b/tests/integration/mcp-protocol/error-handling.test.ts @@ -109,16 +109,16 @@ describe('MCP Error Handling', () => { }); it('should handle empty search query', async () => { - // Empty query returns empty results - const response = await client.callTool({ name: 'search_nodes', arguments: { - query: '' - } }); - - const result = JSON.parse((response as any).content[0].text); - // search_nodes returns 'results' not 'nodes' - expect(result).toHaveProperty('results'); - expect(Array.isArray(result.results)).toBe(true); - expect(result.results).toHaveLength(0); + try { + await client.callTool({ name: 'search_nodes', arguments: { + query: '' + } }); + expect.fail('Should have thrown an error'); + } catch (error: any) { + expect(error).toBeDefined(); + expect(error.message).toContain("search_nodes: Validation failed:"); + expect(error.message).toContain("query: query cannot be empty"); + } }); it('should handle non-existent node types', async () => { @@ -149,19 +149,19 @@ describe('MCP Error Handling', () => { }); it('should handle malformed workflow structure', async () => { - const response = await client.callTool({ name: 'validate_workflow', arguments: { - workflow: { - // Missing required 'nodes' array - connections: {} - } - } }); - - // Should return validation error, not throw - const validation = JSON.parse((response as any).content[0].text); - expect(validation.valid).toBe(false); - expect(validation.errors).toBeDefined(); - expect(validation.errors.length).toBeGreaterThan(0); - expect(validation.errors[0].message).toContain('nodes'); + try { + await client.callTool({ name: 'validate_workflow', arguments: { + workflow: { + // Missing required 'nodes' array + connections: {} + } + } }); + expect.fail('Should have thrown an error'); + } catch (error: any) { + expect(error).toBeDefined(); + expect(error.message).toContain("validate_workflow: Validation failed:"); + expect(error.message).toContain("workflow.nodes: workflow.nodes is required"); + } }); it('should handle circular workflow references', async () => { @@ -501,7 +501,8 @@ describe('MCP Error Handling', () => { } catch (error: any) { expect(error).toBeDefined(); // The error now properly validates required parameters - expect(error.message).toContain("Missing required parameters"); + expect(error.message).toContain("search_nodes: Validation failed:"); + expect(error.message).toContain("query: query is required"); } });