Complete worked example
typescript
import { test, expect } from "../support/test.js";
test("save is idempotent through HTTP", async ({request}) => {
await request.post("/api/login", {data:{user:"alice"}});
expect((await request.put("/api/saved/r1")).status()).toBe(204);
expect((await request.put("/api/saved/r1")).status()).toBe(204);
const response = await request.get("/api/saved");
expect(await response.json()).toEqual({ids:["r1"]});
});- Reasoning
- The read-back checks both the correct id and absence of duplicates.