mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(core): Add support for partial-match execution filters (#15797)
This commit is contained in:
@@ -270,21 +270,22 @@ describe('ExecutionService', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('should filter executions by `metadata`', async () => {
|
||||
test('should filter executions by `metadata` with an exact match by default', async () => {
|
||||
const workflow = await createWorkflow();
|
||||
|
||||
const metadata = [{ key: 'myKey', value: 'myValue' }];
|
||||
const key = 'myKey';
|
||||
const value = 'myValue';
|
||||
|
||||
await Promise.all([
|
||||
createExecution({ status: 'success', metadata }, workflow),
|
||||
createExecution({ status: 'error' }, workflow),
|
||||
createExecution({ status: 'success', metadata: [{ key, value }] }, workflow),
|
||||
createExecution({ status: 'error', metadata: [{ key, value: `${value}2` }] }, workflow),
|
||||
]);
|
||||
|
||||
const query: ExecutionSummaries.RangeQuery = {
|
||||
kind: 'range',
|
||||
range: { limit: 20 },
|
||||
accessibleWorkflowIds: [workflow.id],
|
||||
metadata,
|
||||
metadata: [{ key, value, exactMatch: true }],
|
||||
};
|
||||
|
||||
const output = await executionService.findRangeWithCount(query);
|
||||
@@ -296,6 +297,36 @@ describe('ExecutionService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('should filter executions by `metadata` with a partial match', async () => {
|
||||
const workflow = await createWorkflow();
|
||||
|
||||
const key = 'myKey';
|
||||
|
||||
await Promise.all([
|
||||
createExecution({ status: 'success', metadata: [{ key, value: 'myValue' }] }, workflow),
|
||||
createExecution({ status: 'error', metadata: [{ key, value: 'var' }] }, workflow),
|
||||
createExecution({ status: 'success', metadata: [{ key, value: 'evaluation' }] }, workflow),
|
||||
]);
|
||||
|
||||
const query: ExecutionSummaries.RangeQuery = {
|
||||
kind: 'range',
|
||||
range: { limit: 20 },
|
||||
accessibleWorkflowIds: [workflow.id],
|
||||
metadata: [{ key, value: 'val', exactMatch: false }],
|
||||
};
|
||||
|
||||
const output = await executionService.findRangeWithCount(query);
|
||||
|
||||
expect(output).toEqual({
|
||||
count: 2,
|
||||
estimated: false,
|
||||
results: [
|
||||
expect.objectContaining({ status: 'success' }),
|
||||
expect.objectContaining({ status: 'success' }),
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
test('should filter executions by `projectId`', async () => {
|
||||
const firstProject = await createTeamProject();
|
||||
const secondProject = await createTeamProject();
|
||||
|
||||
Reference in New Issue
Block a user