Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
test(status): pin the sending gate and pacing check on voice posts
Yudhi Armyndharisdbf3169ce420
diff --git a/src/modules/status/status.service.spec.ts b/src/modules/status/status.service.spec.tsindex 105a8c8f9..0c4190516 100644--- a/src/modules/status/status.service.spec.ts+++ b/src/modules/status/status.service.spec.ts@@ -375,14 +375,16 @@ describe('StatusService media validation and selection', () => {// A status post publishes content from the account, so it passes the same `message:sending`// moderation gate as a chat send rather than going out unseen by plugins.describe('message:sending gate', () => {- it('consults the gate for text, image and video status posts', async () => {+ it('consults the gate and the pacing check for text, image, video and voice status posts', async () => {await service.postTextStatus('s1', 'hello', { recipients: [] });await service.postImageStatus('s1', { base64: 'QUJD', mimetype: 'image/png' }, { recipients: [] });await service.postVideoStatus('s1', { base64: 'QUJD', mimetype: 'video/mp4' }, { recipients: [] });+ await service.postVoiceStatus('s1', { base64: 'QUJD' }, { recipients: [] });const types = hookManager.execute.mock.calls.map(([, data]) => (data as { type: string }).type);- expect(types).toEqual(['status-text', 'status-image', 'status-video']);+ expect(types).toEqual(['status-text', 'status-image', 'status-video', 'status-voice']);expect(hookManager.execute.mock.calls.every(([event]) => event === 'message:sending')).toBe(true);+ expect(pacing.assertSendAllowed).toHaveBeenCalledTimes(4);});it('identifies itself as StatusService so a plugin can tell it from a chat send', async () => {@@ -398,7 +400,11 @@ describe('StatusService media validation and selection', () => {await expect(service.postTextStatus('s1', 'spam', { recipients: [] })).rejects.toBeInstanceOf(BadRequestException,);+ await expect(service.postVoiceStatus('s1', { base64: 'QUJD' }, { recipients: [] })).rejects.toBeInstanceOf(+ BadRequestException,+ );expect(engine.postTextStatus).not.toHaveBeenCalled();+ expect(engine.postVoiceStatus).not.toHaveBeenCalled();});it('sends the plugin-rewritten text rather than the original', async () => {