Complete worked example
typescript
import { test, expect } from "../support/test.js";
test("invalid limit can be corrected", async ({page}) => {
await page.goto("/");
const field = page.getByLabel("Page limit");
await field.fill("0");
await page.getByRole("button", {name:"Check limit",exact:true}).click();
await expect(page.getByText("Enter a whole number from 1 to 3")).toBeVisible();
await field.fill("2");
await field.press("Enter");
await expect(page.getByText("Limit accepted", {exact:true})).toBeVisible();
});- Reasoning
- The test observes both invalid feedback and successful correction through the actual form.