test(native-chat): prove callback error ordering

This commit is contained in:
Jinwoo-H
2026-08-23 14:35:55 -07:00
committed by Brennan Benson
parent 9907dd1073
commit c8d2408bf2
@@ -167,12 +167,14 @@ describe('native chat transcript watcher errors', () => {
const filePath = join(root, 'transcript.jsonl')
await mkdir(filePath)
const snapshots: string[][] = []
let errorCallbackCount = 0
const subscription = await subscribeNativeChatTranscript({
agent: 'claude',
sessionId: 'session',
filePath,
onInitialSnapshot: (messages, _hasMore, _beforeOffset, error) => {
if (error) {
errorCallbackCount += 1
throw new Error('subscriber is closing')
}
snapshots.push(messages.map((message) => message.id))
@@ -183,6 +185,7 @@ describe('native chat transcript watcher errors', () => {
})
try {
await vi.waitFor(() => expect(errorCallbackCount).toBe(1))
await rm(filePath, { recursive: true, force: true })
await writeFile(filePath, claudeLine('u-recovered-after-throw', 'user', 'back'))
await vi.waitFor(() => expect(snapshots).toContainEqual(['u-recovered-after-throw']))