mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-06 05:23:08 +00:00
feat(tests): implement Phase 2 integration testing - workflow creation tests
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>
This commit is contained in:
@@ -13,17 +13,27 @@ import { existsSync } from 'fs';
|
||||
export function loadTestEnvironment(): void {
|
||||
// CI Debug logging
|
||||
const isCI = process.env.CI === 'true';
|
||||
|
||||
|
||||
// First, load the main .env file (for integration tests that need real credentials)
|
||||
const mainEnvPath = path.resolve(process.cwd(), '.env');
|
||||
if (existsSync(mainEnvPath)) {
|
||||
dotenv.config({ path: mainEnvPath });
|
||||
if (isCI) {
|
||||
console.log('[CI-DEBUG] Loaded .env file from:', mainEnvPath);
|
||||
}
|
||||
}
|
||||
|
||||
// Load base test environment
|
||||
const testEnvPath = path.resolve(process.cwd(), '.env.test');
|
||||
|
||||
|
||||
if (isCI) {
|
||||
console.log('[CI-DEBUG] Looking for .env.test at:', testEnvPath);
|
||||
console.log('[CI-DEBUG] File exists?', existsSync(testEnvPath));
|
||||
}
|
||||
|
||||
|
||||
if (existsSync(testEnvPath)) {
|
||||
const result = dotenv.config({ path: testEnvPath });
|
||||
// Don't override values from .env
|
||||
const result = dotenv.config({ path: testEnvPath, override: false });
|
||||
if (isCI && result.error) {
|
||||
console.error('[CI-DEBUG] Failed to load .env.test:', result.error);
|
||||
} else if (isCI && result.parsed) {
|
||||
@@ -39,9 +49,9 @@ export function loadTestEnvironment(): void {
|
||||
dotenv.config({ path: localEnvPath, override: true });
|
||||
}
|
||||
|
||||
// Set test-specific defaults
|
||||
// Set test-specific defaults (only if not already set)
|
||||
setTestDefaults();
|
||||
|
||||
|
||||
// Validate required environment variables
|
||||
validateTestEnvironment();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user