From 870a110a75b610872aa4f8f5ba33316e7296cfff Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Tue, 24 Oct 2023 12:11:53 +0200 Subject: [PATCH 1/3] fix: Fetch lastStep directly on the step factory --- packages/backend/test/factories/step.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From a4c22799e70a93475519af10882e6db19a96ca4c Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Tue, 24 Oct 2023 12:12:18 +0200 Subject: [PATCH 2/3] fix: Correct executions table name for execution factory --- packages/backend/test/factories/execution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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('*'); From 61afebc8278f09243a0e3f9fb02f697aee35a77f Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Tue, 24 Oct 2023 12:12:38 +0200 Subject: [PATCH 3/3] test: Implement execution step factory --- .../backend/test/factories/execution-step.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 packages/backend/test/factories/execution-step.ts 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; +};