diff --git a/e2e/map.spec.ts b/e2e/map.spec.ts index 2c0c981..b4df140 100644 --- a/e2e/map.spec.ts +++ b/e2e/map.spec.ts @@ -168,12 +168,18 @@ test('wheel zoom is clamped between min and max zoom', async ({ page }) => { await waitForStableZoom(); expect(await getZoom()).toBeCloseTo(MAX_ZOOM); - // Zoom out well below MIN_ZOOM with several large deltas. - await jumpTo(MIN_ZOOM + 1); - await wheelToLimit(600, (z) => z <= MIN_ZOOM + 1e-9); + // Zoom out to the effective minimum. MapLibre won't zoom out past the point where + // the world no longer covers the viewport height (fit floor = log2(h/512)), so with + // MIN_ZOOM=0 the reachable limit is max(MIN_ZOOM, fitFloor) — "just far enough to see + // the whole Earth", which is exactly what min zoom should give. + const mapBox = await page.getByTestId('map').boundingBox(); + if (!mapBox) throw new Error('map bounding box unavailable'); + const minLimit = Math.max(MIN_ZOOM, Math.log2(mapBox.height / 512)); + await jumpTo(minLimit + 1); + await wheelToLimit(600, (z) => z <= minLimit + 1e-9); await waitForStableZoom(); const zoom = await getZoom(); - expect(zoom).toBeCloseTo(MIN_ZOOM); + expect(zoom).toBeCloseTo(minLimit); expect(zoom).toBeGreaterThanOrEqual(MIN_ZOOM); expect(zoom).toBeLessThanOrEqual(MAX_ZOOM); });