openpencil/tests/engine/app/diagnostics/transport.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

39 lines
989 B
TypeScript

import { describe, expect, test } from 'bun:test'
import {
diagnostics,
recordACPTransportFailure,
recordMCPConnectionFailure
} from '@/app/diagnostics'
describe('transport diagnostic events', () => {
test('records safe ACP failures', async () => {
await diagnostics.clear()
recordACPTransportFailure({
operation: 'message',
errorName: 'NetworkError',
errorCode: null,
retryable: true
})
const [event] = await diagnostics.list()
expect(event?.name).toBe('acp.transport.failed')
expect(event?.attributes).toEqual({
operation: 'message',
errorName: 'NetworkError',
errorCode: null,
retryable: true
})
})
test('rejects invalid MCP operations', async () => {
await diagnostics.clear()
recordMCPConnectionFailure({
operation: 'invalid' as 'connect',
errorName: 'Error',
errorCode: null,
retryable: null
})
expect(await diagnostics.list()).toHaveLength(0)
})
})