test: use toHaveValue() to avoid flaky parameter verification (#20990)

## Problem

The test `create workspace with default and required parameters` was
flaky because `verifyParameters` in `site/e2e/helpers.ts` didn't wait
for input values to be populated before asserting.

After PR #20710 removed classic parameters, the form now uses dynamic
parameters loaded asynchronously via WebSocket. The input field can be
visible before its value is populated.

Closes https://github.com/coder/internal/issues/1154

## Fix

Replace immediate read + assertion:
```typescript
const value = await parameterField.inputValue();
expect(value).toEqual(buildParameter.value);
```

With Playwright's auto-retrying assertion:
```typescript
await expect(parameterField).toHaveValue(buildParameter.value);
```

From [Playwright docs for
`inputValue()`](https://playwright.dev/docs/api/class-locator#locator-input-value):

> **NOTE** If you need to assert input value, prefer
`expect(locator).toHaveValue(value[, options])` to avoid flakiness. See
assertions guide for more details.

---

This PR was fully generated by [mux](https://github.com/coder/mux), and
reviewed by a human.
This commit is contained in:
Ethan
2025-12-01 13:46:19 +11:00
committed by GitHub
parent 7d45d078f2
commit 782a1052c8
+1 -2
View File
@@ -207,8 +207,7 @@ export const verifyParameters = async (
case "number":
{
const parameterField = parameterLabel.locator("input");
const value = await parameterField.inputValue();
expect(value).toEqual(buildParameter.value);
await expect(parameterField).toHaveValue(buildParameter.value);
}
break;
default: