🧪 test: Let Theme Paint Route Handlers Settle Before Teardown (#18059)

"the ClickHouse theme paints its own link, code fill and QR backdrop" and "a theme that names only its link colours Markdown links in both modes and can recolour the QR backdrop" each failed a first attempt in 1 of 70 pull request runs on Nov 11 with "apiResponse.json: Response has been disposed", thrown from the `/api/config` route handler after every assertion had passed.

The app requests `/api/config` three times while it starts, the third about 90ms after the first two. Both tests end within a few milliseconds of that request, so it can still be inside `serveThemes` when the body returns: in one CI trace the handler's fetch starts 1ms before the last assertion and finishes 10ms after the context began closing. Closing the context disposes the fetched response, `response.json()` throws, and Playwright reports the handler's error against the finished test.

Every test in the file now waits for its route handlers to finish before the context is torn down. A handler that throws for any other reason is still reported; only the race against teardown is gone.
This commit is contained in:
Danny Avila 2026-11-11 12:50:16 -05:00 • committed by GitHub
parent 1ef7d244b5
commit 12c3dda7cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -152,6 +152,16 @@ function paintRoles(page: Page) {
const rgb = (channels: string | undefined) => `rgb(${(channels ?? '').split(' ').join(', ')})`;
test.describe('controlled theme paint', () => {
/**
* The app asks for `/api/config` again once the session resolves, and that request can still be
* inside a `serveThemes` handler when a test body returns. Closing the context under it disposes
* the fetched response, which fails the finished test from the handler, so each test lets its
* handlers settle first.
*/
test.afterEach(async ({ page }) => {
await page.unrouteAll({ behavior: 'wait' });
});
test("a shared link's first frame of the conversation already wears the link tenant's theme @scenario:shared-link-first-frame-wears-link-theme", async ({
page,
}) => {