Merge pull request #717 from Hexastack/fix/payload-enum-missing-menu
Some checks are pending
Build and Push Docker API Image / build-and-push (push) Waiting to run
Build and Push Docker Base Image / build-and-push (push) Waiting to run
Build and Push Docker UI Image / build-and-push (push) Waiting to run

fix: missing value in PayloadType enum
This commit is contained in:
Med Marrouchi 2025-04-03 10:02:03 +01:00 committed by GitHub
commit 8680f48688
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View File

@ -53,6 +53,7 @@ import { CategoryRepository } from '../repositories/category.repository';
import { LabelRepository } from '../repositories/label.repository';
import { Block, BlockModel } from '../schemas/block.schema';
import { LabelModel } from '../schemas/label.schema';
import { PayloadType } from '../schemas/types/button';
import { BlockService } from '../services/block.service';
import { CategoryService } from '../services/category.service';
import { LabelService } from '../services/label.service';
@ -336,4 +337,30 @@ describe('BlockController', () => {
).rejects.toThrow(getUpdateOneError(Block.name, blockToDelete.id));
});
});
it('should update block trigger to postback menu', async () => {
jest.spyOn(blockService, 'updateOne');
const updateBlock: BlockUpdateDto = {
patterns: [
{
label: 'postback123',
value: 'postback123',
type: PayloadType.menu,
},
],
};
const result = await blockController.updateOne(block.id, updateBlock);
expect(blockService.updateOne).toHaveBeenCalledWith(block.id, updateBlock);
expect(
result.patterns.find(
(pattern) =>
typeof pattern === 'object' &&
'type' in pattern &&
pattern.type === PayloadType.menu &&
pattern,
),
).toBeDefined();
expect(result.patterns).toEqual(updateBlock.patterns);
});
});

View File

@ -41,4 +41,5 @@ export enum PayloadType {
quick_reply = 'quick_reply',
button = 'button',
outcome = 'outcome',
menu = 'menu',
}