2023-11-10 06:04:26 -08:00
|
|
|
import type { User } from '@db/entities/User';
|
2024-01-17 01:16:13 -08:00
|
|
|
import { Push } from '@/push';
|
2023-11-08 07:29:39 -08:00
|
|
|
import { createSuccessfulExecution, getAllExecutions } from './shared/db/executions';
|
|
|
|
import { createOwner } from './shared/db/users';
|
|
|
|
import { createWorkflow } from './shared/db/workflows';
|
2023-09-20 06:21:42 -07:00
|
|
|
import * as testDb from './shared/testDb';
|
|
|
|
import { setupTestServer } from './shared/utils';
|
2024-01-17 01:16:13 -08:00
|
|
|
import { mockInstance } from '../shared/mocking';
|
2024-01-17 06:42:19 -08:00
|
|
|
import { EnterpriseExecutionsService } from '@/executions/execution.service.ee';
|
|
|
|
|
|
|
|
mockInstance(EnterpriseExecutionsService);
|
2023-09-20 06:21:42 -07:00
|
|
|
|
2024-01-17 01:16:13 -08:00
|
|
|
mockInstance(Push);
|
2023-09-20 06:21:42 -07:00
|
|
|
let testServer = setupTestServer({ endpointGroups: ['executions'] });
|
|
|
|
|
|
|
|
let owner: User;
|
|
|
|
|
|
|
|
const saveExecution = async ({ belongingTo }: { belongingTo: User }) => {
|
2023-11-08 07:29:39 -08:00
|
|
|
const workflow = await createWorkflow({}, belongingTo);
|
2024-01-17 07:08:50 -08:00
|
|
|
return await createSuccessfulExecution(workflow);
|
2023-09-20 06:21:42 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
await testDb.truncate(['Execution', 'Workflow', 'SharedWorkflow']);
|
2023-11-08 07:29:39 -08:00
|
|
|
owner = await createOwner();
|
2023-09-20 06:21:42 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-11-08 07:29:39 -08:00
|
|
|
const executions = await getAllExecutions();
|
2023-09-20 06:21:42 -07:00
|
|
|
|
|
|
|
expect(executions).toHaveLength(0);
|
|
|
|
});
|
|
|
|
});
|