test: hover spec — fleet row testid is plane-${p.id} (double prefix), derive from state
CI / build + unit + e2e (pull_request) Successful in 5m42s

This commit is contained in:
2026-09-19 10:51:18 +00:00
parent eff934a1cc
commit 08094a00e2
2 changed files with 9 additions and 3 deletions
+8 -3
View File
@@ -164,7 +164,12 @@ test('hovering a fleet row highlights the plane on the map', async ({ page }) =>
await page.goto('/');
await waitForAirportCount(page);
const row = page.locator('li[data-testid="plane-starter"]');
// Fleet rows are <li data-testid={`plane-${p.id}`}> and the server id already carries the "plane-"
// prefix (run #34: the real testid is plane-plane-starter) — derive it from /api/state, never hardcode.
const planes = (await getState(page)).planes;
const starterId = planes.find((p) => p.id.endsWith('starter'))?.id ?? (planes.length === 1 ? planes[0].id : undefined);
expect(starterId).toBeDefined();
const row = page.locator(`li[data-testid="plane-${starterId}"]`);
// The browser's /api/state polls can lag node-side requests right after a fresh page load
// (useGameState keeps loading=true until the first success → no fleet rows yet), so poll with
// diagnostics: on timeout the message compares what the NODE side sees vs what the BROWSER
@@ -195,8 +200,8 @@ test('hovering a fleet row highlights the plane on the map', async ({ page }) =>
await row.hover();
await expect.poll(async () => {
const feats = (await renderedFeatures(page, ['planes-highlight'])) as Array<{ properties: Record<string, unknown> }>;
return feats.length > 0 && feats[0].properties.id === 'plane-starter';
}, { timeout: 15_000, message: 'waiting for the planes-highlight layer to show plane-starter' }).toBe(true);
return feats.length > 0 && feats[0].properties.id === starterId;
}, { timeout: 15_000, message: `waiting for the planes-highlight layer to show ${starterId}` }).toBe(true);
await unhover(page);
await expect.poll(async () => (await renderedFeatures(page, ['planes-highlight'])).length, {