Files
accounted/lib/webhooks/__tests__/handler-subscriptions.test.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

30 lines
1020 B
TypeScript

/**
* registerWebhookHandler() must subscribe to exactly the catalogue in
* lib/webhooks/public-events.ts: an event an agent can subscribe to via the
* API but that the handler never fans out would be silently undeliverable.
*/
import { beforeEach, describe, expect, it, vi } from 'vitest'
vi.mock('@/lib/auth/api-keys', () => ({
createServiceClientNoCookies: vi.fn(() => ({ __client: true })),
}))
vi.mock('next/server', () => ({ after: vi.fn() }))
import { eventBus } from '@/lib/events/bus'
import { registerWebhookHandler } from '../handler'
import { PUBLIC_WEBHOOK_EVENTS } from '../public-events'
describe('registerWebhookHandler', () => {
beforeEach(() => {
eventBus.clear()
vi.clearAllMocks()
})
it('subscribes to every catalogued event type and nothing else', () => {
const on = vi.spyOn(eventBus, 'on')
registerWebhookHandler()
const subscribed = on.mock.calls.map(([eventType]) => eventType).sort()
expect(subscribed).toEqual([...PUBLIC_WEBHOOK_EVENTS].sort())
})
})