[notifications] adopt strict zod types and extend test coverage (#36049)

* [notifications] adopt strict zod types and extend test coverage

* [notifications] validate expires date via schema

GitOrigin-RevId: 25dee0578ec443447e4c38a50a7e6c8b44831fe7
This commit is contained in:
Jakob Ackermann
2026-09-17 11:45:58 +00:00
committed by Copybot
parent eb36edac6d
commit f48132a70e
7 changed files with 413 additions and 29 deletions
@@ -24,9 +24,11 @@ async function makeNotification(notificationKey: string, userId: string) {
method: 'POST',
json: {
key: notificationKey,
messageOpts: '',
// must be an object: addNotification's schema models messageOpts as
// an arbitrary key/value map (see NotificationsController.ts), not a
// bare string
messageOpts: {},
templateKey: 'f4g5',
user_id: userId,
},
signal: AbortSignal.timeout(5000),
}
@@ -38,7 +40,7 @@ const getUserNotificationsResponseSchema = z
.object({
_id: zz.objectId(),
key: z.string(),
messageOpts: z.string().optional(),
messageOpts: z.record(z.string(), z.unknown()).optional(),
templateKey: z.string().optional(),
user_id: zz.objectId(),
})