test: Cover bad request responses for API endpoint tests

This commit is contained in:
Faruk AYDIN
2024-02-26 13:30:30 +01:00
parent 404ea94dd2
commit d74b215169
6 changed files with 74 additions and 17 deletions

View File

@@ -70,7 +70,7 @@ describe('GET /api/v1/flows/:flowId', () => {
expect(response.body).toEqual(expectedPayload);
});
it('should return not found response for not existing flow id', async () => {
it('should return not found response for not existing flow UUID', async () => {
await createPermission({
action: 'read',
subject: 'Flow',
@@ -78,11 +78,25 @@ describe('GET /api/v1/flows/:flowId', () => {
conditions: [],
});
const invalidFlowId = Crypto.randomUUID();
const notExistingFlowUUID = Crypto.randomUUID();
await request(app)
.get(`/api/v1/flows/${invalidFlowId}`)
.get(`/api/v1/flows/${notExistingFlowUUID}`)
.set('Authorization', token)
.expect(404);
});
it('should return bad request response for invalid UUID', async () => {
await createPermission({
action: 'read',
subject: 'Flow',
roleId: currentUserRole.id,
conditions: [],
});
await request(app)
.get('/api/v1/flows/invalidFlowUUID')
.set('Authorization', token)
.expect(400);
});
});