mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(core): Filter executions by project ID in internal API (#10976)
This commit is contained in:
@@ -6,6 +6,7 @@ import { ExecutionRepository } from '@/databases/repositories/execution.reposito
|
||||
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
|
||||
import { ExecutionService } from '@/executions/execution.service';
|
||||
import type { ExecutionSummaries } from '@/executions/execution.types';
|
||||
import { createTeamProject } from '@test-integration/db/projects';
|
||||
|
||||
import { annotateExecution, createAnnotationTags, createExecution } from './shared/db/executions';
|
||||
import { createWorkflow } from './shared/db/workflows';
|
||||
@@ -294,6 +295,37 @@ describe('ExecutionService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('should filter executions by `projectId`', 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: 'success' }, firstWorkflow);
|
||||
await createExecution({ status: 'success' }, secondWorkflow); // to filter out
|
||||
|
||||
const query: ExecutionSummaries.RangeQuery = {
|
||||
kind: 'range',
|
||||
range: { limit: 20 },
|
||||
accessibleWorkflowIds: [firstWorkflow.id],
|
||||
projectId: firstProject.id,
|
||||
};
|
||||
|
||||
const output = await executionService.findRangeWithCount(query);
|
||||
|
||||
expect(output).toEqual({
|
||||
count: 2,
|
||||
estimated: false,
|
||||
results: expect.arrayContaining([
|
||||
expect.objectContaining({ workflowId: firstWorkflow.id }),
|
||||
expect.objectContaining({ workflowId: firstWorkflow.id }),
|
||||
// execution for workflow in second project was filtered out
|
||||
]),
|
||||
});
|
||||
});
|
||||
|
||||
test('should exclude executions by inaccessible `workflowId`', async () => {
|
||||
const accessibleWorkflow = await createWorkflow();
|
||||
const inaccessibleWorkflow = await createWorkflow();
|
||||
|
||||
Reference in New Issue
Block a user