test(core): Expand coverage for execution filters (#11890)

This commit is contained in:
Iván Ovejero 2024-11-26 10:27:01 +01:00 committed by GitHub
parent 595de81c03
commit 1adb730599
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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();