From 375b347b0f31062041ce69efe332ed1f42b96a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Wed, 5 Jun 2024 10:14:01 +0200 Subject: [PATCH] refactor(core): Restore test for execution pagination in Public API (no-changelog) (#9621) --- .../integration/publicApi/executions.test.ts | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/packages/cli/test/integration/publicApi/executions.test.ts b/packages/cli/test/integration/publicApi/executions.test.ts index 608eabfdf..ce26a19f8 100644 --- a/packages/cli/test/integration/publicApi/executions.test.ts +++ b/packages/cli/test/integration/publicApi/executions.test.ts @@ -227,6 +227,61 @@ describe('GET /executions', () => { expect(waitTill).toBeNull(); }); + test('should paginate two executions', async () => { + const workflow = await createWorkflow({}, owner); + + const firstSuccessfulExecution = await createSuccessfulExecution(workflow); + const secondSuccessfulExecution = await createSuccessfulExecution(workflow); + + await createErrorExecution(workflow); + + const firstExecutionResponse = await authOwnerAgent.get('/executions').query({ + status: 'success', + limit: 1, + }); + + expect(firstExecutionResponse.statusCode).toBe(200); + expect(firstExecutionResponse.body.data.length).toBe(1); + expect(firstExecutionResponse.body.nextCursor).toBeDefined(); + + const secondExecutionResponse = await authOwnerAgent.get('/executions').query({ + status: 'success', + limit: 1, + cursor: firstExecutionResponse.body.nextCursor, + }); + + expect(secondExecutionResponse.statusCode).toBe(200); + expect(secondExecutionResponse.body.data.length).toBe(1); + expect(secondExecutionResponse.body.nextCursor).toBeNull(); + + const successfulExecutions = [firstSuccessfulExecution, secondSuccessfulExecution]; + const executions = [...firstExecutionResponse.body.data, ...secondExecutionResponse.body.data]; + + for (let i = 0; i < executions.length; i++) { + const { + id, + finished, + mode, + retryOf, + retrySuccessId, + startedAt, + stoppedAt, + workflowId, + waitTill, + } = executions[i]; + + expect(id).toBeDefined(); + expect(finished).toBe(true); + expect(mode).toEqual(successfulExecutions[i].mode); + expect(retrySuccessId).toBeNull(); + expect(retryOf).toBeNull(); + expect(startedAt).not.toBeNull(); + expect(stoppedAt).not.toBeNull(); + expect(workflowId).toBe(successfulExecutions[i].workflowId); + expect(waitTill).toBeNull(); + } + }); + test('should retrieve all error executions', async () => { const workflow = await createWorkflow({}, owner);