fix: update integration tests for new validation error format
- 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.
This commit is contained in:
BIN
data/nodes.db
BIN
data/nodes.db
Binary file not shown.
@@ -109,16 +109,16 @@ describe('MCP Error Handling', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle empty search query', async () => {
|
it('should handle empty search query', async () => {
|
||||||
// Empty query returns empty results
|
try {
|
||||||
const response = await client.callTool({ name: 'search_nodes', arguments: {
|
await client.callTool({ name: 'search_nodes', arguments: {
|
||||||
query: ''
|
query: ''
|
||||||
} });
|
} });
|
||||||
|
expect.fail('Should have thrown an error');
|
||||||
const result = JSON.parse((response as any).content[0].text);
|
} catch (error: any) {
|
||||||
// search_nodes returns 'results' not 'nodes'
|
expect(error).toBeDefined();
|
||||||
expect(result).toHaveProperty('results');
|
expect(error.message).toContain("search_nodes: Validation failed:");
|
||||||
expect(Array.isArray(result.results)).toBe(true);
|
expect(error.message).toContain("query: query cannot be empty");
|
||||||
expect(result.results).toHaveLength(0);
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle non-existent node types', async () => {
|
it('should handle non-existent node types', async () => {
|
||||||
@@ -149,19 +149,19 @@ describe('MCP Error Handling', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle malformed workflow structure', async () => {
|
it('should handle malformed workflow structure', async () => {
|
||||||
const response = await client.callTool({ name: 'validate_workflow', arguments: {
|
try {
|
||||||
workflow: {
|
await client.callTool({ name: 'validate_workflow', arguments: {
|
||||||
// Missing required 'nodes' array
|
workflow: {
|
||||||
connections: {}
|
// Missing required 'nodes' array
|
||||||
}
|
connections: {}
|
||||||
} });
|
}
|
||||||
|
} });
|
||||||
// Should return validation error, not throw
|
expect.fail('Should have thrown an error');
|
||||||
const validation = JSON.parse((response as any).content[0].text);
|
} catch (error: any) {
|
||||||
expect(validation.valid).toBe(false);
|
expect(error).toBeDefined();
|
||||||
expect(validation.errors).toBeDefined();
|
expect(error.message).toContain("validate_workflow: Validation failed:");
|
||||||
expect(validation.errors.length).toBeGreaterThan(0);
|
expect(error.message).toContain("workflow.nodes: workflow.nodes is required");
|
||||||
expect(validation.errors[0].message).toContain('nodes');
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle circular workflow references', async () => {
|
it('should handle circular workflow references', async () => {
|
||||||
@@ -501,7 +501,8 @@ describe('MCP Error Handling', () => {
|
|||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
expect(error).toBeDefined();
|
expect(error).toBeDefined();
|
||||||
// The error now properly validates required parameters
|
// 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");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user