test: Implement get executions method time filters tests

This commit is contained in:
Faruk AYDIN
2025-03-27 23:27:18 +01:00
parent 6068b6c746
commit f7e81ec687

View File

@@ -1380,12 +1380,18 @@ describe('User model', () => {
status: 'success',
});
// sleep for 10 milliseconds to make sure the created_at values are different
await new Promise((resolve) => setTimeout(resolve, 10));
executionTwo = await createExecution({
flowId: flow.id,
testRun: true,
status: 'failure',
});
// sleep for 10 milliseconds to make sure the created_at values are different
await new Promise((resolve) => setTimeout(resolve, 10));
executionThree = await createExecution({
flowId: anotherUserFlow.id,
testRun: false,
@@ -1421,6 +1427,17 @@ describe('User model', () => {
expect(executions[0].id).toBe(executionTwo.id);
});
it('should return executions filtered by startDateTime and endDateTime', async () => {
const executions = await currentUser.getExecutions({
startDateTime: executionOne.createdAt,
endDateTime: executionTwo.createdAt,
});
expect(executions).toHaveLength(2);
expect(executions[0].id).toBe(executionTwo.id);
expect(executions[1].id).toBe(executionOne.id);
});
it('should return all executions when no filter is applied', async () => {
const executions = await currentUser.getExecutions({});