From e4f39bc8e7d22256d793008f87413e2f46a5cde8 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 8 Oct 2026 14:11:53 +0200 Subject: [PATCH] test(server): pin what a send reports while push is unavailable NotificationsService.send() now reports how many deliveries it attempted and how many went out, so the reminder jobs can tell a failed send from a sent one. WPDISP-008 and WPDISP-011 asserted that the send resolved to undefined, which only meant "no error" and broke on the new result. They now pin the counts: the in-app row and the webhook go out, and a push the broken key pair cannot send is skipped rather than counted as failed. --- .../tests/unit/nest/notifications/web-push-dispatch.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/tests/unit/nest/notifications/web-push-dispatch.test.ts b/server/tests/unit/nest/notifications/web-push-dispatch.test.ts index 0fede7500..bce4694dc 100644 --- a/server/tests/unit/nest/notifications/web-push-dispatch.test.ts +++ b/server/tests/unit/nest/notifications/web-push-dispatch.test.ts @@ -222,7 +222,8 @@ describe('Web Push while the stored key pair cannot be used', () => { setNotificationChannels(testDb, 'webhook,push'); breakStoredPrivateKey(); - await expect(invite(user.id, actor.id)).resolves.toBeUndefined(); + // In-app and the webhook go out; the skipped push is no failed delivery. + await expect(invite(user.id, actor.id)).resolves.toEqual({ attempted: 2, delivered: 2 }); expect(pushedTo()).toEqual(['https://hooks.example.test/trek']); const inApp = testDb.prepare('SELECT COUNT(*) AS n FROM notifications WHERE recipient_id = ?').get(user.id) as { @@ -290,7 +291,8 @@ describe('Web Push while the VAPID_* pair is broken and an older pair is stored' // A typo or a rotated Secret: still a valid 32-byte key, so boot is fine. vi.stubEnv('VAPID_PRIVATE_KEY', generateVapidKeyPair().privateKey); - await expect(invite(user.id, actor.id)).resolves.toBeUndefined(); + // Only the in-app row goes out; the push it cannot send counts as skipped, not failed. + await expect(invite(user.id, actor.id)).resolves.toEqual({ attempted: 1, delivered: 1 }); expect(safeFetchFollow).not.toHaveBeenCalled(); expect((await subscriptions.listForUser(user.id)).map((r) => [r.endpoint, r.vapid_public_key])).toEqual([