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>
This commit is contained in:
blinkagent[bot]
2026-02-27 16:32:16 -05:00
committed by GitHub
co-authored by blink-so[bot]
parent 1a87e74574
commit 8bb80b060e
+10 -2
View File
@@ -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: