diff --git a/apps/api/src/app/workflows-v2/mappers/notification-template-mapper.ts b/apps/api/src/app/workflows-v2/mappers/notification-template-mapper.ts index 6913b0b6d20..3977b3e151f 100644 --- a/apps/api/src/app/workflows-v2/mappers/notification-template-mapper.ts +++ b/apps/api/src/app/workflows-v2/mappers/notification-template-mapper.ts @@ -33,7 +33,7 @@ export function toResponseWorkflowDto( tags: workflow.tags, active: workflow.active, preferences: preferencesDto, - steps: steps, + steps, description: workflow.description, origin: computeOrigin(workflow), updatedAt: workflow.updatedAt || 'Missing Updated At', diff --git a/apps/api/src/app/workflows-v2/usecases/build-step-data/build-step-data.usecase.ts b/apps/api/src/app/workflows-v2/usecases/build-step-data/build-step-data.usecase.ts index 4a6919120af..60b6ffa7480 100644 --- a/apps/api/src/app/workflows-v2/usecases/build-step-data/build-step-data.usecase.ts +++ b/apps/api/src/app/workflows-v2/usecases/build-step-data/build-step-data.usecase.ts @@ -20,15 +20,12 @@ export class BuildStepDataUsecase { const workflow = await this.fetchWorkflow(command); const { currentStep } = await this.loadStepsFromDb(command, workflow); - if ( - currentStep.name === undefined || - !currentStep._templateId || - currentStep.stepId === undefined || - !currentStep.template?.type - ) { + + if (!currentStep._templateId || !currentStep.template?.type) { throw new InvalidStepException(currentStep); } const controlValues = await this.getValues(command, currentStep, workflow._id); + const stepName = currentStep.name || 'Missing Step Name'; return { controls: { @@ -43,10 +40,10 @@ export class BuildStepDataUsecase { stepInternalId: currentStep._templateId, workflow, }), - name: currentStep.name, - slug: buildSlug(currentStep.name, ShortIsPrefixEnum.STEP, currentStep._templateId), + name: stepName, + slug: buildSlug(stepName, ShortIsPrefixEnum.STEP, currentStep._templateId), _id: currentStep._templateId, - stepId: currentStep.stepId, + stepId: currentStep.stepId || 'Missing Step Id', type: currentStep.template?.type, origin: workflow.origin || WorkflowOriginEnum.EXTERNAL, workflowId: workflow.triggers[0].identifier, diff --git a/apps/api/src/app/workflows-v2/usecases/get-workflow/get-workflow.usecase.ts b/apps/api/src/app/workflows-v2/usecases/get-workflow/get-workflow.usecase.ts index ff64553598e..47fbf3efa4f 100644 --- a/apps/api/src/app/workflows-v2/usecases/get-workflow/get-workflow.usecase.ts +++ b/apps/api/src/app/workflows-v2/usecases/get-workflow/get-workflow.usecase.ts @@ -8,11 +8,11 @@ import { WorkflowInternalResponseDto, } from '@novu/application-generic'; +import { NotificationStepEntity } from '@novu/dal'; import { GetWorkflowCommand } from './get-workflow.command'; import { toResponseWorkflowDto } from '../../mappers/notification-template-mapper'; import { BuildStepDataUsecase } from '../build-step-data/build-step-data.usecase'; import { BuildStepDataCommand } from '../build-step-data/build-step-data.command'; -import { NotificationStepEntity } from '@novu/dal'; @Injectable() export class GetWorkflowUseCase { diff --git a/apps/api/src/app/workflows-v2/usecases/sync-to-environment/sync-to-environment.usecase.ts b/apps/api/src/app/workflows-v2/usecases/sync-to-environment/sync-to-environment.usecase.ts index 49a14eb9377..39013c8ea04 100644 --- a/apps/api/src/app/workflows-v2/usecases/sync-to-environment/sync-to-environment.usecase.ts +++ b/apps/api/src/app/workflows-v2/usecases/sync-to-environment/sync-to-environment.usecase.ts @@ -83,7 +83,7 @@ export class SyncToEnvironmentUseCase { externalId: string ): Promise { try { - return this.getWorkflowUseCase.execute( + return await this.getWorkflowUseCase.execute( GetWorkflowCommand.create({ user: { ...command.user, environmentId: command.targetEnvironmentId }, workflowIdOrInternalId: externalId, 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 d546821aa4d..1b5549351ce 100644 --- a/apps/api/src/app/workflows-v2/workflow.controller.e2e.ts +++ b/apps/api/src/app/workflows-v2/workflow.controller.e2e.ts @@ -465,10 +465,11 @@ describe('Workflow Controller E2E API Testing', () => { describe('Promote Workflow Permutations', () => { it('should promote by creating a new workflow in production environment with the same properties', async () => { // Create a workflow in the development environment - const devWorkflow = await createWorkflowAndValidate('-promote-workflow'); + let devWorkflow = await createWorkflowAndValidate('-promote-workflow'); await workflowsClient.patchWorkflowStepData(devWorkflow._id, devWorkflow.steps[0]._id, { controlValues: { vinyl: 'vinyl', color: 'red', band: 'beatles' }, }); + devWorkflow = await getWorkflowRest(devWorkflow._id); // Switch to production environment and get its ID const devEnvironmentId = session.environment._id; diff --git a/packages/shared/src/dto/workflows/step.dto.ts b/packages/shared/src/dto/workflows/step.dto.ts index b84cceb40c0..5a97fdabdb8 100644 --- a/packages/shared/src/dto/workflows/step.dto.ts +++ b/packages/shared/src/dto/workflows/step.dto.ts @@ -29,7 +29,6 @@ export type PatchStepDataDto = { controlValues?: Record; }; -// remove all these useless step dtos export type StepDto = { name: string; type: StepTypeEnum;