Wait for the order response in checkout e2e instead of sleeping
Trail-Session: codex:50c2b188-6c5a-4cb2-8e23-ce73e2a4ffc5
Trail-Link: http://localhost:8787/repos/web-app/session/50c2b188-6c5a-4cb2-8e23-ce73e2a4ffc5
Mmaya committed 1 day ago · maincommit 0a413766312468b03a35f6184c84cf2c7de9efec
Agent sessions behind this commit1
The checkout e2e test fails on CI about 1 run in 5. Figure out why and make it reliable.
Conversationcodex:50c2b188-6c5a-4cb2-8e23-ce73e2a4ffc5 · transcript lines 0–10
Artifacts1
Showing 1 changed file with 2 additions and 1 deletions.
e2e/checkout.spec.ts+2 −1
@@ -1,6 +1,7 @@
test("checkout", async ({ page }) => {
await page.goto("/cart");
+ const order = page.waitForResponse((r) => r.url().endsWith("/api/orders") && r.ok());
await page.click("text=Place order");
- await page.waitForTimeout(500);
+ await order; // a fixed 500ms sleep failed whenever the API took longer
await expect(page.locator("h1")).toHaveText("Thanks for your order");
});