czlonkowski--n8n-mcp
409e92d6ae
Build and Push Docker Images / Build Docker Image (push) Has been cancelled
Build and Push Docker Images / Build Railway Docker Image (push) Has been cancelled
Build and Publish n8n Docker Image / test-image (push) Has been cancelled
Dependency Compatibility Check / Fresh Install Dependency Check (push) Has been cancelled
Build and Publish n8n Docker Image / build-and-push (push) Has been cancelled
Build and Publish n8n Docker Image / create-release (push) Has been cancelled
Automated Release / Detect Version Change (push) Has been cancelled
Automated Release / Generate Release Notes (push) Has been cancelled
Automated Release / Create GitHub Release (push) Has been cancelled
Automated Release / Package MCPB Bundle (push) Has been cancelled
Automated Release / Build and Verify (push) Has been cancelled
Automated Release / Publish to NPM (push) Has been cancelled
Automated Release / Build and Push Docker Images (push) Has been cancelled
Automated Release / Update Documentation (push) Has been cancelled
Automated Release / Notify Release Completion (push) Has been cancelled
Secret Scan / secretlint (push) Has been cancelled
Test Suite / test (push) Has been cancelled
Test Suite / cjs-runtime (push) Has been cancelled
Test Suite / publish-results (push) Has been cancelled
149 行
4.4 KiB
TypeScript
149 行
4.4 KiB
TypeScript
/**
|
|
* Integration Tests: handleDeleteExecution
|
|
*
|
|
* Tests execution deletion against a real n8n instance.
|
|
* Covers successful deletion, error handling, and cleanup verification.
|
|
*/
|
|
|
|
import { describe, it, expect, beforeEach, beforeAll } from 'vitest';
|
|
import { createMcpContext } from '../utils/mcp-context';
|
|
import { InstanceContext } from '../../../../src/types/instance-context';
|
|
import { handleDeleteExecution, handleTriggerWebhookWorkflow, handleGetExecution } from '../../../../src/mcp/handlers-n8n-manager';
|
|
import { getN8nCredentials } from '../utils/credentials';
|
|
|
|
describe('Integration: handleDeleteExecution', () => {
|
|
let mcpContext: InstanceContext;
|
|
let webhookUrl: string;
|
|
|
|
beforeEach(() => {
|
|
mcpContext = createMcpContext();
|
|
});
|
|
|
|
beforeAll(() => {
|
|
const creds = getN8nCredentials();
|
|
webhookUrl = creds.webhookUrls.get;
|
|
});
|
|
|
|
// ======================================================================
|
|
// Successful Deletion
|
|
// ======================================================================
|
|
|
|
describe('Successful Deletion', () => {
|
|
it('should delete an execution successfully', async () => {
|
|
// First, create an execution to delete
|
|
const triggerResponse = await handleTriggerWebhookWorkflow(
|
|
{
|
|
webhookUrl,
|
|
httpMethod: 'GET',
|
|
waitForResponse: true
|
|
},
|
|
mcpContext
|
|
);
|
|
|
|
// Try to extract execution ID
|
|
let executionId: string | undefined;
|
|
if (triggerResponse.success && triggerResponse.data) {
|
|
const responseData = triggerResponse.data as any;
|
|
executionId = responseData.executionId ||
|
|
responseData.id ||
|
|
responseData.execution?.id ||
|
|
responseData.workflowData?.executionId;
|
|
}
|
|
|
|
if (!executionId) {
|
|
console.warn('Could not extract execution ID for deletion test');
|
|
return;
|
|
}
|
|
|
|
// Delete the execution
|
|
const response = await handleDeleteExecution(
|
|
{ id: executionId },
|
|
mcpContext
|
|
);
|
|
|
|
expect(response.success).toBe(true);
|
|
expect(response.data).toBeDefined();
|
|
}, 30000);
|
|
|
|
it('should verify execution is actually deleted', async () => {
|
|
// Create an execution
|
|
const triggerResponse = await handleTriggerWebhookWorkflow(
|
|
{
|
|
webhookUrl,
|
|
httpMethod: 'GET',
|
|
waitForResponse: true
|
|
},
|
|
mcpContext
|
|
);
|
|
|
|
let executionId: string | undefined;
|
|
if (triggerResponse.success && triggerResponse.data) {
|
|
const responseData = triggerResponse.data as any;
|
|
executionId = responseData.executionId ||
|
|
responseData.id ||
|
|
responseData.execution?.id ||
|
|
responseData.workflowData?.executionId;
|
|
}
|
|
|
|
if (!executionId) {
|
|
console.warn('Could not extract execution ID for deletion verification test');
|
|
return;
|
|
}
|
|
|
|
// Delete it
|
|
const deleteResponse = await handleDeleteExecution(
|
|
{ id: executionId },
|
|
mcpContext
|
|
);
|
|
|
|
expect(deleteResponse.success).toBe(true);
|
|
|
|
// Try to fetch the deleted execution
|
|
const getResponse = await handleGetExecution(
|
|
{ id: executionId },
|
|
mcpContext
|
|
);
|
|
|
|
// Should fail to find the deleted execution
|
|
expect(getResponse.success).toBe(false);
|
|
expect(getResponse.error).toBeDefined();
|
|
}, 30000);
|
|
});
|
|
|
|
// ======================================================================
|
|
// Error Handling
|
|
// ======================================================================
|
|
|
|
describe('Error Handling', () => {
|
|
it('should handle non-existent execution ID', async () => {
|
|
const response = await handleDeleteExecution(
|
|
{ id: '99999999' },
|
|
mcpContext
|
|
);
|
|
|
|
expect(response.success).toBe(false);
|
|
expect(response.error).toBeDefined();
|
|
});
|
|
|
|
it('should handle invalid execution ID format', async () => {
|
|
const response = await handleDeleteExecution(
|
|
{ id: 'invalid-id-format' },
|
|
mcpContext
|
|
);
|
|
|
|
expect(response.success).toBe(false);
|
|
expect(response.error).toBeDefined();
|
|
});
|
|
|
|
it('should handle missing execution ID', async () => {
|
|
const response = await handleDeleteExecution(
|
|
{} as any,
|
|
mcpContext
|
|
);
|
|
|
|
expect(response.success).toBe(false);
|
|
expect(response.error).toBeDefined();
|
|
});
|
|
});
|
|
});
|