test: decisive hover diagnostics — browser snapshot vs node state + fleet HTML; CI fresh DB per run
CI / build + unit + e2e (pull_request) Failing after 6m3s
CI / build + unit + e2e (pull_request) Failing after 6m3s
This commit is contained in:
+16
-6
@@ -32,6 +32,7 @@ interface PackageState {
|
||||
}
|
||||
|
||||
interface StateBody {
|
||||
account: { cash: number; reputation: number };
|
||||
simState: { clockMs: number; timeScale: number; paused: boolean };
|
||||
planes: PlaneState[];
|
||||
packages: PackageState[];
|
||||
@@ -166,16 +167,25 @@ test('hovering a fleet row highlights the plane on the map', async ({ page }) =>
|
||||
const row = page.locator('li[data-testid="plane-starter"]');
|
||||
// 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 distinguishes "server has no plane-starter" from
|
||||
// "DOM didn't render". (The value is returned, not thrown — expect.poll fails immediately
|
||||
// on a callback throw instead of retrying.)
|
||||
// diagnostics: on timeout the message compares what the NODE side sees vs what the BROWSER
|
||||
// last polled, plus the fleet section's HTML — distinguishing server divergence from a render
|
||||
// bug. (The value is returned, not thrown — expect.poll fails immediately on a callback throw
|
||||
// instead of retrying.)
|
||||
await expect
|
||||
.poll(async () => {
|
||||
if ((await row.count()) > 0 && (await row.isVisible())) return 'visible';
|
||||
const body = await getState(page);
|
||||
const serverHasStarter = body.planes.some((p) => p.id === 'plane-starter');
|
||||
const paneHtml = (await page.locator('[data-testid="left-pane"]').first().innerHTML()).slice(0, 200);
|
||||
return `not visible — /api/state has plane-starter: ${serverHasStarter}; left-pane HTML: ${paneHtml}`;
|
||||
const browserSnap = await page.evaluate(() => (window as any).__flightLastSnapshot ?? null);
|
||||
const fleetHtml = await page.evaluate(() => {
|
||||
const el = document.querySelector('[data-testid="fleet-list"]');
|
||||
if (el) return `fleet-list HTML: ${(el.outerHTML ?? '').slice(0, 300)}`;
|
||||
const pane = document.querySelector<HTMLElement>('[data-testid="left-pane"]');
|
||||
return `no fleet-list — left-pane text: ${(pane?.innerText ?? '').slice(0, 200)}`;
|
||||
});
|
||||
return (
|
||||
`not visible — node /api/state planes=[${body.planes.map((p) => p.id).join(', ')}] cash=${body.account.cash}; ` +
|
||||
`browser __flightLastSnapshot=${JSON.stringify(browserSnap)}; ${fleetHtml}`
|
||||
);
|
||||
}, { timeout: 30_000 })
|
||||
.toBe('visible');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user