From f0ee6ee93af020e9afc106486df7e12bb2d4dda7 Mon Sep 17 00:00:00 2001 From: CLYEH Date: Wed, 2 Sep 2026 11:31:25 +0800 Subject: [PATCH] test(e2e): the drag test samples the hand's start at mousedown (T-104) The fourth T-104 test compared the post-drag camera against a live sample taken BEFORE `mouse.down()`, while the flight was still moving. On a slow runner the flight's own motion between that sample and the mousedown ran opposite to the 160x120px pan and cancelled most of it: CI read 0.00055 against the 0.001 floor (run 33586396145, PR #93). The pan handler is `activateOnStart`, so the mousedown itself calls `stop(true)` and freezes the camera; sampling right after it isolates the hand's effect exactly. The fixed 400 ms inertia wait is now a poll on `!map.isMoving()`, so the `moveend` the store publishes on has fired before the position is read. Verified: 12/12 with `--workers=2 --repeat-each=3`; under a load average above 150 (a parallel `--repeat-each=5` on this machine) the spec's other tests also timed out, which is the runner, not the change. Task: T-104 --- e2e/awakening-flight.spec.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/e2e/awakening-flight.spec.ts b/e2e/awakening-flight.spec.ts index 7c8a344..85ac387 100644 --- a/e2e/awakening-flight.spec.ts +++ b/e2e/awakening-flight.spec.ts @@ -331,17 +331,25 @@ test.describe("the Awakening does not cancel the first flight (T-104)", () => { // Measuring the drag's delta off that target, rather than off where the // hand actually started, would pass even if the drag below were a no-op: // the flight alone would already account for the whole "distance". - const beforeDrag = await liveCamera(page); + // + // And sampled AFTER `mouse.down()`, not before it. The pan handler is + // `activateOnStart`, so the mousedown alone makes the handler manager call + // `stop(true)`: from that instant the camera is frozen until the first + // pan delta. Sampled a few round trips earlier, the still-moving flight + // would pollute the delta -- on a slow CI runner it once cancelled most + // of a 160x120px pan and read 0.00055 against the 0.001 floor below. const box = await page.getByTestId("map").boundingBox(); if (!box) throw new Error("map container has no box to drag over"); const startX = box.x + box.width * 0.3; const startY = box.y + box.height * 0.5; await page.mouse.move(startX, startY); await page.mouse.down(); + const beforeDrag = await liveCamera(page); await page.mouse.move(startX + 160, startY + 120, { steps: 12 }); await page.mouse.up(); - // Let any drag inertia settle before reading the position back. - await page.waitForTimeout(400); + // Let the drag's inertia run out before reading the position back -- the + // store publishes at `moveend`, and a fixed wait is a bet on the runner. + await page.waitForFunction(() => !window.__glassmapMap!.isMoving()); const afterDrag = await callTool(page, "get_map_state"); expect(afterDrag.error).toBeUndefined();