From 48219fb860a77a9b276091a6dac548ae58f9f3e1 Mon Sep 17 00:00:00 2001 From: czlonkowski <56956555+czlonkowski@users.noreply.github.com> Date: Mon, 28 Jul 2025 18:36:47 +0200 Subject: [PATCH] fix: resolve TypeScript errors in MCP handler tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix N8nRateLimitError constructor call (takes only retryAfter parameter) - Fix optional chaining for result.details access - Mock NodeRepository correctly instead of trying to instantiate it 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- CLAUDE.md | 4 +++- tests/unit/mcp/handlers-n8n-manager.test.ts | 4 ++-- tests/unit/mcp/handlers-workflow-diff.test.ts | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 798ae59..c8fdaac 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -68,4 +68,6 @@ src/ ### Development Workflow Reminders - When you make changes to MCP server, you need to ask the user to reload it before you test -- When the user asks to review issues, you should use GH CLI to get the issue and all the comments \ No newline at end of file +- When the user asks to review issues, you should use GH CLI to get the issue and all the comments +- When the task can be divided into separated subtasks, you should spawn separate sub-agents to handle them in paralel +- Use the best sub-agent for the task as per their descriptions \ No newline at end of file diff --git a/tests/unit/mcp/handlers-n8n-manager.test.ts b/tests/unit/mcp/handlers-n8n-manager.test.ts index 8f54bb1..e5c0703 100644 --- a/tests/unit/mcp/handlers-n8n-manager.test.ts +++ b/tests/unit/mcp/handlers-n8n-manager.test.ts @@ -453,7 +453,7 @@ describe('handlers-n8n-manager', () => { describe('handleValidateWorkflow', () => { it('should validate workflow from n8n instance', async () => { const testWorkflow = createTestWorkflow(); - const mockNodeRepository = new NodeRepository(':memory:'); + const mockNodeRepository = {} as any; // Mock repository mockApiClient.getWorkflow.mockResolvedValue(testWorkflow); mockValidator.validateWorkflow.mockResolvedValue({ @@ -614,7 +614,7 @@ describe('handlers-n8n-manager', () => { }); it('should handle rate limit errors', async () => { - const rateLimitError = new N8nRateLimitError('Too many requests', 60); + const rateLimitError = new N8nRateLimitError(60); mockApiClient.listWorkflows.mockRejectedValue(rateLimitError); const result = await handlers.handleListWorkflows({}); diff --git a/tests/unit/mcp/handlers-workflow-diff.test.ts b/tests/unit/mcp/handlers-workflow-diff.test.ts index b894d02..013a5f9 100644 --- a/tests/unit/mcp/handlers-workflow-diff.test.ts +++ b/tests/unit/mcp/handlers-workflow-diff.test.ts @@ -351,7 +351,7 @@ describe('handlers-workflow-diff', () => { expect(result.success).toBe(false); expect(result.error).toBe('Invalid input'); expect(result.details).toHaveProperty('errors'); - expect(result.details.errors).toBeInstanceOf(Array); + expect(result.details?.errors).toBeInstanceOf(Array); }); it('should handle complex operation types', async () => { @@ -462,7 +462,7 @@ describe('handlers-workflow-diff', () => { }); it('should handle rate limit errors', async () => { - const rateLimitError = new N8nRateLimitError('Too many requests', 60); + const rateLimitError = new N8nRateLimitError(60); mockApiClient.getWorkflow.mockRejectedValue(rateLimitError); const result = await handleUpdatePartialWorkflow({