test: update notification sender attempt mocks

- Exercise identity-aware delivery attempt recording\n- Keep self-delivery assertions explicit
This commit is contained in:
Marc-André Bombeck committed 2026-08-06 04:05:33 +02:00
1 parent d9b675f993
commit 2ccd022410
7 files changed
+20 -1

No files matched your search

@@ -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",
@@ -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", () => ({
@@ -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", () => ({
@@ -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";
@@ -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();
@@ -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", () => ({
@@ -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";