diff --git a/tests/e2e/inspector-dock-layout.spec.js b/tests/e2e/inspector-dock-layout.spec.js index 6bd3702a..f175c729 100644 --- a/tests/e2e/inspector-dock-layout.spec.js +++ b/tests/e2e/inspector-dock-layout.spec.js @@ -153,11 +153,18 @@ test.describe('docked right-inspector dock-aware width (#586 findings 2a/2b)', ( expect(Math.round(before.width)).toBe(500); await page.setViewportSize({ width: 900, height: 800 }); + // #599: `setViewportSize` resolves as soon as the viewport is applied, but + // the DISPLAYED width above is recomputed by app-shell.ts's + // `reclampInspectorWidth`, run from a real `window` 'resize' event + // LISTENER — dispatched asynchronously relative to that resolution, and + // more likely to lose the race under parallel load. Poll for the settled + // width instead of reading it on the very next microtask. + await expect.poll(async () => Math.round((await inspectorHost.boundingBox()).width)) + // Default sidebarPx (248) + 2 handles (14) reserved, minus CENTRE_MIN_PX + // (320): ceiling = 900-262-320 = 318, below the shared 320 floor — clamp + // floors it at 320 exactly. + .toBe(320); const after = await inspectorHost.boundingBox(); - // Default sidebarPx (248) + 2 handles (14) reserved, minus CENTRE_MIN_PX - // (320): ceiling = 900-262-320 = 318, below the shared 320 floor — clamp - // floors it at 320 exactly. - expect(Math.round(after.width)).toBe(320); expect(after.width).toBeLessThan(before.width); test.info().annotations.push( diff --git a/tests/e2e/tile-open-workbench.spec.js b/tests/e2e/tile-open-workbench.spec.js index 98a81c08..3dca7b99 100644 --- a/tests/e2e/tile-open-workbench.spec.js +++ b/tests/e2e/tile-open-workbench.spec.js @@ -361,7 +361,15 @@ test('widen doubles a grid tile\'s rendered width, preserves its height, then wr // until #564. expect(wide.width).toBeGreaterThan(before.width); expect(wide.height).toBe(before.height); - expect((await page.evaluate(() => window.__dashboard('sales'))).items['t-sales']) + // #599: the widen press applies OPTIMISTICALLY first (`runCommand`, + // src/ui/dashboard.ts) — the geometry above is already settled by the time + // `widen.click()` resolves, but the PERSISTED commit this reads is a + // separate, fire-and-forget `app.mutateWorkspace` call that lands later. + // Poll rather than reading it on the very next microtask, matching the same + // commit-republish race the later "narrow tile" test already guards + // against (its own "Read defensively" comment, below). + await expect.poll(async () => (await page.evaluate(() => window.__dashboard('sales'))) + ?.items?.['t-sales'] ?? null) .toEqual({ grid: { span: 12, height: 2 } }); // At the maximum the next press wraps to a single column.