diff --git a/packages/backend/test/factories/execution-step.ts b/packages/backend/test/factories/execution-step.ts new file mode 100644 index 00000000..b1d2cb9a --- /dev/null +++ b/packages/backend/test/factories/execution-step.ts @@ -0,0 +1,20 @@ +import ExecutionStep from '../../src/models/execution-step'; +import { createExecution } from './execution'; +import { createStep } from './step'; + +export const createExecutionStep = async ( + params: Partial = {} +) => { + params.executionId = params?.executionId || (await createExecution()).id; + params.stepId = params?.stepId || (await createStep()).id; + params.status = params?.status || 'success'; + params.dataIn = params?.dataIn || { dataIn: 'dataIn' }; + params.dataOut = params?.dataOut || { dataOut: 'dataOut' }; + + const [executionStep] = await global.knex + .table('executionSteps') + .insert(params) + .returning('*'); + + return executionStep; +}; diff --git a/packages/backend/test/factories/execution.ts b/packages/backend/test/factories/execution.ts index 84748831..65597e9f 100644 --- a/packages/backend/test/factories/execution.ts +++ b/packages/backend/test/factories/execution.ts @@ -6,7 +6,7 @@ export const createExecution = async (params: Partial = {}) => { params.testRun = params?.testRun || false; const [execution] = await global.knex - .table('execution') + .table('executions') .insert(params) .returning('*'); diff --git a/packages/backend/test/factories/step.ts b/packages/backend/test/factories/step.ts index 560808dd..409adda2 100644 --- a/packages/backend/test/factories/step.ts +++ b/packages/backend/test/factories/step.ts @@ -5,7 +5,7 @@ export const createStep = async (params: Partial = {}) => { params.flowId = params?.flowId || (await createFlow()).id; params.type = params?.type || 'action'; - const [lastStep] = await global.knex + const lastStep = await global.knex .table('steps') .where('flowId', params.flowId) .andWhere('deletedAt', '!=', null)