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({ @IsObjectId({
message: 'Attached block must be a valid objectId', message: 'Attached block must be a valid objectId',
}) })
attachedBlock?: string; attachedBlock?: string | null;
@ApiProperty({ description: 'Block category', type: String }) @ApiProperty({ description: 'Block category', type: String })
@IsNotEmpty() @IsNotEmpty()

View File

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

View File

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

View File

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

View File

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