test: order restart fixture readiness around daemon recovery (#18949)

This commit is contained in:
Neil
2026-09-05 17:26:54 -07:00
committed by GitHub
parent 6a3e446c69
commit 2e2ecc5193
2 changed files with 23 additions and 1 deletions
@@ -283,6 +283,24 @@ async function expectTerminalInteractive(
}
async function moveHostAwayFromWorktree(page: Page, targetWorktreeId: string): Promise<string> {
await expect
.poll(
() =>
page.evaluate(async (targetId) => {
const state = window.__store?.getState()
const target = state?.allWorktrees().find((worktree) => worktree.id === targetId)
if (!state || !target) {
return false
}
await state.fetchWorktrees(target.repoId)
return window
.__store!.getState()
.allWorktrees()
.some((worktree) => worktree.repoId === target.repoId && worktree.id !== targetId)
}, targetWorktreeId),
{ message: 'Seeded alternate host worktree never loaded' }
)
.toBe(true)
const alternateWorktreeId = await page.evaluate((targetId) => {
const state = window.__store?.getState()
const alternate = state?.allWorktrees().find((worktree) => worktree.id !== targetId)
@@ -423,6 +441,9 @@ test('foregrounds a preserved daemon PTY after the paired host relaunches', asyn
expect(reconnectControl.ptyId).not.toBe(target.ptyId)
await openClientTab(client.page, worktreeId, reconnectControl.webTabId)
await waitForPaneConnected(client.page, reconnectControl.webTabId)
await expect
.poll(() => readPaneContent(client!.page, reconnectControl.webTabId), { timeout: 30_000 })
.toContain('READY')
await expectTerminalInteractive(client, reconnectControl, 'y')
} finally {
if (client) {
@@ -239,7 +239,6 @@ test('restored pane recovers input after the daemon un-wedges', async (// oxlint
const second = await session.launch()
secondApp = second.app
await settleRestoredLaunch(second.page)
// Field-fidelity check, not a hard gate: does the pane paint restored
// content while its PTY attach cannot complete? That visible-but-dead
@@ -258,6 +257,8 @@ test('restored pane recovers input after the daemon un-wedges', async (// oxlint
}
stoppedDaemonPid = null
// Session readiness requires a daemon response; resume it before waiting for restoration.
await settleRestoredLaunch(second.page)
await expectRestoredPaneAcceptsInput(
second.page,
`daemon wedged during relaunch (painted while wedged: ${paintedWhileWedged}, ` +