From 8bb80b060e0330f0dbce0a80e9247038ad312f7b Mon Sep 17 00:00:00 2001 From: "blinkagent[bot]" <237617714+blinkagent[bot]@users.noreply.github.com> Date: Fri, 27 Feb 2026 16:32:16 -0500 Subject: [PATCH] fix(e2e): fix flaky verifyParameters assertion in updateWorkspace test (#22413) ## Problem The `update workspace, new required, mutable parameter added` e2e test has been flaking consistently ([internal#1328](https://github.com/coder/internal/issues/1328)). The error: ``` Error: Timed out 5000ms waiting for expect(locator).toHaveValue(expected) Locator: getByTestId('parameter-field-Sixth parameter').locator('input') Expected string: "99" Received string: "" ``` ## Root Cause A race between page navigation and data hydration in `verifyParameters`: 1. The page navigates with `waitUntil: "domcontentloaded"` which does not wait for API responses to settle 2. React Query may serve stale cached workspace data initially (from before the update), causing the form to render with empty/old parameter values 3. The `toHaveValue` assertion uses the default `actionTimeout` of 5000ms which isn't enough time for fresh data to arrive and the form to re-render ## Fix - Switch `verifyParameters` navigation to `waitUntil: "networkidle"` to ensure API responses (workspace data, build parameters) are settled before the form renders - Increase the `toHaveValue` timeout to 15s to handle cases where dynamic parameters hydrate slowly after initial render Fixes coder/internal#1328 --------- Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com> --- site/e2e/helpers.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/site/e2e/helpers.ts b/site/e2e/helpers.ts index 6c170429b9..60b06b3803 100644 --- a/site/e2e/helpers.ts +++ b/site/e2e/helpers.ts @@ -171,8 +171,11 @@ export const verifyParameters = async ( expectedBuildParameters: WorkspaceBuildParameter[], ) => { const user = currentUser(page); + // Use networkidle to ensure all API responses (workspace data, build + // parameters) are settled before verifying values. Using domcontentloaded + // can cause the form to render with stale React Query cache data. await page.goto(`/@${user.username}/${workspaceName}/settings/parameters`, { - waitUntil: "domcontentloaded", + waitUntil: "networkidle", }); for (const buildParameter of expectedBuildParameters) { @@ -209,7 +212,12 @@ export const verifyParameters = async ( case "number": { const parameterField = parameterLabel.locator("input"); - await expect(parameterField).toHaveValue(buildParameter.value); + // Dynamic parameters can hydrate after initial render with + // stale or empty values. Retry with a longer timeout to + // allow the page to settle. + await expect(parameterField).toHaveValue(buildParameter.value, { + timeout: 15_000, + }); } break; default: