fix architecture and write new tests

This commit is contained in:
root
2026-06-10 00:40:19 -04:00
parent 560da1cadf
commit 80a597bc10
377 changed files with 84020 additions and 1337 deletions
@@ -0,0 +1,27 @@
import { describe, expect, it } from 'vitest'
import { historyQuerySchema, idParamSchema, preferencesSchema, unreadQuerySchema } from './notification.schemas'
describe('notification schema contracts', () => {
it('requires complete preference entries', () => {
expect(preferencesSchema.parse([{ notificationType: 'BOOKING_CREATED', channel: 'EMAIL', enabled: true }])).toEqual([
{ notificationType: 'BOOKING_CREATED', channel: 'EMAIL', enabled: true },
])
expect(() => preferencesSchema.parse([{ notificationType: 'BOOKING_CREATED', channel: 'EMAIL' }])).toThrow()
})
it('coerces history limits and caps bulk history requests', () => {
expect(historyQuerySchema.parse({ channel: 'EMAIL', status: 'SENT', limit: '25' })).toEqual({
channel: 'EMAIL',
status: 'SENT',
limit: 25,
})
expect(() => historyQuerySchema.parse({ limit: '0' })).toThrow()
expect(() => historyQuerySchema.parse({ limit: '501' })).toThrow()
})
it('accepts unread query passthrough but rejects empty ids', () => {
expect(unreadQuerySchema.parse({ unread: 'true' })).toEqual({ unread: 'true' })
expect(idParamSchema.parse({ id: 'notification_1' })).toEqual({ id: 'notification_1' })
expect(() => idParamSchema.parse({ id: '' })).toThrow()
})
})