test(e2e): wait for the paired-reveal decoy to settle at its new size (#28319)

* test(e2e): read the parked-reveal decoy grid only after it settles at the new fit

* test(e2e): name the settle wait and give it the file's reveal timeout
This commit is contained in:
Jinwoo Hong
2026-10-13 10:00:18 -04:00
committed by GitHub
parent 4280eb118c
commit aa7afabb1d
@@ -191,6 +191,22 @@ async function readActivePaneGrid(
}, webTabId)
}
/** The pane's grid, or null while it differs from what its container fits. */
async function readFittedPaneGrid(
page: Page,
webTabId: string
): Promise<{ cols: number; rows: number } | null> {
return page.evaluate((id) => {
const manager = window.__paneManagers?.get(id)
const pane = manager?.getActivePane?.() ?? manager?.getPanes?.()[0] ?? null
const fit = pane?.fitAddon.proposeDimensions()
if (!pane || !fit || pane.terminal.cols !== fit.cols || pane.terminal.rows !== fit.rows) {
return null
}
return { cols: fit.cols, rows: fit.rows }
}, webTabId)
}
/** Reads the target tab's own buffer. `getTerminalContent` resolves whatever
* tab the store thinks is active, which hides per-tab reveal failures. */
async function readPaneContent(page: Page, webTabId: string): Promise<string> {
@@ -423,10 +439,25 @@ test('paired client keeps revealed remote terminals interactive', async ({
await openClientTab(client.page, worktreeId, decoys[0].webTabId)
const originalGrid = await readActivePaneGrid(client.page, target.webTabId)
await client.page.setViewportSize({ width: 960, height: 800 })
// Why fitted: a late reveal replay briefly parses at the host's old grid before refitting (#7279, #18132).
const fitted: { lastKey: string | null; settled: { cols: number; rows: number } | null } = {
lastKey: null,
settled: null
}
await expect
.poll(() => readActivePaneGrid(client.page, decoys[0].webTabId))
.not.toEqual(originalGrid)
const revealGrid = await readActivePaneGrid(client.page, decoys[0].webTabId)
.poll(
async () => {
const grid = await readFittedPaneGrid(client.page, decoys[0].webTabId)
const key = grid && JSON.stringify(grid)
const isNewFit = key !== null && key !== JSON.stringify(originalGrid)
fitted.settled = isNewFit && key === fitted.lastKey ? grid : null
fitted.lastKey = isNewFit ? key : null
return fitted.settled !== null
},
{ timeout: 60_000, message: 'decoy never settled at the new viewport fit' }
)
.toBe(true)
const revealGrid = fitted.settled
if (!revealGrid) {
throw new Error('visible decoy has no grid')
}