Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

test(session): persist the first copy in the re-fire dedup test

Yudhi Armyndharis4e538b814a93
diff --git a/src/modules/session/session.service.spec.ts b/src/modules/session/session.service.spec.ts
index 0a9a36d48..39b505971 100644
--- a/src/modules/session/session.service.spec.ts
+++ b/src/modules/session/session.service.spec.ts
@@ -6432,7 +6432,8 @@ describe('SessionService', () => {
(messageRepository.insert as jest.Mock).mockReset();
(webhookService.dispatch as jest.Mock).mockClear();
(messageRepository.insert as jest.Mock)
- .mockResolvedValueOnce(undefined) // first delivery: new row
+ // first delivery: new row
+ .mockResolvedValueOnce({ identifiers: [{ id: 'gen-uuid-1' }], generatedMaps: [], raw: undefined })
.mockRejectedValueOnce({
driverError: { code: 'SQLITE_CONSTRAINT_UNIQUE', message: 'UNIQUE constraint failed' },
}); // re-fire
@@ -6458,6 +6459,9 @@ describe('SessionService', () => {
expect(
((webhookService.dispatch as jest.Mock).mock.calls as unknown[][]).filter(c => c[1] === 'message.received'),
).toHaveLength(1);
+ expect(
+ ((hookManager.execute as jest.Mock).mock.calls as unknown[][]).filter(c => c[0] === 'message:persisted'),
+ ).toHaveLength(1);
});
it('still dispatches message.received when the insert fails with a non-constraint error (fail-open)', async () => {