openpencil/tests/engine/app/diagnostics/subscriptions.test.ts
Danila Poyarkov 5f8a373b2b
feat(diagnostics): add local usage and diagnostics foundation
Supersedes #572. Adds local structured AI usage and diagnostics history, typed diagnostic events, localized Usage/Diagnostics settings, shared IndexedDB lifecycle, and consolidated button/dialog primitives.
2026-08-24 16:56:40 +03:00

23 lines
601 B
TypeScript

import { describe, expect, test } from 'bun:test'
import { diagnostics, recordChatCompleted } from '@/app/diagnostics'
describe('diagnostic subscriptions', () => {
test('notifies on record and clear, then unsubscribes', async () => {
await diagnostics.clear()
let calls = 0
const unsubscribe = diagnostics.subscribe(() => {
calls++
})
recordChatCompleted({ finishReason: 'stop' })
await diagnostics.clear()
expect(calls).toBe(2)
unsubscribe()
recordChatCompleted({ finishReason: 'stop' })
expect(calls).toBe(2)
await diagnostics.clear()
})
})