fix(editor): Don't render now when startedAt is null (#15283)

This commit is contained in:
Danny Martini
2025-05-14 10:31:52 +02:00
committed by GitHub
parent 0cddc9576f
commit 44ecad5883
12 changed files with 150 additions and 13 deletions

View File

@@ -0,0 +1,49 @@
import { ExecutionRepository } from '@n8n/db';
import { Container } from '@n8n/di';
import { createExecution } from '@test-integration/db/executions';
import { createWorkflow } from '@test-integration/db/workflows';
import * as testDb from './shared/test-db';
describe('UserRepository', () => {
let executionRepository: ExecutionRepository;
beforeAll(async () => {
await testDb.init();
executionRepository = Container.get(ExecutionRepository);
});
beforeEach(async () => {
await testDb.truncate(['ExecutionEntity']);
});
afterAll(async () => {
await testDb.terminate();
});
describe('findManyByRangeQuery', () => {
test('sort by `createdAt` if `startedAt` is null', async () => {
const workflow = await createWorkflow();
const execution1 = await createExecution({}, workflow);
const execution2 = await createExecution({ startedAt: null }, workflow);
const execution3 = await createExecution({}, workflow);
const executions = await executionRepository.findManyByRangeQuery({
workflowId: workflow.id,
accessibleWorkflowIds: [workflow.id],
kind: 'range',
range: { limit: 10 },
order: { startedAt: 'DESC' },
});
// Executions are returned in reverse order, and if `startedAt` is not
// defined `createdAt` is used.
expect(executions.map((e) => e.id)).toStrictEqual([
execution3.id,
execution2.id,
execution1.id,
]);
});
});
});