Files
n8n-mcp/tests/integration/n8n-api/utils/mcp-context.ts
czlonkowski 7a402bc7ad feat(tests): implement Phase 3 integration tests - workflow retrieval
Phase 3: Workflow Retrieval Tests (11 tests, all passing)

## Test Files Created:
- tests/integration/n8n-api/workflows/get-workflow.test.ts (3 scenarios)
- tests/integration/n8n-api/workflows/get-workflow-details.test.ts (4 scenarios)
- tests/integration/n8n-api/workflows/get-workflow-structure.test.ts (2 scenarios)
- tests/integration/n8n-api/workflows/get-workflow-minimal.test.ts (2 scenarios)
- tests/integration/n8n-api/utils/mcp-context.ts (helper for MCP context)

## Key Features:
- All tests use MCP handlers instead of direct API client calls
- Tests verify handleGetWorkflow, handleGetWorkflowDetails, handleGetWorkflowStructure, handleGetWorkflowMinimal
- Proper error handling tests for invalid/malformed IDs
- Version history tracking verification
- Execution statistics validation
- Flexible assertions to document actual n8n API behavior

## API Behavior Discoveries:
- Tags may not be returned in GET requests even when set during creation
- typeVersion field may be undefined in some API responses
- handleGetWorkflowDetails wraps response in {workflow, executionStats, hasWebhookTrigger, webhookPath}
- Minimal workflow view may not include tags or node data

All 11 tests passing locally.
2025-10-04 11:06:14 +02:00

25 lines
613 B
TypeScript

/**
* MCP Context Helper for Integration Tests
*
* Provides a configured InstanceContext for testing MCP handlers
* against a real n8n instance.
*/
import { InstanceContext } from '../../../../src/types/instance-context';
import { getN8nCredentials } from './credentials';
/**
* Create an InstanceContext configured with n8n API credentials
*
* This context is passed to MCP handlers to configure them to use
* the test n8n instance.
*/
export function createMcpContext(): InstanceContext {
const creds = getN8nCredentials();
return {
n8nApiUrl: creds.url,
n8nApiKey: creds.apiKey
};
}