mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-06 13:33:11 +00:00
refactor(integration): update Phase 2 tests to use MCP handlers
**Critical Fix**: Tests now properly test the MCP handler layer (the actual product) instead of raw API client. **Changes**: - All 15 tests now use `handleCreateWorkflow()` MCP handler - Tests validate `McpToolResponse` structure (`success`, `data`, `error`) - Created `mcp-context.ts` helper for configuring InstanceContext - Fixed ERROR_HANDLING_WORKFLOW to add main connection (MCP validation requirement) - Updated error/edge case tests to expect validation failures (correct MCP behavior) **MCP Handler Validation**: - Error scenarios now correctly expect `success: false` with validation errors - Edge cases updated to reflect MCP handler's proper pre-validation - Documents that MCP validation is CORRECT behavior (catches errors early) **Test Results**: All 15 scenarios passing - 8 valid workflow tests → expect `success: true` - 7 validation tests (errors/edge cases) → expect `success: false` **Why This Matters**: AI assistants interact with MCP handlers, not raw API client. Testing the wrong layer would miss MCP-specific logic and validation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -222,6 +222,7 @@ export const ERROR_HANDLING_WORKFLOW: Partial<Workflow> = {
|
||||
main: [[{ node: 'HTTP Request', type: 'main', index: 0 }]]
|
||||
},
|
||||
'HTTP Request': {
|
||||
main: [[{ node: 'Handle Error', type: 'main', index: 0 }]],
|
||||
error: [[{ node: 'Handle Error', type: 'main', index: 0 }]]
|
||||
}
|
||||
},
|
||||
|
||||
14
tests/integration/n8n-api/utils/mcp-context.ts
Normal file
14
tests/integration/n8n-api/utils/mcp-context.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { InstanceContext } from '../../../../src/types/instance-context';
|
||||
import { getN8nCredentials } from './credentials';
|
||||
|
||||
/**
|
||||
* Creates MCP context for testing MCP handlers against real n8n instance
|
||||
* This is what gets passed to MCP handlers (handleCreateWorkflow, etc.)
|
||||
*/
|
||||
export function createMcpContext(): InstanceContext {
|
||||
const creds = getN8nCredentials();
|
||||
return {
|
||||
n8nApiUrl: creds.url,
|
||||
n8nApiKey: creds.apiKey
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user