feat: Extend step serializer with last execution step

This commit is contained in:
Faruk AYDIN
2024-08-29 18:45:17 +03:00
parent 51e200533b
commit d3dc207166
2 changed files with 18 additions and 0 deletions

View File

@@ -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)

View File

@@ -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 });