Merge pull request #1693 from automatisch/refactor-get-executions-tests
refactor: Add steps to get execution tests
This commit is contained in:
@@ -5,6 +5,7 @@ import app from '../../../../app.js';
|
|||||||
import createAuthTokenByUserId from '../../../../helpers/create-auth-token-by-user-id';
|
import createAuthTokenByUserId from '../../../../helpers/create-auth-token-by-user-id';
|
||||||
import { createUser } from '../../../../../test/factories/user';
|
import { createUser } from '../../../../../test/factories/user';
|
||||||
import { createFlow } from '../../../../../test/factories/flow.js';
|
import { createFlow } from '../../../../../test/factories/flow.js';
|
||||||
|
import { createStep } from '../../../../../test/factories/step.js';
|
||||||
import { createExecution } from '../../../../../test/factories/execution.js';
|
import { createExecution } from '../../../../../test/factories/execution.js';
|
||||||
import { createPermission } from '../../../../../test/factories/permission';
|
import { createPermission } from '../../../../../test/factories/permission';
|
||||||
import getExecutionMock from '../../../../../test/mocks/rest/api/v1/executions/get-execution';
|
import getExecutionMock from '../../../../../test/mocks/rest/api/v1/executions/get-execution';
|
||||||
@@ -24,6 +25,16 @@ describe('GET /api/v1/executions/:executionId', () => {
|
|||||||
userId: currentUser.id,
|
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({
|
const currentUserExecution = await createExecution({
|
||||||
flowId: currentUserFlow.id,
|
flowId: currentUserFlow.id,
|
||||||
});
|
});
|
||||||
@@ -42,7 +53,8 @@ describe('GET /api/v1/executions/:executionId', () => {
|
|||||||
|
|
||||||
const expectedPayload = await getExecutionMock(
|
const expectedPayload = await getExecutionMock(
|
||||||
currentUserExecution,
|
currentUserExecution,
|
||||||
currentUserFlow
|
currentUserFlow,
|
||||||
|
[stepOne, stepTwo]
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(response.body).toEqual(expectedPayload);
|
expect(response.body).toEqual(expectedPayload);
|
||||||
@@ -55,6 +67,16 @@ describe('GET /api/v1/executions/:executionId', () => {
|
|||||||
userId: anotherUser.id,
|
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({
|
const anotherUserExecution = await createExecution({
|
||||||
flowId: anotherUserFlow.id,
|
flowId: anotherUserFlow.id,
|
||||||
});
|
});
|
||||||
@@ -73,7 +95,8 @@ describe('GET /api/v1/executions/:executionId', () => {
|
|||||||
|
|
||||||
const expectedPayload = await getExecutionMock(
|
const expectedPayload = await getExecutionMock(
|
||||||
anotherUserExecution,
|
anotherUserExecution,
|
||||||
anotherUserFlow
|
anotherUserFlow,
|
||||||
|
[stepOne, stepTwo]
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(response.body).toEqual(expectedPayload);
|
expect(response.body).toEqual(expectedPayload);
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
const getExecutionMock = async (execution, flow) => {
|
const getExecutionMock = async (execution, flow, steps) => {
|
||||||
const data = {
|
const data = {
|
||||||
id: execution.id,
|
id: execution.id,
|
||||||
testRun: execution.testRun,
|
testRun: execution.testRun,
|
||||||
@@ -9,6 +9,17 @@ const getExecutionMock = async (execution, flow) => {
|
|||||||
name: flow.name,
|
name: flow.name,
|
||||||
active: flow.active,
|
active: flow.active,
|
||||||
status: flow.active ? 'published' : 'draft',
|
status: flow.active ? 'published' : 'draft',
|
||||||
|
steps: steps.map((step) => ({
|
||||||
|
id: step.id,
|
||||||
|
type: step.type,
|
||||||
|
key: step.key,
|
||||||
|
appKey: step.appKey,
|
||||||
|
iconUrl: step.iconUrl,
|
||||||
|
webhookUrl: step.webhookUrl,
|
||||||
|
status: step.status,
|
||||||
|
position: step.position,
|
||||||
|
parameters: step.parameters,
|
||||||
|
})),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user