From 3df6179d5b462a900313065d80ac4b75f974a902 Mon Sep 17 00:00:00 2001 From: Federico Kamelhar Date: Tue, 5 May 2026 23:58:25 -0400 Subject: [PATCH] test(workbench/e2e): poll for Model B/C options before selectOption MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Anthropic sweep flaked on tutorials #01 and #02 because configureAnthropic() only polled for Model A's option to appear in the cfg-model dropdown — it then fired selectOption on cfg-model-b immediately, racing the WebDriver layer's view of the populated options. Playwright would retry for ~65s and eventually the test timed out with "Target page, context or browser has been closed". Mirror the existing A poll for B and C: wait for the desired option text to be visible in the dropdown before calling selectOption. Same 15s budget, same toPass shape. Fixes the flake; the sweep ran 32/32 green in 9.5 min after this change. Signed-off-by: Federico Kamelhar --- workbench/e2e/tests/all-anthropic.spec.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/workbench/e2e/tests/all-anthropic.spec.ts b/workbench/e2e/tests/all-anthropic.spec.ts index 2857a8a..453ee87 100644 --- a/workbench/e2e/tests/all-anthropic.spec.ts +++ b/workbench/e2e/tests/all-anthropic.spec.ts @@ -57,8 +57,21 @@ async function configureAnthropic(page: Page): Promise { expect(opts.includes(MODEL)).toBe(true); }).toPass({ timeout: 15_000 }); await page.getByTestId("cfg-model").selectOption(MODEL); - if (MODEL_B) await page.getByTestId("cfg-model-b").selectOption(MODEL_B); - if (MODEL_C) await page.getByTestId("cfg-model-c").selectOption(MODEL_C); + // The B/C dropdowns are populated by the same setModelOptions pass + // as A but the option list may not have flushed to the WebDriver + // layer by the time selectOption fires — poll for the target option + // to exist before attempting to set it. + for (const [tid, value] of [ + ["cfg-model-b", MODEL_B] as const, + ["cfg-model-c", MODEL_C] as const, + ]) { + if (!value) continue; + await expect(async () => { + const opts = await page.getByTestId(tid).locator("option").allTextContents(); + expect(opts.includes(value)).toBe(true); + }).toPass({ timeout: 15_000 }); + await page.getByTestId(tid).selectOption(value); + } await page.getByTestId("settings-save").click(); }