wip: Added tests for test run delete

This commit is contained in:
Eugene Molodkin 2024-11-28 11:01:35 +01:00
parent a4616e9320
commit dc27ff83e0
No known key found for this signature in database

View file

@ -166,3 +166,39 @@ describe('GET /evaluation/test-definitions/:testDefinitionId/runs/:id', () => {
expect(resp.statusCode).toBe(404);
});
});
describe('DELETE /evaluation/test-definitions/:testDefinitionId/runs/:id', () => {
test('should delete test run for a test definition', async () => {
const testRunRepository = Container.get(TestRunRepository);
const testRun = await testRunRepository.createTestRun(testDefinition.id);
const resp = await authOwnerAgent.delete(
`/evaluation/test-definitions/${testDefinition.id}/runs/${testRun.id}`,
);
expect(resp.statusCode).toBe(200);
expect(resp.body.data).toEqual({ success: true });
const testRunAfterDelete = await testRunRepository.findOne({ where: { id: testRun.id } });
expect(testRunAfterDelete).toBeNull();
});
test('should retrieve 404 if test run does not exist', async () => {
const resp = await authOwnerAgent.delete(
`/evaluation/test-definitions/${testDefinition.id}/runs/123`,
);
expect(resp.statusCode).toBe(404);
});
test('should retrieve 404 if user does not have access to test definition', async () => {
const testRunRepository = Container.get(TestRunRepository);
const testRun = await testRunRepository.createTestRun(otherTestDefinition.id);
const resp = await authOwnerAgent.delete(
`/evaluation/test-definitions/${otherTestDefinition.id}/runs/${testRun.id}`,
);
expect(resp.statusCode).toBe(404);
});
});