test(opencode2): cover live form lifecycle

This commit is contained in:
Neil
2026-09-19 17:16:22 -07:00
parent 4fa90bfe67
commit 00d4cf6a4e
2 changed files with 29 additions and 1 deletions
@@ -149,6 +149,10 @@ describe('OpenCode 2 setup and prompt ordering', () => {
type: 'permission.asked',
data: { id: 'perm-1', sessionID: 'ses_root', action: 'bash', resources: ['pwd'] }
}
yield {
type: 'permission.replied',
data: { id: 'perm-1', requestID: 'perm-1', sessionID: 'ses_root' }
}
yield {
type: 'form.created',
data: {
@@ -189,6 +193,30 @@ describe('OpenCode 2 setup and prompt ordering', () => {
)
expect(names).toEqual(expect.arrayContaining(['PermissionRequest', 'MessagePart']))
})
await vi.waitFor(() => {
const names = posts.map(
({ body }) => (body.payload as Record<string, unknown>)?.hook_event_name
)
expect(names).toContain('AskUserQuestion')
expect(posts).toEqual(
expect.arrayContaining([
expect.objectContaining({
body: expect.objectContaining({
payload: expect.objectContaining({
hook_event_name: 'AskUserQuestion',
sessionID: 'ses_root'
})
})
})
])
)
})
await vi.waitFor(() => {
const names = posts.map(
({ body }) => (body.payload as Record<string, unknown>)?.hook_event_name
)
expect(names).toContain('SessionIdle')
})
await cleanup?.()
})
@@ -150,7 +150,7 @@ describe('client-hosted screenshot markup', () => {
image: backdrop,
displayCssWidth: 800,
displayCssHeight: 600,
['shapes']: []
shapes: []
})
)
await waitFor(() => expect(overlay()).toBeNull())