mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
refactor(core): Restore test for execution pagination in Public API (no-changelog) (#9621)
This commit is contained in:
parent
044607e2a0
commit
375b347b0f
|
@ -227,6 +227,61 @@ describe('GET /executions', () => {
|
||||||
expect(waitTill).toBeNull();
|
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 () => {
|
test('should retrieve all error executions', async () => {
|
||||||
const workflow = await createWorkflow({}, owner);
|
const workflow = await createWorkflow({}, owner);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue