From 706b683225a5044285a8297369d054987a45dea9 Mon Sep 17 00:00:00 2001 From: DreamCoder08 Date: Sun, 22 Nov 2026 18:22:14 -0500 Subject: [PATCH] test(e2e): measure the idle 3D globe only after the page rests The relief refines for a few frames after it reports loaded. On a slow CI runner each frame takes 300-400 ms, and those frames outlasted the fixed one-second wait, failing main twice (runs 45073984924 and 45080755271: idle 3D long tasks [335, 315, 303] and [396, 404] ms) while the same commits passed on their pull requests. The guard now waits for a full second without a long task before measuring. A globe that re-renders every frame never rests, so the old freeze still fails it, now with "the page never rests" (checked by turning requestRenderMode off). 20 of 20 repeats pass with 2 workers. --- apps/e2e/tests/territorio-long-tasks.spec.ts | 23 +++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/e2e/tests/territorio-long-tasks.spec.ts b/apps/e2e/tests/territorio-long-tasks.spec.ts index 481e8246..2f8c735c 100644 --- a/apps/e2e/tests/territorio-long-tasks.spec.ts +++ b/apps/e2e/tests/territorio-long-tasks.spec.ts @@ -27,12 +27,17 @@ const drain = (page: Page) => const sum = (values: readonly number[]) => values.reduce((a, b) => a + b, 0); /** - * Waits until half a second passes without a long task. A layer's first draw is a one-time cost - * of opening the map; it must be paid before the switch is measured, not counted against it. + * Waits until `quietMs` pass without a long task. A layer's first draw is a one-time cost of opening + * the map; it must be paid before the switch is measured, not counted against it. A page that never + * rests (a globe re-rendering every frame) never passes, and the guard fails here. */ -const settle = (page: Page) => +const settle = (page: Page, quietMs = 500) => expect - .poll(async () => (await drain(page)).length, { intervals: [500], timeout: 30_000 }) + .poll(async () => (await drain(page)).length, { + message: `no ${quietMs} ms without a long task: the page never rests`, + intervals: [quietMs], + timeout: 30_000, + }) .toBe(0); test('Territorio switches between 2D and 3D without long main-thread freezes', async ({ @@ -58,10 +63,12 @@ test('Territorio switches between 2D and 3D without long main-thread freezes', a await page.getByRole('button', { name: 'Vista 3D' }).click(); const terrain = page.locator('[data-map-engine="cesium"]'); await expect(terrain).toHaveAttribute('aria-busy', 'false', { timeout: 30_000 }); - // The globe draws only when something changes: once the relief has settled it stays idle. - // A fixed window is the measurement itself, not a wait for state. - await page.waitForTimeout(1_000); - await drain(page); + // The globe draws only when something changes: once the relief has settled it stays idle. The + // relief refines for a few frames after it reports loaded; on a slow CI runner each frame takes + // 300–400 ms and those frames outlasted a fixed one-second wait (main, runs 45073984924 and + // 45080755271). So wait for a full second at rest, then measure. A fixed window is the + // measurement itself, not a wait for state. + await settle(page, 1_000); await page.waitForTimeout(2_000); const idle = await drain(page); expect(sum(idle), `idle 3D long tasks [${idle.join(', ')}] ms`).toBeLessThan(IDLE_3D_TOTAL_MS);