diff --git a/apps/api/src/app/workflows-v2/usecases/upsert-workflow/upsert-workflow.usecase.ts b/apps/api/src/app/workflows-v2/usecases/upsert-workflow/upsert-workflow.usecase.ts index f47c69f4f60..e54d78baea6 100644 --- a/apps/api/src/app/workflows-v2/usecases/upsert-workflow/upsert-workflow.usecase.ts +++ b/apps/api/src/app/workflows-v2/usecases/upsert-workflow/upsert-workflow.usecase.ts @@ -5,7 +5,6 @@ import { NotificationGroupRepository, NotificationStepEntity, NotificationTemplateEntity, - NotificationTemplateRepository, PreferencesEntity, } from '@novu/dal'; import { @@ -273,7 +272,7 @@ export class UpsertWorkflowUseCase { controls: step.controls, content: '', }, - stepId: step.stepId || slugifyName(step.name), + stepId: slugifyName(step.name), name: step.name, }; } diff --git a/apps/api/src/app/workflows-v2/workflow.controller.e2e.ts b/apps/api/src/app/workflows-v2/workflow.controller.e2e.ts index 1aefeecfc29..cf3289e3fef 100644 --- a/apps/api/src/app/workflows-v2/workflow.controller.e2e.ts +++ b/apps/api/src/app/workflows-v2/workflow.controller.e2e.ts @@ -6,6 +6,7 @@ import { ListWorkflowResponse, StepCreateDto, StepDto, + StepResponseDto, StepTypeEnum, StepUpdateDto, UpdateWorkflowDto, @@ -226,7 +227,7 @@ async function createWorkflowAndValidate(nameSuffix: string = ''): Promise - removeFields(step, 'stepUuid') + removeFields(step, 'stepUuid', 'stepId') ); expect(createdWorkflowWithoutUpdateDate).to.deep.equal( removeFields(createWorkflowDto, '__source'), @@ -243,7 +244,6 @@ function buildEmailStep(): StepDto { schema: channelStepSchemas.email.output, }, name: 'Email Test Step', - stepId: 'email-test-step', type: StepTypeEnum.EMAIL, }; } @@ -255,7 +255,6 @@ function buildInAppStep(): StepDto { schema: channelStepSchemas.in_app.output, }, name: 'In-App Test Step', - stepId: 'in-app-test-step', type: StepTypeEnum.IN_APP, }; } @@ -317,6 +316,18 @@ function findStepOnRequestBasedOnId(workflowUpdateRequest: UpdateWorkflowDto, st return undefined; } +/* + * There's a side effect on the backend where the stepId gets updated based on the step name. + * We need to make a design decision on the client side, should we allow users to update the stepId separately. + */ +function updateStepId(step: StepResponseDto): StepResponseDto { + if (step.stepId) { + return { ...step, stepId: slugifyName(step.name) }; + } + + return step; +} + function validateUpdatedWorkflowAndRemoveResponseFields( workflowResponse: WorkflowResponseDto, workflowUpdateRequest: UpdateWorkflowDto @@ -355,8 +366,12 @@ async function updateWorkflowAndValidate( updatedWorkflow, updateRequest ); + const expectedUpdateRequest = { + ...updateRequest, + steps: updateRequest.steps.map(updateStepId), + }; expect(updatedWorkflowWithResponseFieldsRemoved, 'workflow after update does not match as expected').to.deep.equal( - updateRequest + expectedUpdateRequest ); expect(convertToDate(updatedWorkflow.updatedAt)).to.be.greaterThan(convertToDate(updatedAt)); } @@ -587,6 +602,7 @@ function buildUpdateDtoWithValues(workflowCreated: WorkflowResponseDto): UpdateW steps: [updatedStep, newStep], }; } + function createStep(): StepCreateDto { return { name: 'someStep', diff --git a/packages/shared/src/dto/workflows/workflow-commons-fields.ts b/packages/shared/src/dto/workflows/workflow-commons-fields.ts index 06ca10d70d9..267722c55ed 100644 --- a/packages/shared/src/dto/workflows/workflow-commons-fields.ts +++ b/packages/shared/src/dto/workflows/workflow-commons-fields.ts @@ -36,10 +36,6 @@ export class StepDto { @IsDefined() name: string; - @IsString() - @IsOptional() - stepId?: string; - @IsString() @IsDefined() type: StepTypeEnum;