mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-01-30 22:42:04 +00:00
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.
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
/**
|
|
* Test script to verify error message tracking is working
|
|
*/
|
|
|
|
import { telemetry } from '../src/telemetry';
|
|
|
|
async function testErrorTracking() {
|
|
console.log('=== Testing Error Message Tracking ===\n');
|
|
|
|
// Track session first
|
|
console.log('1. Starting session...');
|
|
telemetry.trackSessionStart();
|
|
|
|
// Track an error WITH a message
|
|
console.log('\n2. Tracking error WITH message:');
|
|
const testErrorMessage = 'This is a test error message with sensitive data: password=secret123 and test@example.com';
|
|
telemetry.trackError(
|
|
'TypeError',
|
|
'tool_execution',
|
|
'test_tool',
|
|
testErrorMessage
|
|
);
|
|
console.log(` Original message: "${testErrorMessage}"`);
|
|
|
|
// Track an error WITHOUT a message
|
|
console.log('\n3. Tracking error WITHOUT message:');
|
|
telemetry.trackError(
|
|
'Error',
|
|
'tool_execution',
|
|
'test_tool2'
|
|
);
|
|
|
|
// Check the event queue
|
|
const metrics = telemetry.getMetrics();
|
|
console.log('\n4. Telemetry metrics:');
|
|
console.log(' Status:', metrics.status);
|
|
console.log(' Events queued:', metrics.tracking.eventsQueued);
|
|
|
|
// Get raw event queue to inspect
|
|
const eventTracker = (telemetry as any).eventTracker;
|
|
const queue = eventTracker.getEventQueue();
|
|
|
|
console.log('\n5. Event queue contents:');
|
|
queue.forEach((event, i) => {
|
|
console.log(`\n Event ${i + 1}:`);
|
|
console.log(` - Type: ${event.event}`);
|
|
console.log(` - Properties:`, JSON.stringify(event.properties, null, 6));
|
|
});
|
|
|
|
// Flush to database
|
|
console.log('\n6. Flushing to database...');
|
|
await telemetry.flush();
|
|
|
|
console.log('\n7. Done! Check Supabase for error events with "error" field.');
|
|
console.log(' Query: SELECT * FROM telemetry_events WHERE event = \'error_occurred\' ORDER BY created_at DESC LIMIT 5;');
|
|
}
|
|
|
|
testErrorTracking().catch(console.error);
|