mirror of
https://github.com/hexastack/hexabot
synced 2025-04-24 16:27:23 +00:00
Merge pull request #717 from Hexastack/fix/payload-enum-missing-menu
fix: missing value in PayloadType enum
This commit is contained in:
commit
8680f48688
@ -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);
|
||||
});
|
||||
});
|
||||
|
@ -41,4 +41,5 @@ export enum PayloadType {
|
||||
quick_reply = 'quick_reply',
|
||||
button = 'button',
|
||||
outcome = 'outcome',
|
||||
menu = 'menu',
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user