Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
test(session): cover a revoke whose engine retires during the row read
Yudhi Armyndharis2ac7d4ee1b7d
diff --git a/src/modules/session/message-projector.service.spec.ts b/src/modules/session/message-projector.service.spec.tsindex 8992df804..38339f00f 100644--- a/src/modules/session/message-projector.service.spec.ts+++ b/src/modules/session/message-projector.service.spec.ts@@ -395,6 +395,23 @@ describe('MessageProjector', () => {expect(eventsGateway.emitMessageRevoked).toHaveBeenCalledTimes(1);});++ it('writes and announces nothing when the engine is retired while the row is read', async () => {+ let answer!: () => void;+ messageRepository.findOne.mockReturnValue(+ new Promise(resolve => (answer = () => resolve({ chatId: '[email protected]', direction: 'incoming' }))),+ );++ projector.handleMessageRevoked('s1', engine, revoke, { fromMe: false });+ await settle();+ engines.delete('s1');+ answer();+ await settle();++ expect(messageRepository.update).not.toHaveBeenCalled();+ expect(webhookService.dispatch).not.toHaveBeenCalled();+ expect(eventsGateway.emitMessageRevoked).not.toHaveBeenCalled();+ });});it('ignores an event from an engine that no longer owns the session', async () => {