test: poll terminal readiness in expectSingleOwningPty

Retry the terminal list assertion with polling to account for timing
delays in PTY state reporting from the runtime.
This commit is contained in:
Jinjing
2026-08-23 12:58:55 -07:00
parent 86c583a739
commit a9f7dadc3f
@@ -83,15 +83,24 @@ async function expectSingleOwningPty(
terminal: string,
ptyId: string
): Promise<void> {
const listed = await callStartupExecRuntime<RuntimeTerminalListResult>(page, 'terminal.list', {
worktree: `id:${worktreeId}`,
requireFreshPtyLiveness: true
})
expect(
listed.terminals
.filter((candidate) => candidate.tabId === tabId)
.map((candidate) => ({ handle: candidate.handle, ptyId: candidate.ptyId }))
).toEqual([{ handle: terminal, ptyId }])
await expect
.poll(
async () => {
const listed = await callStartupExecRuntime<RuntimeTerminalListResult>(
page,
'terminal.list',
{
worktree: `id:${worktreeId}`,
requireFreshPtyLiveness: true
}
)
return listed.terminals
.filter((candidate) => candidate.tabId === tabId)
.map((candidate) => ({ handle: candidate.handle, ptyId: candidate.ptyId }))
},
{ timeout: 30_000 }
)
.toEqual([{ handle: terminal, ptyId }])
}
export async function callStartupExecRuntime<TResult>(