n8n/packages/cli/test/integration/executions.controller.test.ts
कारतोफ्फेलस्क्रिप्ट™ 000e76e3b4
ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671)
This also gets rid of `Db.collection`, which was another source of
circular dependencies.
2023-11-10 15:04:26 +01:00

43 lines
1.3 KiB
TypeScript

import type { User } from '@db/entities/User';
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';
let testServer = setupTestServer({ endpointGroups: ['executions'] });
let owner: User;
const saveExecution = async ({ belongingTo }: { belongingTo: User }) => {
const workflow = await createWorkflow({}, belongingTo);
return 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);
});
});