From a9f7dadc3fd19e8c333cdde4eac0e6a1d72eaed2 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sun, 23 Aug 2026 12:58:55 -0700 Subject: [PATCH] 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. --- .../helpers/startup-exec-readiness-oracle.ts | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/e2e/helpers/startup-exec-readiness-oracle.ts b/tests/e2e/helpers/startup-exec-readiness-oracle.ts index 48b2928ed6d..0ef9a7eff67 100644 --- a/tests/e2e/helpers/startup-exec-readiness-oracle.ts +++ b/tests/e2e/helpers/startup-exec-readiness-oracle.ts @@ -83,15 +83,24 @@ async function expectSingleOwningPty( terminal: string, ptyId: string ): Promise { - const listed = await callStartupExecRuntime(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( + 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(