mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 16:33:16 +00:00
ede109dce8
Connect the Journey backend to the web and mobile UI, including public access and subscriptions, day recordings, photo drafts and per-map framing. Preserve legacy recording responses and cover the new behavior in every locale.
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import { bookMapElementSchema, bookMapViewSchema } from '@trek/shared';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
import { boxToView, currentMapBox, moveBox, zoomBox } from './mapViewEdit';
|
|
|
|
const frame = { x: 0, y: 0, w: 100, h: 50 };
|
|
|
|
describe('editing the visible Studio map window', () => {
|
|
it('starts from the automatic framing of the current route', () => {
|
|
const el = bookMapElementSchema.parse({
|
|
id: 'map',
|
|
kind: 'map',
|
|
frame,
|
|
points: [
|
|
{ lat: 52.51, lng: 13.38 },
|
|
{ lat: 52.49, lng: 13.42 },
|
|
],
|
|
});
|
|
const fitted = boxToView(currentMapBox(el));
|
|
expect(fitted.west).toBeLessThan(13.38);
|
|
expect(fitted.east).toBeGreaterThan(13.42);
|
|
expect(fitted.south).toBeLessThan(52.49);
|
|
expect(fitted.north).toBeGreaterThan(52.51);
|
|
});
|
|
|
|
it('pans a manual view across the antimeridian and zooms it around the same centre', () => {
|
|
const view = { west: 175, east: 181, south: -19, north: -16 };
|
|
const el = bookMapElementSchema.parse({ id: 'map', kind: 'map', frame, view });
|
|
const start = currentMapBox(el);
|
|
const moved = moveBox(start, 0.5, 0);
|
|
const closer = boxToView(zoomBox(moved, 2));
|
|
|
|
expect(closer.west).toBeCloseTo(179.5);
|
|
expect(closer.east).toBeCloseTo(182.5);
|
|
expect(closer.north).toBeLessThan(view.north);
|
|
expect(closer.south).toBeGreaterThan(view.south);
|
|
});
|
|
|
|
it('keeps an extreme drag or zoom within a valid stored world window', () => {
|
|
const view = boxToView({ minX: 2000, maxX: 3000, minY: -900, maxY: 900 });
|
|
expect(bookMapViewSchema.safeParse(view).success).toBe(true);
|
|
expect(view.east - view.west).toBeLessThanOrEqual(360);
|
|
expect(view.east).toBeLessThanOrEqual(540);
|
|
});
|
|
});
|