mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-12 15:44:06 -08:00
9a1cc56806
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import type { User } from '@db/entities/User';
|
|
import { Push } from '@/push';
|
|
import { createSuccessfulExecution, getAllExecutions } from './shared/db/executions';
|
|
import { createOwner } from './shared/db/users';
|
|
import { createWorkflow } from './shared/db/workflows';
|
|
import * as testDb from './shared/testDb';
|
|
import { setupTestServer } from './shared/utils';
|
|
import { mockInstance } from '../shared/mocking';
|
|
import { EnterpriseExecutionsService } from '@/executions/execution.service.ee';
|
|
|
|
mockInstance(EnterpriseExecutionsService);
|
|
|
|
mockInstance(Push);
|
|
let testServer = setupTestServer({ endpointGroups: ['executions'] });
|
|
|
|
let owner: User;
|
|
|
|
const saveExecution = async ({ belongingTo }: { belongingTo: User }) => {
|
|
const workflow = await createWorkflow({}, belongingTo);
|
|
return await createSuccessfulExecution(workflow);
|
|
};
|
|
|
|
beforeEach(async () => {
|
|
await testDb.truncate(['Execution', 'Workflow', 'SharedWorkflow']);
|
|
owner = await createOwner();
|
|
});
|
|
|
|
describe('POST /executions/delete', () => {
|
|
test('should hard-delete an execution', async () => {
|
|
await saveExecution({ belongingTo: owner });
|
|
|
|
const response = await testServer.authAgentFor(owner).get('/executions').expect(200);
|
|
|
|
expect(response.body.data.count).toBe(1);
|
|
|
|
const [execution] = response.body.data.results;
|
|
|
|
await testServer
|
|
.authAgentFor(owner)
|
|
.post('/executions/delete')
|
|
.send({ ids: [execution.id] })
|
|
.expect(200);
|
|
|
|
const executions = await getAllExecutions();
|
|
|
|
expect(executions).toHaveLength(0);
|
|
});
|
|
});
|