refactor: Add steps to get execution tests

This commit is contained in:
Faruk AYDIN
2024-03-04 16:12:02 +01:00
parent 172bf4bd51
commit 1cb48c7760
2 changed files with 37 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ import app from '../../../../app.js';
import createAuthTokenByUserId from '../../../../helpers/create-auth-token-by-user-id';
import { createUser } from '../../../../../test/factories/user';
import { createFlow } from '../../../../../test/factories/flow.js';
import { createStep } from '../../../../../test/factories/step.js';
import { createExecution } from '../../../../../test/factories/execution.js';
import { createPermission } from '../../../../../test/factories/permission';
import getExecutionMock from '../../../../../test/mocks/rest/api/v1/executions/get-execution';
@@ -24,6 +25,16 @@ describe('GET /api/v1/executions/:executionId', () => {
userId: currentUser.id,
});
const stepOne = await createStep({
flowId: currentUserFlow.id,
type: 'trigger',
});
const stepTwo = await createStep({
flowId: currentUserFlow.id,
type: 'action',
});
const currentUserExecution = await createExecution({
flowId: currentUserFlow.id,
});
@@ -42,7 +53,8 @@ describe('GET /api/v1/executions/:executionId', () => {
const expectedPayload = await getExecutionMock(
currentUserExecution,
currentUserFlow
currentUserFlow,
[stepOne, stepTwo]
);
expect(response.body).toEqual(expectedPayload);
@@ -55,6 +67,16 @@ describe('GET /api/v1/executions/:executionId', () => {
userId: anotherUser.id,
});
const stepOne = await createStep({
flowId: anotherUserFlow.id,
type: 'trigger',
});
const stepTwo = await createStep({
flowId: anotherUserFlow.id,
type: 'action',
});
const anotherUserExecution = await createExecution({
flowId: anotherUserFlow.id,
});
@@ -73,7 +95,8 @@ describe('GET /api/v1/executions/:executionId', () => {
const expectedPayload = await getExecutionMock(
anotherUserExecution,
anotherUserFlow
anotherUserFlow,
[stepOne, stepTwo]
);
expect(response.body).toEqual(expectedPayload);