test: pause sim around plane-popup marker click at 1000× (rendered marker lags fresh state by one poll)
CI / build + unit + e2e (pull_request) Successful in 4m43s
CI / build + unit + e2e (pull_request) Successful in 4m43s
This commit is contained in:
@@ -251,8 +251,23 @@ test('plane markers move while flying and the plane popup shows status + route',
|
||||
// The arc itself stays covered by unit tests: lib/mapData.test.ts.)
|
||||
|
||||
// 4) Click the flying plane → status popup with model, status, fuel and the leg.
|
||||
// Fetch + project in one evaluate so the click lands on a fresh position (at scale
|
||||
// 1000 the marker moves fast — a stale projection would miss it).
|
||||
// Freeze the sim so the click can't miss a fast-moving marker: at scale 1000 the rendered
|
||||
// marker lags our fresh /api/state fetch by up to one map poll (~1 s) — tens of px of drift
|
||||
// on this leg. Pausing makes the position static; we resume right after the popup checks.
|
||||
await postSim(page, { paused: true });
|
||||
let prevPos: { lat: number; lon: number } | null = null;
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const p = (await getState(page)).planes.find((x) => x.id === 'plane-starter');
|
||||
if (!p || p.status !== 'flying') return false;
|
||||
if (prevPos && prevPos.lat === p.lat && prevPos.lon === p.lon) return true;
|
||||
prevPos = { lat: p.lat, lon: p.lon };
|
||||
return false;
|
||||
}, { timeout: 15_000, message: 'waiting for the paused clock to freeze the plane position' })
|
||||
.toBe(true);
|
||||
|
||||
// Fetch + project in one evaluate — with the sim paused above, the server's analytic
|
||||
// position is static, so the projected point matches what the map renders.
|
||||
const pt = await page.evaluate(async () => {
|
||||
const m = (window as any).__flightMap;
|
||||
if (!m) return null;
|
||||
@@ -277,6 +292,9 @@ test('plane markers move while flying and the plane popup shows status + route',
|
||||
// The popup's route line is the plane's own leg: origin name → destination name.
|
||||
await expect(page.getByTestId('plane-route')).toContainText(`${live.locationName} → ${live.destName}`);
|
||||
|
||||
// Resume before step 5 — the landing wait needs a running clock.
|
||||
await postSim(page, { timeScale: SCALE, paused: false });
|
||||
|
||||
// 5) Let the flight finish, then fly home so the live instance stays in its
|
||||
// onboarding state (starter grounded at EDDF) for the other specs. The loaded
|
||||
// package is delivered on arrival (in-deadline).
|
||||
|
||||
Reference in New Issue
Block a user