mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 02:51:14 +00:00
fix(core): Fix broken execution query when using projectId (#11852)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user