Skip to content

Commit

Permalink
fix(core): Fix broken execution query when using projectId (#11852)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcL authored and netroy committed Nov 25, 2024
1 parent 55ae09a commit 74261da
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
if (projectId) {
qb.innerJoin(WorkflowEntity, 'w', 'w.id = execution.workflowId')
.innerJoin(SharedWorkflow, 'sw', 'sw.workflowId = w.id')
.where('sw.projectId = :projectId', { projectId });
.andWhere('sw.projectId = :projectId', { projectId });
}

return qb;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,36 @@ describe('ExecutionService', () => {
});
});

test('should filter executions by `projectId` and expected `status`', async () => {
const firstProject = await createTeamProject();
const secondProject = await createTeamProject();

const firstWorkflow = await createWorkflow(undefined, firstProject);
const secondWorkflow = await createWorkflow(undefined, secondProject);

await createExecution({ status: 'success' }, firstWorkflow);
await createExecution({ status: 'error' }, firstWorkflow);
await createExecution({ status: 'success' }, secondWorkflow);

const query: ExecutionSummaries.RangeQuery = {
kind: 'range',
range: { limit: 20 },
accessibleWorkflowIds: [firstWorkflow.id],
projectId: firstProject.id,
status: ['error'],
};

const output = await executionService.findRangeWithCount(query);

expect(output).toEqual({
count: 1,
estimated: false,
results: expect.arrayContaining([
expect.objectContaining({ workflowId: firstWorkflow.id, status: 'error' }),
]),
});
});

test('should exclude executions by inaccessible `workflowId`', async () => {
const accessibleWorkflow = await createWorkflow();
const inaccessibleWorkflow = await createWorkflow();
Expand Down

0 comments on commit 74261da

Please sign in to comment.