fix(ui-e2e): Phase 29 map-toggles spec passes across all four projects
Tests · UI / test (push) Failing after 10m52s

Three independent bugs in `tests/e2e/map-toggles.spec.ts` made the
fresh-Phase-29 suite red on CI #216:

1. `visiblePlanets` filtered on `p.id < 1_000_000`, which JS interprets
   in signed space — high-bit-prefix primitives (cargo route 0x80…,
   battle 0xa0…, bombing 0xc0…) are stored as negative Numbers and
   leaked into the planet list. Filter switched to a `0 < id < 1e7`
   window that matches the engine planet-number range exactly.
2. The `visibleHighBitCount` helper now ToUint32-converts the id
   before masking so the bitmask comparison works regardless of
   whether the id is stored as positive or negative.
3. The fog and wrap-mode tests read the renderer state synchronously
   after the click — the Svelte effect re-runs asynchronously, so the
   tests saw stale state. Both now `waitForFunction` on the canonical
   "settled" signal: empty fog circles for the fog flip, and a new
   `getMapMode()` debug accessor for the wrap-mode remount.

Renderer side: registers a `MapModeProvider` next to the existing
camera / fog providers and exposes `getMapMode()` through the debug
surface.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilia Denisov
2026-05-19 22:02:15 +02:00
parent 2bd1b54936
commit 2528d63b51
5 changed files with 108 additions and 67 deletions
@@ -10,6 +10,7 @@
import {
getMapCamera,
getMapFog,
getMapMode,
getMapPickState,
getMapPrimitives,
type MapCameraSnapshot,
@@ -17,6 +18,7 @@
type MapPickStateSnapshot,
type MapPrimitiveSnapshot,
} from "../../../lib/debug-surface.svelte";
import type { WrapMode } from "../../../map/world";
interface DebugSnapshot {
publicKey: number[];
@@ -42,6 +44,7 @@
getMapPickState(): MapPickStateSnapshot;
getMapCamera(): MapCameraSnapshot | null;
getMapFog(): MapFogSnapshot;
getMapMode(): WrapMode | null;
}
type DebugWindow = typeof globalThis & { __galaxyDebug?: DebugSurface };
@@ -142,6 +145,9 @@
getMapFog() {
return getMapFog();
},
getMapMode() {
return getMapMode();
},
};
(window as DebugWindow).__galaxyDebug = surface;
ready = true;