mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-01-29 22:12:05 +00:00
Implements comprehensive workflow creation tests against real n8n instance with 15 test scenarios covering P0 bugs, base nodes, advanced features, error scenarios, and edge cases. Key Changes: - Added 15 workflow creation test scenarios in create-workflow.test.ts - Fixed critical MSW interference with real API calls - Fixed environment loading priority (.env before test defaults) - Implemented multi-level cleanup with webhook workflow preservation - Migrated from webhook IDs to webhook URLs configuration - Added TypeScript type safety fixes (26 errors resolved) - Updated test names to reflect actual n8n API behavior Bug Fixes: - Removed MSW from integration test setup (was blocking real API calls) - Fixed .env loading order to preserve real credentials over test defaults - Added type guards for undefined workflow IDs - Fixed position arrays to use proper tuple types [number, number] - Added literal types for executionOrder and settings values Test Coverage: - P0: Critical bug verification (FULL vs SHORT node type format) - P1: Base n8n nodes (webhook, HTTP, langchain, multi-node) - P2: Advanced features (connections, settings, expressions, error handling) - Error scenarios (documents actual n8n API validation behavior) - Edge cases (minimal workflows, empty connections, no settings) Technical Improvements: - Cleanup strategy preserves pre-activated webhook workflows - Single webhook URL accepts all HTTP methods (GET, POST, PUT, DELETE) - Environment-aware credential loading with validation - Comprehensive test context for resource tracking All 15 tests passing ✅ TypeScript: 0 errors ✅ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
#!/usr/bin/env tsx
|
|
|
|
/**
|
|
* Export Webhook Workflow JSONs
|
|
*
|
|
* Generates the 4 webhook workflow JSON files needed for integration testing.
|
|
* These workflows must be imported into n8n and activated manually.
|
|
*/
|
|
|
|
import { writeFileSync, mkdirSync } from 'fs';
|
|
import { join } from 'path';
|
|
import { exportAllWebhookWorkflows } from '../tests/integration/n8n-api/utils/webhook-workflows';
|
|
|
|
const OUTPUT_DIR = join(process.cwd(), 'workflows-for-import');
|
|
|
|
// Create output directory
|
|
mkdirSync(OUTPUT_DIR, { recursive: true });
|
|
|
|
// Generate all workflow JSONs
|
|
const workflows = exportAllWebhookWorkflows();
|
|
|
|
// Write each workflow to a separate file
|
|
Object.entries(workflows).forEach(([method, workflow]) => {
|
|
const filename = `webhook-${method.toLowerCase()}.json`;
|
|
const filepath = join(OUTPUT_DIR, filename);
|
|
|
|
writeFileSync(filepath, JSON.stringify(workflow, null, 2), 'utf-8');
|
|
|
|
console.log(`✓ Generated: ${filename}`);
|
|
});
|
|
|
|
console.log(`\n✓ All workflow JSONs written to: ${OUTPUT_DIR}`);
|
|
console.log('\nNext steps:');
|
|
console.log('1. Import each JSON file into your n8n instance');
|
|
console.log('2. Activate each workflow in the n8n UI');
|
|
console.log('3. Copy the webhook URLs from each workflow (open workflow → Webhook node → copy URL)');
|
|
console.log('4. Add them to your .env file:');
|
|
console.log(' N8N_TEST_WEBHOOK_GET_URL=https://your-n8n.com/webhook/mcp-test-get');
|
|
console.log(' N8N_TEST_WEBHOOK_POST_URL=https://your-n8n.com/webhook/mcp-test-post');
|
|
console.log(' N8N_TEST_WEBHOOK_PUT_URL=https://your-n8n.com/webhook/mcp-test-put');
|
|
console.log(' N8N_TEST_WEBHOOK_DELETE_URL=https://your-n8n.com/webhook/mcp-test-delete');
|