Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

test(server): pin what a send reports while push is unavailable

Mauricee4f39bc8e7d2
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([