mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-06 13:33:11 +00:00
fix(integration): add type assertions to fix TypeScript linting
**Issue**: response.data is typed as unknown, causing TypeScript errors **Changes**: - Import Workflow type from n8n-api types - Add type assertion: `response.data as Workflow` - Add explicit type annotations for .find() and .map() callbacks **Result**: All TypeScript linting errors resolved 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import { describe, it, expect, beforeEach, afterEach, afterAll } from 'vitest';
|
|||||||
import { createTestContext, TestContext, createTestWorkflowName } from '../utils/test-context';
|
import { createTestContext, TestContext, createTestWorkflowName } from '../utils/test-context';
|
||||||
import { getTestN8nClient } from '../utils/n8n-client';
|
import { getTestN8nClient } from '../utils/n8n-client';
|
||||||
import { N8nApiClient } from '../../../../src/services/n8n-api-client';
|
import { N8nApiClient } from '../../../../src/services/n8n-api-client';
|
||||||
|
import { Workflow } from '../../../../src/types/n8n-api';
|
||||||
import {
|
import {
|
||||||
SIMPLE_WEBHOOK_WORKFLOW,
|
SIMPLE_WEBHOOK_WORKFLOW,
|
||||||
SIMPLE_HTTP_WORKFLOW,
|
SIMPLE_HTTP_WORKFLOW,
|
||||||
@@ -70,7 +71,7 @@ describe('Integration: handleCreateWorkflow', () => {
|
|||||||
// Create workflow using MCP handler
|
// Create workflow using MCP handler
|
||||||
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
||||||
expect(response.success).toBe(true);
|
expect(response.success).toBe(true);
|
||||||
const result = response.data;
|
const result = response.data as Workflow;
|
||||||
|
|
||||||
// Verify workflow created successfully
|
// Verify workflow created successfully
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeDefined();
|
||||||
@@ -101,7 +102,7 @@ describe('Integration: handleCreateWorkflow', () => {
|
|||||||
|
|
||||||
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
||||||
expect(response.success).toBe(true);
|
expect(response.success).toBe(true);
|
||||||
const result = response.data;
|
const result = response.data as Workflow;
|
||||||
|
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeDefined();
|
||||||
expect(result.id).toBeTruthy();
|
expect(result.id).toBeTruthy();
|
||||||
@@ -111,8 +112,8 @@ describe('Integration: handleCreateWorkflow', () => {
|
|||||||
expect(result.nodes).toHaveLength(2);
|
expect(result.nodes).toHaveLength(2);
|
||||||
|
|
||||||
// Verify both nodes created with FULL type format
|
// Verify both nodes created with FULL type format
|
||||||
const webhookNode = result.nodes.find(n => n.name === 'Webhook');
|
const webhookNode = result.nodes.find((n: any) => n.name === 'Webhook');
|
||||||
const httpNode = result.nodes.find(n => n.name === 'HTTP Request');
|
const httpNode = result.nodes.find((n: any) => n.name === 'HTTP Request');
|
||||||
|
|
||||||
expect(webhookNode).toBeDefined();
|
expect(webhookNode).toBeDefined();
|
||||||
expect(webhookNode!.type).toBe('n8n-nodes-base.webhook');
|
expect(webhookNode!.type).toBe('n8n-nodes-base.webhook');
|
||||||
@@ -134,7 +135,7 @@ describe('Integration: handleCreateWorkflow', () => {
|
|||||||
|
|
||||||
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
||||||
expect(response.success).toBe(true);
|
expect(response.success).toBe(true);
|
||||||
const result = response.data;
|
const result = response.data as Workflow;
|
||||||
|
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeDefined();
|
||||||
expect(result.id).toBeTruthy();
|
expect(result.id).toBeTruthy();
|
||||||
@@ -144,7 +145,7 @@ describe('Integration: handleCreateWorkflow', () => {
|
|||||||
expect(result.nodes).toHaveLength(2);
|
expect(result.nodes).toHaveLength(2);
|
||||||
|
|
||||||
// Verify langchain node type format
|
// Verify langchain node type format
|
||||||
const agentNode = result.nodes.find(n => n.name === 'AI Agent');
|
const agentNode = result.nodes.find((n: any) => n.name === 'AI Agent');
|
||||||
expect(agentNode).toBeDefined();
|
expect(agentNode).toBeDefined();
|
||||||
expect(agentNode!.type).toBe('@n8n/n8n-nodes-langchain.agent');
|
expect(agentNode!.type).toBe('@n8n/n8n-nodes-langchain.agent');
|
||||||
});
|
});
|
||||||
@@ -158,7 +159,7 @@ describe('Integration: handleCreateWorkflow', () => {
|
|||||||
|
|
||||||
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
||||||
expect(response.success).toBe(true);
|
expect(response.success).toBe(true);
|
||||||
const result = response.data;
|
const result = response.data as Workflow;
|
||||||
|
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeDefined();
|
||||||
expect(result.id).toBeTruthy();
|
expect(result.id).toBeTruthy();
|
||||||
@@ -168,7 +169,7 @@ describe('Integration: handleCreateWorkflow', () => {
|
|||||||
expect(result.nodes).toHaveLength(4);
|
expect(result.nodes).toHaveLength(4);
|
||||||
|
|
||||||
// Verify all node types preserved
|
// Verify all node types preserved
|
||||||
const nodeTypes = result.nodes.map(n => n.type);
|
const nodeTypes = result.nodes.map((n: any) => n.type);
|
||||||
expect(nodeTypes).toContain('n8n-nodes-base.webhook');
|
expect(nodeTypes).toContain('n8n-nodes-base.webhook');
|
||||||
expect(nodeTypes).toContain('n8n-nodes-base.set');
|
expect(nodeTypes).toContain('n8n-nodes-base.set');
|
||||||
expect(nodeTypes).toContain('n8n-nodes-base.merge');
|
expect(nodeTypes).toContain('n8n-nodes-base.merge');
|
||||||
@@ -192,7 +193,7 @@ describe('Integration: handleCreateWorkflow', () => {
|
|||||||
|
|
||||||
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
||||||
expect(response.success).toBe(true);
|
expect(response.success).toBe(true);
|
||||||
const result = response.data;
|
const result = response.data as Workflow;
|
||||||
|
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeDefined();
|
||||||
expect(result.id).toBeTruthy();
|
expect(result.id).toBeTruthy();
|
||||||
@@ -231,7 +232,7 @@ describe('Integration: handleCreateWorkflow', () => {
|
|||||||
|
|
||||||
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
||||||
expect(response.success).toBe(true);
|
expect(response.success).toBe(true);
|
||||||
const result = response.data;
|
const result = response.data as Workflow;
|
||||||
|
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeDefined();
|
||||||
expect(result.id).toBeTruthy();
|
expect(result.id).toBeTruthy();
|
||||||
@@ -250,7 +251,7 @@ describe('Integration: handleCreateWorkflow', () => {
|
|||||||
|
|
||||||
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
||||||
expect(response.success).toBe(true);
|
expect(response.success).toBe(true);
|
||||||
const result = response.data;
|
const result = response.data as Workflow;
|
||||||
|
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeDefined();
|
||||||
expect(result.id).toBeTruthy();
|
expect(result.id).toBeTruthy();
|
||||||
@@ -259,7 +260,7 @@ describe('Integration: handleCreateWorkflow', () => {
|
|||||||
expect(result.nodes).toHaveLength(2);
|
expect(result.nodes).toHaveLength(2);
|
||||||
|
|
||||||
// Verify Set node with expressions
|
// Verify Set node with expressions
|
||||||
const setNode = result.nodes.find(n => n.name === 'Set Variables');
|
const setNode = result.nodes.find((n: any) => n.name === 'Set Variables');
|
||||||
expect(setNode).toBeDefined();
|
expect(setNode).toBeDefined();
|
||||||
expect(setNode!.parameters.assignments).toBeDefined();
|
expect(setNode!.parameters.assignments).toBeDefined();
|
||||||
|
|
||||||
@@ -280,7 +281,7 @@ describe('Integration: handleCreateWorkflow', () => {
|
|||||||
|
|
||||||
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
const response = await handleCreateWorkflow({ ...workflow }, mcpContext);
|
||||||
expect(response.success).toBe(true);
|
expect(response.success).toBe(true);
|
||||||
const result = response.data;
|
const result = response.data as Workflow;
|
||||||
|
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeDefined();
|
||||||
expect(result.id).toBeTruthy();
|
expect(result.id).toBeTruthy();
|
||||||
@@ -289,7 +290,7 @@ describe('Integration: handleCreateWorkflow', () => {
|
|||||||
expect(result.nodes).toHaveLength(3);
|
expect(result.nodes).toHaveLength(3);
|
||||||
|
|
||||||
// Verify HTTP node with error handling
|
// Verify HTTP node with error handling
|
||||||
const httpNode = result.nodes.find(n => n.name === 'HTTP Request');
|
const httpNode = result.nodes.find((n: any) => n.name === 'HTTP Request');
|
||||||
expect(httpNode).toBeDefined();
|
expect(httpNode).toBeDefined();
|
||||||
expect(httpNode!.continueOnFail).toBe(true);
|
expect(httpNode!.continueOnFail).toBe(true);
|
||||||
expect(httpNode!.onError).toBe('continueErrorOutput');
|
expect(httpNode!.onError).toBe('continueErrorOutput');
|
||||||
|
|||||||
Reference in New Issue
Block a user