fix: update Chat module unit tests

This commit is contained in:
yassinedorbozgithub 2025-01-13 15:37:55 +01:00
parent 848bf79005
commit 2e269d390e
5 changed files with 10 additions and 9 deletions

View File

@ -84,7 +84,7 @@ export class BlockCreateDto {
@IsObjectId({
message: 'Attached block must be a valid objectId',
})
attachedBlock?: string;
attachedBlock?: string | null;
@ApiProperty({ description: 'Block category', type: String })
@IsNotEmpty()

View File

@ -139,10 +139,12 @@ export class Block extends BlockStub {
@Transform(({ obj }) => obj.nextBlocks.map((elem) => elem.toString()))
nextBlocks: string[];
@Transform(({ obj }) => obj.attachedBlock?.toString() || null)
attachedBlock: string;
@Transform(({ obj }) =>
obj.attachedBlock ? obj.attachedBlock.toString() : null,
)
attachedBlock: string | null;
@Transform(({ obj }) => obj.category.toString())
@Transform(({ obj }) => (obj.category ? obj.category.toString() : null))
category: string | null;
@Exclude()
@ -164,10 +166,10 @@ export class BlockFull extends BlockStub {
nextBlocks: Block[];
@Type(() => Block)
attachedBlock: Block;
attachedBlock: Block | null;
@Type(() => Category)
category: Category;
category: Category | null;
@Type(() => Block)
previousBlocks?: Block[];

View File

@ -251,7 +251,7 @@ export class BotService {
// If there's labels, they should be already have been assigned
assign_labels: [],
trigger_labels: [],
attachedBlock: undefined,
attachedBlock: null,
category: undefined as any,
previousBlocks: [],
};

View File

@ -29,7 +29,6 @@ export const blockDefaultValues: TBlockFixtures['defaultValues'] = {
trigger_channels: [],
builtin: false,
starts_conversation: false,
attachedBlock: null,
};
export const blocks: TBlockFixtures['values'][] = [

View File

@ -105,7 +105,7 @@ export const blockEmpty = {
patterns: [],
message: [''],
nextBlocks: [],
};
} as unknown as BlockFull;
// Translation Data
export const textResult = ['Hi back !'];