Skip to content

Commit

Permalink
fix(public api): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tkasriel-numberly committed Jul 7, 2023
1 parent f2a1391 commit 2cb2c57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Container from 'typedi';
import { ExecutionRepository } from '@/databases/repositories';

function getStatusCondition(status: ExecutionStatus | ExecutionStatus[]) {
const condition: Pick<FindOptionsWhere<IExecutionFlattedDb>, 'status'> = {};
if (typeof status === 'string') {
status = [status];
}
Expand All @@ -22,7 +23,8 @@ function getStatusCondition(status: ExecutionStatus | ExecutionStatus[]) {
output.add(currFilter);
}
}
return In(Array.from(output));
condition.status = In(Array.from(output));
return condition;
}

export async function getExecutions(params: {
Expand Down
16 changes: 12 additions & 4 deletions packages/cli/test/integration/publicApi/executions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,13 @@ describe('GET /executions', () => {
});

expect(response.statusCode).toBe(200);
expect(response.body.data.length).toBe(1);
expect(response.body.nextCursor).toBe(null);

if (filterStatus === 'error') {
// Check for breaking change
expect(response.body.data.length).toBe(3);
} else {
expect(response.body.data.length).toBe(1);
}
const {
id,
finished,
Expand Down Expand Up @@ -362,8 +366,12 @@ describe('GET /executions', () => {
});

expect(response.statusCode).toBe(200);
expect(response.body.data.length).toBe(filterStatusList.length);

if (filterStatusList.includes('error')) {
// Check for breaking change
expect(response.body.data.length).toBe(filterStatusList.length + 2);
} else {
expect(response.body.data.length).toBe(filterStatusList.length);
}
for (let execution of response.body.data) {
const {
id,
Expand Down

0 comments on commit 2cb2c57

Please sign in to comment.