fix(ui): refresh LOCAL SYSTEM after a jump instead of waiting for a page reload (#30)
CI / build + unit + e2e (pull_request) Successful in 2m39s

WorldMapPanel owns the world state and applied the /api/jump response
locally, so MissionControl's lifted /api/system state (LOCAL SYSTEM tab,
CARGO HOLD, SECTOR row) stayed on the previous system until a full refresh.
The panel now takes an onJumped callback that MissionControl wires to an
/api/system refetch after every successful jump.
This commit is contained in:
2026-09-29 10:00:18 +00:00
parent e6c88b10c2
commit e27ff7015e
5 changed files with 48 additions and 5 deletions
+24
View File
@@ -112,6 +112,30 @@ test('jumping to an adjacent system updates the world state and turn counter', a
expect(after.systems.find((s) => s.current)?.id).toBe(targetId);
});
test('local system shows the new current system after a jump, without a page reload (#30)', async ({ page }) => {
const before = (await (await page.request.get('/api/world')).json()) as WorldState;
const currentId = before.systems.find((s) => s.current)!.id;
const edge = before.edges.find(([a, b]) => a === currentId || b === currentId)!;
const targetId = edge[0] === currentId ? edge[1] : edge[0];
const targetName = before.systems.find((s) => s.id === targetId)!.name;
await page.goto('/');
// Jump through the UI: click the target's chart field on WORLD MAP (the default tab).
await page.getByRole('tabpanel').getByRole('button', { name: targetName.toUpperCase(), exact: true }).click();
// Wait until the jump response is applied to the chart — server state is committed by then, so
// the /api/world read below can't race the in-flight POST.
await expect(page.getByText(`GALACTIC CHART // JUMP ROUTES — TURN ${before.turn + 1}`)).toBeVisible();
const after = (await (await page.request.get('/api/world')).json()) as WorldState;
const newCurrent = after.systems.find((s) => s.current)!;
expect(newCurrent.id).toBe(targetId); // the jump landed where we aimed
// Switch to LOCAL SYSTEM — it must show the NEW current system without a page reload (#30).
await page.getByRole('tab', { name: 'LOCAL SYSTEM' }).click();
await expect(page.getByText(`EXPLORABLE WORLDS // ${newCurrent.name.toUpperCase()} — TURN ${after.turn}`)).toBeVisible();
});
test('local system shows the current system bodies with staggered moons and explore buttons', async ({ page }) => {
const sys = (await (await page.request.get('/api/system')).json()) as SystemState;