v0.70.0: e2e wheel-clamp test asserts MapLibre height fit floor
CI / build + unit + e2e (pull_request) Successful in 14m5s

This commit is contained in:
2026-09-23 23:35:22 +00:00
parent fb369a1afb
commit 0aca4d63aa
+10 -4
View File
@@ -168,12 +168,18 @@ test('wheel zoom is clamped between min and max zoom', async ({ page }) => {
await waitForStableZoom(); await waitForStableZoom();
expect(await getZoom()).toBeCloseTo(MAX_ZOOM); expect(await getZoom()).toBeCloseTo(MAX_ZOOM);
// Zoom out well below MIN_ZOOM with several large deltas. // Zoom out to the effective minimum. MapLibre won't zoom out past the point where
await jumpTo(MIN_ZOOM + 1); // the world no longer covers the viewport height (fit floor = log2(h/512)), so with
await wheelToLimit(600, (z) => z <= MIN_ZOOM + 1e-9); // 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(); await waitForStableZoom();
const zoom = await getZoom(); const zoom = await getZoom();
expect(zoom).toBeCloseTo(MIN_ZOOM); expect(zoom).toBeCloseTo(minLimit);
expect(zoom).toBeGreaterThanOrEqual(MIN_ZOOM); expect(zoom).toBeGreaterThanOrEqual(MIN_ZOOM);
expect(zoom).toBeLessThanOrEqual(MAX_ZOOM); expect(zoom).toBeLessThanOrEqual(MAX_ZOOM);
}); });