From 2ccd022410b367de2c72dd328e8444832c9caf88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 6 Aug 2026 04:05:33 +0200 Subject: [PATCH] test: update notification sender attempt mocks - Exercise identity-aware delivery attempt recording\n- Keep self-delivery assertions explicit --- src/lib/notifications/__tests__/client-managed-apns.test.ts | 3 ++- src/lib/notifications/__tests__/web-push-dose-clear.test.ts | 1 + src/lib/notifications/__tests__/web-push-egress-pin.test.ts | 1 + src/lib/notifications/senders/__tests__/email.test.ts | 5 +++++ src/lib/notifications/senders/__tests__/telegram.test.ts | 1 + src/lib/notifications/senders/__tests__/urgency.test.ts | 5 +++++ src/lib/notifications/senders/__tests__/webhook.test.ts | 5 +++++ 7 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/lib/notifications/__tests__/client-managed-apns.test.ts b/src/lib/notifications/__tests__/client-managed-apns.test.ts index 9121c89a5..75a7a7b8c 100644 --- a/src/lib/notifications/__tests__/client-managed-apns.test.ts +++ b/src/lib/notifications/__tests__/client-managed-apns.test.ts @@ -137,7 +137,8 @@ describe("dispatchNotification — client-managed APNs suppression", () => { }, ); expect(recordPushAttemptMock).toHaveBeenCalledWith({ - userId: "u-1", + recordUserId: "u-1", + recipientUserId: "u-1", channel: "APNS", eventType: "MEDICATION_REMINDER", result: "skipped", diff --git a/src/lib/notifications/__tests__/web-push-dose-clear.test.ts b/src/lib/notifications/__tests__/web-push-dose-clear.test.ts index 5fd17e260..684a85cea 100644 --- a/src/lib/notifications/__tests__/web-push-dose-clear.test.ts +++ b/src/lib/notifications/__tests__/web-push-dose-clear.test.ts @@ -45,6 +45,7 @@ vi.mock("@/lib/logging/context", () => ({ vi.mock("@/lib/notifications/senders/push-attempt-record", () => ({ recordPushAttempt: vi.fn(), + recordPushAttemptForPayload: vi.fn(), })); vi.mock("@/lib/db", () => ({ diff --git a/src/lib/notifications/__tests__/web-push-egress-pin.test.ts b/src/lib/notifications/__tests__/web-push-egress-pin.test.ts index 00885c993..488d4574b 100644 --- a/src/lib/notifications/__tests__/web-push-egress-pin.test.ts +++ b/src/lib/notifications/__tests__/web-push-egress-pin.test.ts @@ -38,6 +38,7 @@ vi.mock("@/lib/logging/context", () => ({ vi.mock("@/lib/notifications/senders/push-attempt-record", () => ({ recordPushAttempt: vi.fn(), + recordPushAttemptForPayload: vi.fn(), })); vi.mock("@/lib/db", () => ({ diff --git a/src/lib/notifications/senders/__tests__/email.test.ts b/src/lib/notifications/senders/__tests__/email.test.ts index 5abbb7cd9..998ec15f6 100644 --- a/src/lib/notifications/senders/__tests__/email.test.ts +++ b/src/lib/notifications/senders/__tests__/email.test.ts @@ -31,6 +31,11 @@ vi.mock("@/lib/logging/context", () => ({ vi.mock("@/lib/notifications/senders/push-attempt-record", () => ({ recordPushAttempt: (...args: unknown[]) => recordPushAttemptMock(...args), + recordPushAttemptForPayload: ( + _payload: unknown, + _recipientUserId: string, + attempt: unknown, + ) => recordPushAttemptMock(attempt), })); import { sendViaEmail, resetEmailTransporterForTesting } from "../email"; diff --git a/src/lib/notifications/senders/__tests__/telegram.test.ts b/src/lib/notifications/senders/__tests__/telegram.test.ts index 9439062dd..80e6fe7d4 100644 --- a/src/lib/notifications/senders/__tests__/telegram.test.ts +++ b/src/lib/notifications/senders/__tests__/telegram.test.ts @@ -42,6 +42,7 @@ vi.mock("@/lib/logging/context", () => ({ vi.mock("@/lib/notifications/senders/push-attempt-record", () => ({ recordPushAttempt: vi.fn(), + recordPushAttemptForPayload: vi.fn(), })); const scheduleTelegramAutoDeleteMock = vi.fn(); diff --git a/src/lib/notifications/senders/__tests__/urgency.test.ts b/src/lib/notifications/senders/__tests__/urgency.test.ts index e23a15f44..bf94783ac 100644 --- a/src/lib/notifications/senders/__tests__/urgency.test.ts +++ b/src/lib/notifications/senders/__tests__/urgency.test.ts @@ -35,6 +35,11 @@ vi.mock("@/lib/logging/context", () => ({ vi.mock("@/lib/notifications/senders/push-attempt-record", () => ({ recordPushAttempt: (...args: unknown[]) => recordPushAttemptMock(...args), + recordPushAttemptForPayload: ( + _payload: unknown, + _recipientUserId: string, + attempt: unknown, + ) => recordPushAttemptMock(attempt), })); vi.mock("@/lib/db", () => ({ diff --git a/src/lib/notifications/senders/__tests__/webhook.test.ts b/src/lib/notifications/senders/__tests__/webhook.test.ts index eaddccc2b..aab98366d 100644 --- a/src/lib/notifications/senders/__tests__/webhook.test.ts +++ b/src/lib/notifications/senders/__tests__/webhook.test.ts @@ -27,6 +27,11 @@ vi.mock("@/lib/logging/context", () => ({ vi.mock("@/lib/notifications/senders/push-attempt-record", () => ({ recordPushAttempt: (...args: unknown[]) => recordPushAttemptMock(...args), + recordPushAttemptForPayload: ( + _payload: unknown, + _recipientUserId: string, + attempt: unknown, + ) => recordPushAttemptMock(attempt), })); import { sendViaWebhook } from "../webhook";