Skip to content

Commit

Permalink
fix(api): Resolve circular import issue for workflow update validation (
Browse files Browse the repository at this point in the history
#7151)

Co-authored-by: Richard Fontein <[email protected]>
Co-authored-by: George Desipris <[email protected]>
Co-authored-by: Dima Grossman <[email protected]>
Co-authored-by: Pawan Jain <[email protected]>
Co-authored-by: Sokratis Vidros <[email protected]>
  • Loading branch information
6 people authored Nov 28, 2024
1 parent 3fe3c28 commit 98bc719
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 17 deletions.
19 changes: 19 additions & 0 deletions apps/api/src/app/workflows-v2/workflow.controller.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ describe('Workflow Controller E2E API Testing', () => {
expect(res.isSuccessResult()).to.be.false;
expect(res.error?.responseText).to.include('description must be shorter than or equal to 256 characters');
});
it('should respond with 400 when description is too long on an update call', async () => {
const createWorkflowDto: CreateWorkflowDto = buildCreateWorkflowDto('nameSuffix');

const res = await workflowsClient.createWorkflow(createWorkflowDto);
expect(res.isSuccessResult()).to.be.true;
if (res.isSuccessResult()) {
const updateWorkflowDto = {
...buildUpdateRequest(res.value),
description: Array.from({ length: 260 }).join('X'),
};
const updateResult = await workflowsClient.updateWorkflow(res.value?._id, updateWorkflowDto);
expect(updateResult.isSuccessResult(), JSON.stringify(updateResult.value)).to.be.false;
if (!updateResult.isSuccessResult()) {
expect(updateResult.error?.responseText).to.include(
'description must be shorter than or equal to 256 characters'
);
}
}
});

it('should respond with 400 when a tag is too long', async () => {
const createWorkflowDto: CreateWorkflowDto = buildCreateWorkflowDto('nameSuffix', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,32 @@ import {
BuilderFieldType,
BuilderGroupValues,
ChannelCTATypeEnum,
ContentIssue as ContentIssueDto,
FilterParts,
IMessageAction,
INotificationGroup,
IStepVariant,
StepIssuesDto,
StepIssue as StepIssueDto,
ContentIssue as ContentIssueDto,
IWorkflowStepMetadata,
JSONSchemaDto,
NotificationTemplateCustomData,
WorkflowOriginEnum,
WorkflowTypeEnum,
StepIssueEnum,
StepContentIssueEnum,
StepCreateAndUpdateKeys,
StepIssue as StepIssueDto,
StepIssueEnum,
StepIssuesDto,
WorkflowOriginEnum,
WorkflowStatusEnum,
WorkflowTypeEnum,
} from '@novu/shared';

import { Type } from 'class-transformer';
import { EnvironmentWithUserCommand } from '../../commands';
import { PreferencesRequired } from '../upsert-preferences';

export const MAX_TAG_ELEMENTS = 16;
export const MAX_TAG_LENGTH = 32;
export const MAX_NAME_LENGTH = 64;
export const MAX_DESCRIPTION_LENGTH = 256;
import {
MAX_DESCRIPTION_LENGTH,
MAX_NAME_LENGTH,
MAX_TAG_LENGTH,
} from '../workflow';

export class CreateWorkflowCommand extends EnvironmentWithUserCommand {
@IsDefined()
Expand Down
3 changes: 1 addition & 2 deletions libs/application-generic/src/usecases/workflow/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './update-workflow/update-workflow.usecase';
export * from './update-workflow/update-workflow.command';
export * from './update-workflow';
export * from './delete-workflow/delete-workflow.usecase';
export * from './delete-workflow/delete-workflow.command';
export * from './get-workflow-by-ids/get-workflow-by-ids.usecase';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './upsert-validation-constants';
export * from './update-workflow.command';
export * from './update-workflow.usecase';
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ import { Type } from 'class-transformer';
import { EnvironmentWithUserCommand } from '../../../commands';
import { PreferencesRequired } from '../../upsert-preferences';
import {
ContentIssue,
IStepControl,
MAX_DESCRIPTION_LENGTH,
MAX_NAME_LENGTH,
MAX_TAG_ELEMENTS,
MAX_TAG_LENGTH,
} from './upsert-validation-constants';
import {
ContentIssue,
IStepControl,
NotificationStep,
} from '../..';
} from '../../create-workflow/create-workflow.command';

export class UpdateWorkflowCommand extends EnvironmentWithUserCommand {
@IsDefined()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const MAX_TAG_ELEMENTS = 16;
export const MAX_TAG_LENGTH = 32;
export const MAX_NAME_LENGTH = 64;
export const MAX_DESCRIPTION_LENGTH = 256;

0 comments on commit 98bc719

Please sign in to comment.