Complete worked example
typescript
import { test, expect } from "../support/test.js";
test("complete local role workflow", async ({page}) => {
await page.goto("/");
await page.getByRole("button", {name:"Sign in",exact:true}).click();
await expect(page.getByText("User: alice", {exact:true})).toBeVisible();
await page.getByLabel("Country", {exact:true}).selectOption("UA");
await page.getByLabel("Search roles").fill("qa");
await expect(page.getByRole("list", {name:"Matching roles"}).getByRole("listitem")).toHaveCount(1);
await page.getByRole("button", {name:"Save QA Engineer",exact:true}).click();
await expect(page.getByRole("list", {name:"Saved roles"})).toContainText("r1");
await page.reload();
await expect(page.getByRole("list", {name:"Saved roles"})).toContainText("r1");
expect(await (await page.request.get("/api/saved")).json()).toEqual({ids:["r1"]});
});- Reasoning
- The browser actions are connected to exact membership and a persisted account-specific postcondition.