diff --git a/packages/backend/src/serializers/step.js b/packages/backend/src/serializers/step.js index 27a9060c..f5ae1c26 100644 --- a/packages/backend/src/serializers/step.js +++ b/packages/backend/src/serializers/step.js @@ -13,6 +13,12 @@ const stepSerializer = (step) => { parameters: step.parameters, }; + if (step.lastExecutionStep) { + stepData.lastExecutionStep = executionStepSerializer( + step.lastExecutionStep + ); + } + if (step.executionSteps?.length > 0) { stepData.executionSteps = step.executionSteps.map((executionStep) => executionStepSerializer(executionStep) diff --git a/packages/backend/src/serializers/step.test.js b/packages/backend/src/serializers/step.test.js index 5ebc340e..8245196b 100644 --- a/packages/backend/src/serializers/step.test.js +++ b/packages/backend/src/serializers/step.test.js @@ -27,6 +27,18 @@ describe('stepSerializer', () => { expect(stepSerializer(step)).toEqual(expectedPayload); }); + it('should return step data with the last execution step', async () => { + const executionStep = await createExecutionStep({ stepId: step.id }); + + step.lastExecutionStep = executionStep; + + const expectedPayload = { + lastExecutionStep: executionStepSerializer(executionStep), + }; + + expect(stepSerializer(step)).toMatchObject(expectedPayload); + }); + it('should return step data with the execution steps', async () => { const executionStepOne = await createExecutionStep({ stepId: step.id }); const executionStepTwo = await createExecutionStep({ stepId: step.id });