test: await subscriber and late-proof SQL observations

This commit is contained in:
Brennan Benson
2026-11-10 05:57:46 -08:00
parent 445fdad212
commit 595f50610f
2 changed files with 13 additions and 13 deletions
@@ -1,7 +1,7 @@
import { mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { AGENT_JOURNAL_THREAD_SCOPE } from '../../../../../../shared/agent-session/journal/agent-session-journal-types'
import { claudeProviderHandle } from '../../../../../../shared/agent-session/lifecycle/agent-session-provider-handle-encoding'
import type { AgentSessionSubscribeEvent } from '../../../../../../shared/agent-session/agent-session-wire'
@@ -71,7 +71,7 @@ describe('the background-task roster on subscriber frames', () => {
fence: 1,
emit: toPane
})
expect(pane.backgroundTasks).toEqual(MONITORING)
await vi.waitFor(() => expect(pane.backgroundTasks).toEqual(MONITORING))
close()
roster = null
subscribers.republishBackgroundTasks(SESSION, 1)
@@ -87,6 +87,6 @@ describe('the background-task roster on subscriber frames', () => {
emit: toPane
})
expect(pane.backgroundTasks).toBeNull()
await vi.waitFor(() => expect(pane.backgroundTasks).toBeNull())
})
})
@@ -115,14 +115,14 @@ describe('a proof written after an unverifiable settle', () => {
])
await settle(2, null)
expect(turnState('turn-1')).toBe('unverifiable')
expect(callLifecycle('turn-1', 1)).toBe('failed')
expect(await turnState('turn-1')).toBe('unverifiable')
expect(await callLifecycle('turn-1', 1)).toBe('failed')
await settle(3, proofFor(1))
expect(turnState('turn-1')).toBe('interrupted')
expect(callLifecycle('turn-1', 1)).toBe('interrupted')
expect(callLifecycle('turn-1', 2)).toBe('failed')
expect(callLifecycle('turn-1', 3)).toBe('completed')
expect(await turnState('turn-1')).toBe('interrupted')
expect(await callLifecycle('turn-1', 1)).toBe('interrupted')
expect(await callLifecycle('turn-1', 2)).toBe('failed')
expect(await callLifecycle('turn-1', 3)).toBe('completed')
const corrected = journal.cursor()
await expect(settle(4, proofFor(1))).resolves.toBe(0)
@@ -134,7 +134,7 @@ describe('a proof written after an unverifiable settle', () => {
await settle(2, null)
await seedTurn('turn-2', 2)
await settle(3, null)
expect(callLifecycle('turn-2', 1)).toBe('failed')
expect(await callLifecycle('turn-2', 1)).toBe('failed')
const unrevised = journal.cursor()
// Other-owner and legacy ownerless proof cannot settle this generation.
@@ -143,8 +143,8 @@ describe('a proof written after an unverifiable settle', () => {
expect(journal.cursor()).toEqual(unrevised)
await settle(4, proofFor(1))
expect(callLifecycle('turn-1', 1)).toBe('interrupted')
expect(turnState('turn-2')).toBe('unverifiable')
expect(callLifecycle('turn-2', 1)).toBe('failed')
expect(await callLifecycle('turn-1', 1)).toBe('interrupted')
expect(await turnState('turn-2')).toBe('unverifiable')
expect(await callLifecycle('turn-2', 1)).toBe('failed')
})
})