e2e: per-test timescale speedup — FAST/CHAIN rates for pure arrival waits (v1.8.0)
CI / build + unit + e2e (pull_request) Successful in 6m3s
CI / build + unit + e2e (pull_request) Successful in 6m3s
- actions/hover/two-planes: FAST=10_000 for expiry fast-forwards, landing waits and fly-home cleanups; queue: + CHAIN=4_000 for auto-chain observation, refuel test at explicit 2_000 with relaxed fuel bound - map-interactions: FAST=50_000 chain hops (~3 min -> ~15 s per direction); crossing leg stays at SCALE and now sets it BEFORE dispatch (a leftover fast rate would let the dispatch tick consume most of the leg) - hover fleet-row test asserts flying from the fly endpoint's own snapshot and freezes immediately instead of speeding up then freezing mid-leg - two-planes parallel-flight: both-grounded poll after cleanup dispatches so afterEach heal no longer pays the range-edge return leg at SCALE
This commit is contained in:
+23
-17
@@ -17,6 +17,7 @@ test.beforeEach(async ({ page }) => { await authenticate(page); });
|
||||
// additionally gets a distinct green ring in `airports-target-highlight` (ISS-022).
|
||||
|
||||
const SCALE = 1000; // test rate for fast-forwarding legs — keeps flights to seconds of real time
|
||||
const FAST = 10_000; // pure arrival waits (no mid-leg observation) — LEMD-length legs land in ~1 s
|
||||
const WORLD = 24; // the fixed world rate (ISS-117) — must match lib/worldClock.ts
|
||||
const HUB = 'EDDF'; // must match HUB_ICAO in lib/game/seed.ts
|
||||
// Madrid–Barajas — same long leg as e2e/map-interactions.spec.ts: ~1420 km → ~10 s at scale 1000.
|
||||
@@ -516,7 +517,7 @@ test('hovering the Relocate section previews the planned route and target airpor
|
||||
});
|
||||
|
||||
test('hovering the fleet row of a flying plane highlights its route', async ({ page }) => {
|
||||
test.setTimeout(600_000); // self-heal + one flight at scale 1000 + fly-home cleanup
|
||||
test.setTimeout(600_000); // self-heal + one flight (frozen mid-leg) + FAST fly-home cleanup
|
||||
await flyHomeViaApi(page);
|
||||
|
||||
// Full tank before departure — deterministic baseline (ISS-082 hook; dispatch would auto-refuel anyway).
|
||||
@@ -525,23 +526,26 @@ test('hovering the fleet row of a flying plane highlights its route', async ({ p
|
||||
await page.goto('/');
|
||||
await waitForAirportCount(page);
|
||||
|
||||
// Load + fly via the API (same pattern as e2e/map-interactions.spec.ts), then speed up.
|
||||
// Load + fly via the API (same pattern as e2e/map-interactions.spec.ts). The endpoint's OWN
|
||||
// post-action snapshot already shows the plane flying — no poll race.
|
||||
const pkg = await createPackage(page, HUB, DEST);
|
||||
const load = await page.request.post(`/api/packages/${pkg.id}/load`, { data: { planeId: 'plane-starter' } });
|
||||
expect(load.status()).toBe(200);
|
||||
const fly = await page.request.post('/api/planes/plane-starter/fly', { data: { destIcao: DEST } });
|
||||
expect(fly.status()).toBe(200);
|
||||
await setScale(page, SCALE);
|
||||
const flyBody = (await fly.json()) as StateBody;
|
||||
expect(flyBody.planes.find((p) => p.id === 'plane-starter')?.status).toBe('flying');
|
||||
|
||||
// Freeze immediately: at a leftover scale of 1000 the ~10 s leg could otherwise land under us and
|
||||
// empty the route line while we assert. At scale 1 every /api/state snapshot reports the same state
|
||||
// for minutes, so no mid-flight position window is needed at all (same pattern as the package-hover
|
||||
// test below).
|
||||
await setScale(page, 1);
|
||||
|
||||
// The fleet row shows the plane in flight once a snapshot with status 'flying' lands (ISS-054).
|
||||
const block = page.getByTestId('plane-plane-starter');
|
||||
await expect(block).toContainText(/in flight/i, { timeout: 15_000 });
|
||||
|
||||
// Freeze mid-flight so the ~10 s leg can't land under us while we assert (same pattern as
|
||||
// e2e/map-interactions.spec.ts' marker click): at scale 1 the leg takes minutes of real time, and
|
||||
// the route line stays drawn while frozen.
|
||||
await setScale(page, 1);
|
||||
|
||||
await block.hover();
|
||||
await expect.poll(async () => {
|
||||
const feats = (await renderedFeatures(page, ['routes-highlight'])) as Array<{ properties: Record<string, unknown> }>;
|
||||
@@ -554,9 +558,10 @@ test('hovering the fleet row of a flying plane highlights its route', async ({ p
|
||||
message: 'waiting for the highlight to clear after mouseleave',
|
||||
}).toBe(0);
|
||||
|
||||
// Resume and fast-forward to arrival, then fly home so the live instance stays in its
|
||||
// onboarding state (starter grounded at EDDF) for the other specs.
|
||||
await setScale(page, SCALE);
|
||||
// Fast-forward to arrival (pure wait — no mid-leg observation), then fly home so the live instance
|
||||
// stays in its onboarding state (starter grounded at EDDF) for the other specs. Both legs are pure
|
||||
// arrivals → FAST (~1 s each instead of ~10 s).
|
||||
await setScale(page, FAST);
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const p = (await getState(page)).planes.find((x) => x.id === 'plane-starter');
|
||||
@@ -564,8 +569,8 @@ test('hovering the fleet row of a flying plane highlights its route', async ({ p
|
||||
}, { timeout: 120_000, message: `waiting for plane-starter to land at ${DEST}` })
|
||||
.toBe(true);
|
||||
|
||||
// Re-set SCALE for the return leg.
|
||||
await setScale(page, SCALE);
|
||||
// Re-set FAST for the return leg.
|
||||
await setScale(page, FAST);
|
||||
const home = await page.request.post('/api/planes/plane-starter/fly', { data: { destIcao: HUB } });
|
||||
expect(home.status()).toBe(200);
|
||||
await expect
|
||||
@@ -577,7 +582,7 @@ test('hovering the fleet row of a flying plane highlights its route', async ({ p
|
||||
});
|
||||
|
||||
test('hovering an on-board package while its carrier is mid-flight traces from the landing airport', async ({ page }) => {
|
||||
test.setTimeout(600_000); // self-heal + one flight at scale 1000 + fly-home cleanup
|
||||
test.setTimeout(600_000); // self-heal + one flight (frozen mid-leg) + FAST fly-home cleanup
|
||||
await flyHomeViaApi(page);
|
||||
|
||||
// Full tank before departure — deterministic baseline (ISS-082 hook; dispatch would auto-refuel anyway).
|
||||
@@ -651,7 +656,8 @@ test('hovering an on-board package while its carrier is mid-flight traces from t
|
||||
// not DEST — it never delivered), then fly home.
|
||||
const cancelRes = await page.request.post('/api/planes/plane-starter/queue/cancel', { data: { index: 0 } });
|
||||
expect(cancelRes.status()).toBe(200);
|
||||
await setScale(page, SCALE);
|
||||
// Pure arrival wait (the queue is empty — nothing to observe mid-leg) → FAST.
|
||||
await setScale(page, FAST);
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const p = (await getState(page)).planes.find((x) => x.id === 'plane-starter');
|
||||
@@ -662,8 +668,8 @@ test('hovering an on-board package while its carrier is mid-flight traces from t
|
||||
const abandon = await page.request.post(`/api/packages/${pkg.id}/abandon`);
|
||||
expect(abandon.status()).toBe(200); // only possible once grounded — the poll above guarantees it
|
||||
|
||||
// Re-set SCALE for the return leg.
|
||||
await setScale(page, SCALE);
|
||||
// Re-set FAST for the return leg (~1 s instead of ~10 s).
|
||||
await setScale(page, FAST);
|
||||
const home = await page.request.post('/api/planes/plane-starter/fly', { data: { destIcao: HUB } });
|
||||
expect(home.status()).toBe(200);
|
||||
await expect
|
||||
|
||||
Reference in New Issue
Block a user