mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
test(core): Expand coverage for execution filters (#11890)
This commit is contained in:
parent
595de81c03
commit
1adb730599
|
@ -357,6 +357,65 @@ describe('ExecutionService', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test.each([
|
||||
{
|
||||
name: 'waitTill',
|
||||
filter: { waitTill: true },
|
||||
matchingParams: { waitTill: new Date() },
|
||||
nonMatchingParams: { waitTill: undefined },
|
||||
},
|
||||
{
|
||||
name: 'metadata',
|
||||
filter: { metadata: [{ key: 'testKey', value: 'testValue' }] },
|
||||
matchingParams: { metadata: [{ key: 'testKey', value: 'testValue' }] },
|
||||
nonMatchingParams: { metadata: [{ key: 'otherKey', value: 'otherValue' }] },
|
||||
},
|
||||
{
|
||||
name: 'startedAfter',
|
||||
filter: { startedAfter: '2023-01-01' },
|
||||
matchingParams: { startedAt: new Date('2023-06-01') },
|
||||
nonMatchingParams: { startedAt: new Date('2022-01-01') },
|
||||
},
|
||||
{
|
||||
name: 'startedBefore',
|
||||
filter: { startedBefore: '2023-12-31' },
|
||||
matchingParams: { startedAt: new Date('2023-06-01') },
|
||||
nonMatchingParams: { startedAt: new Date('2024-01-01') },
|
||||
},
|
||||
])(
|
||||
'should filter executions by `projectId` and expected `$name`',
|
||||
async ({ filter, matchingParams, nonMatchingParams }) => {
|
||||
const firstProject = await createTeamProject();
|
||||
const secondProject = await createTeamProject();
|
||||
|
||||
const firstWorkflow = await createWorkflow(undefined, firstProject);
|
||||
const secondWorkflow = await createWorkflow(undefined, secondProject);
|
||||
|
||||
await Promise.all([
|
||||
createExecution(matchingParams, firstWorkflow),
|
||||
createExecution(nonMatchingParams, secondWorkflow),
|
||||
]);
|
||||
|
||||
const query: ExecutionSummaries.RangeQuery = {
|
||||
kind: 'range',
|
||||
range: { limit: 20 },
|
||||
accessibleWorkflowIds: [firstWorkflow.id],
|
||||
projectId: firstProject.id,
|
||||
...filter,
|
||||
};
|
||||
|
||||
const output = await executionService.findRangeWithCount(query);
|
||||
|
||||
expect(output).toEqual({
|
||||
count: 1,
|
||||
estimated: false,
|
||||
results: expect.arrayContaining([
|
||||
expect.objectContaining({ workflowId: firstWorkflow.id }),
|
||||
]),
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
test('should exclude executions by inaccessible `workflowId`', async () => {
|
||||
const accessibleWorkflow = await createWorkflow();
|
||||
const inaccessibleWorkflow = await createWorkflow();
|
||||
|
|
Loading…
Reference in a new issue