From 0bf54b48eb10cce584b14d655ca954af7ae7163c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Wed, 9 Sep 2026 23:02:59 +0200 Subject: [PATCH] test(vaccinations): seed the a11y dose over the page's own connection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The scan's fixture was written with a Playwright API context. Every API context in a runner shares one process-wide keep-alive agent, so a request can be handed a socket the server has already closed on its five-second idle timeout, and a POST — unlike a GET — is never replayed on a fresh one. That is what ended this spec twice, on this line, on all three attempts each time: `socket hang up` and `read ECONNRESET`. The dose is written from the page instead. The browser opens its own connection, the service worker is blocked in this project, and the row still goes through the real route, so nothing about the fixture changes except which socket carries it. --- e2e/vaccinations.spec.ts | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/e2e/vaccinations.spec.ts b/e2e/vaccinations.spec.ts index 42f8f5ef4..e46fc2b95 100644 --- a/e2e/vaccinations.spec.ts +++ b/e2e/vaccinations.spec.ts @@ -282,16 +282,34 @@ test.describe("vaccinations", () => { test("the list and the capture form carry no serious accessibility violations", async ({ page, - request, }) => { // Seed one dose so the list scans a populated surface rather than the empty // state, then scan both the list and the open capture form. - const seeded = await request.post("/api/vaccinations", { - data: { occurredAt: "2019-05-01T00:00:00.000Z", antigenSlug: "polio" }, - }); - expect(seeded.status()).toBe(201); - + // + // Written from the page, not from a Playwright API context. Every API + // context in the runner shares ONE process-wide keep-alive agent + // (`httpHappyEyeballsAgent`), so a request can be handed a pooled socket the + // server has already closed on its five-second idle timeout — and a POST, + // unlike a GET, is never replayed on a fresh one. This seed died that way + // twice, on this line, on all three attempts each time: `socket hang up` + // and `read ECONNRESET`. The browser opens its own connection and the row + // is still written by the real route, so nothing about the fixture changes + // except which socket carries it. await page.goto("/vaccinations"); + const seededStatus = await page.evaluate(async () => { + const res = await fetch("/api/vaccinations", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ + occurredAt: "2019-05-01T00:00:00.000Z", + antigenSlug: "polio", + }), + }); + return res.status; + }); + expect(seededStatus).toBe(201); + + await page.reload(); await expect( page.locator('[data-slot="vaccination-group"][data-antigen="polio"]'), ).toBeVisible({ timeout: 15_000 });