docs/local/integration-tests-phase1-summary.md
Phase 1 establishes the foundation for n8n API integration testing. All core utilities, fixtures, and infrastructure are now in place.
feat/integration-tests-foundation
.env.example with integration testing configurationN8N_API_URL, N8N_API_KEY)tests/integration/n8n-api/
├── workflows/ (empty - for Phase 2+)
├── executions/ (empty - for Phase 2+)
├── system/ (empty - for Phase 2+)
├── scripts/
│ └── cleanup-orphans.ts
└── utils/
├── credentials.ts
├── n8n-client.ts
├── test-context.ts
├── cleanup-helpers.ts
├── fixtures.ts
├── factories.ts
└── webhook-workflows.ts
credentials.ts (200 lines)Key Functions:
getN8nCredentials() - Load credentials from .env or GitHub secretsvalidateCredentials() - Ensure required credentials are presentvalidateWebhookWorkflows() - Check webhook workflow IDs with setup instructionshasCredentials() - Non-throwing credential checkhasWebhookWorkflows() - Non-throwing webhook checkn8n-client.ts (45 lines)Key Functions:
getTestN8nClient() - Get/create configured API clientresetTestN8nClient() - Reset client instanceisN8nApiAccessible() - Check API connectivitytest-context.ts (120 lines)Key Functions:
createTestContext() - Create context for tracking resourcesTestContext.trackWorkflow() - Track workflow for cleanupTestContext.trackExecution() - Track execution for cleanupTestContext.cleanup() - Delete all tracked resourcescreateTestWorkflowName() - Generate unique workflow namesgetTestTag() - Get configured test tagcleanup-helpers.ts (275 lines)Key Functions:
cleanupOrphanedWorkflows() - Find and delete test workflowscleanupOldExecutions() - Delete executions older than X hourscleanupAllTestResources() - Comprehensive cleanupcleanupWorkflowsByTag() - Delete workflows by tagcleanupExecutionsByWorkflow() - Delete workflow's executionsfixtures.ts (310 lines)Available Fixtures:
SIMPLE_WEBHOOK_WORKFLOW - Single webhook nodeSIMPLE_HTTP_WORKFLOW - Webhook + HTTP RequestMULTI_NODE_WORKFLOW - Complex branching workflowERROR_HANDLING_WORKFLOW - Error output configurationAI_AGENT_WORKFLOW - Langchain agent nodeEXPRESSION_WORKFLOW - n8n expressions testingHelper Functions:
getFixture() - Get fixture by name (with deep clone)createCustomWorkflow() - Build custom workflow from nodesfactories.ts (315 lines)Node Factories:
createWebhookNode() - Webhook node with customizationcreateHttpRequestNode() - HTTP Request nodecreateSetNode() - Set node with assignmentscreateManualTriggerNode() - Manual trigger nodeConnection Factories:
createConnection() - Simple node connectioncreateSequentialWorkflow() - Auto-connected sequential nodescreateParallelWorkflow() - Trigger with parallel branchescreateErrorHandlingWorkflow() - Workflow with error handlingUtilities:
randomString() - Generate random test datauniqueId() - Unique IDs for testingcreateTestTags() - Test workflow tagscreateWorkflowSettings() - Common settingswebhook-workflows.ts (215 lines)Key Features:
WEBHOOK_WORKFLOW_CONFIGS - Configurations for all 4 HTTP methodsprintSetupInstructions() - Print detailed setup guidegenerateWebhookWorkflowJson() - Generate workflow JSONexportAllWebhookWorkflows() - Export all 4 configsgetWebhookUrl() - Get webhook URL for testingisValidWebhookWorkflow() - Validate workflow structurecleanup-orphans.ts (40 lines)Usage:
npm run test:cleanup:orphans
Added to package.json:
{
"test:integration:n8n": "vitest run tests/integration/n8n-api",
"test:cleanup:orphans": "tsx tests/integration/n8n-api/scripts/cleanup-orphans.ts"
}
npm run typechecknpm run builddocs/local/integration-testing-plan.md (550 lines)docs/local/integration-tests-phase1-summary.md (this file).env.example - Updated with test configuration (32 new lines)package.json - Added 2 npm scriptstests/integration/n8n-api/utils/credentials.ts (200 lines)tests/integration/n8n-api/utils/n8n-client.ts (45 lines)tests/integration/n8n-api/utils/test-context.ts (120 lines)tests/integration/n8n-api/utils/cleanup-helpers.ts (275 lines)tests/integration/n8n-api/utils/fixtures.ts (310 lines)tests/integration/n8n-api/utils/factories.ts (315 lines)tests/integration/n8n-api/utils/webhook-workflows.ts (215 lines)tests/integration/n8n-api/scripts/cleanup-orphans.ts (40 lines)Total New Code: ~1,520 lines of production-ready TypeScript
Phase 2 will implement the first actual integration tests:
Branch: feat/integration-tests-workflow-creation
Before running integration tests, you need to:
Set up n8n instance:
npx n8n startConfigure credentials in .env:
N8N_API_URL=http://localhost:5678
N8N_API_KEY=<your-api-key>
Create 4 webhook workflows manually:
.env:
N8N_TEST_WEBHOOK_GET_ID=<workflow-id>
N8N_TEST_WEBHOOK_POST_ID=<workflow-id>
N8N_TEST_WEBHOOK_PUT_ID=<workflow-id>
N8N_TEST_WEBHOOK_DELETE_ID=<workflow-id>
See docs/local/integration-testing-plan.md for detailed setup instructions.
Phase 1 Success Criteria - ALL MET:
null for no more pages, need to convert to undefinedPhase 1 actual time: ~2 hours (estimated 2-3 days in plan)