test(e2e): wait for login form hydration before filling

The customJsx E2E test occasionally failed at login with the form
showing 'This field is required' on the username, because the submit
button was clicked while the form was still hydrating (it is disabled
until mounted) and the field values were reset by the re-mount. Wait
for the submit button to become enabled before filling, and assert the
username value stuck before submitting.
This commit is contained in:
Thomas Camlong committed 2026-08-07 15:49:21 +02:00
1 parent 17f08c6d14
commit 926b7e2a5e
1 file changed
+6 -1
+6 -1
View File
@@ -43,9 +43,14 @@ describe("Custom JSX custom widgets", () => {
try {
await page.goto(`${baseUrl}/auth/login`);
// The submit button is disabled until the form finishes hydrating, so wait for it
// before filling to avoid a hydration re-mount resetting the field values.
const submitButton = page.locator("css=button[type='submit']");
await expect(submitButton).toBeEnabled({ timeout: 30_000 });
await page.getByLabel("Username").fill(adminCredentials.username);
await page.locator("#password").fill(adminCredentials.password);
await page.locator("css=button[type='submit']").click();
await expect(page.getByLabel("Username")).toHaveValue(adminCredentials.username);
await submitButton.click();
await expect(page).not.toHaveURL(/\/auth\/login/, { timeout: 30_000 });
await page.goto(`${baseUrl}/manage/custom-widgets/new`);