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.
23 lines
601 B
TypeScript
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()
|
|
})
|
|
})
|