mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 07:07:31 +00:00
test(tours): follow the reworked planner, ferrata and map stage in their suites; keep the map's waypoint list stable between renders
This commit is contained in:
@@ -91,17 +91,18 @@ const ferrata = (
|
||||
id: string,
|
||||
name: string | null,
|
||||
level: number | null,
|
||||
options: { routeName?: string | null; lat?: number; plus?: '+' | null } = {}
|
||||
options: { routeName?: string | null; lat?: number; lng?: number; plus?: '+' | null } = {}
|
||||
): Ferrata => {
|
||||
const lat = options.lat ?? 46.5;
|
||||
const lng = options.lng ?? 11.7;
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
grade: { raw: level === null ? null : String(level), level, plus: options.plus ?? null },
|
||||
routeName: options.routeName ?? null,
|
||||
geometry: [
|
||||
[lat, 11.7],
|
||||
[lat + 0.01, 11.71],
|
||||
[lat, lng],
|
||||
[lat + 0.01, Math.round((lng + 0.01) * 1e6) / 1e6],
|
||||
],
|
||||
osmUrl: `https://www.openstreetmap.org/${id}`,
|
||||
};
|
||||
@@ -141,7 +142,8 @@ describe('FerrataLayerLeaflet', () => {
|
||||
it('FE-FERRATA-LEAFLET-003: the tooltip names the ferrata and its grade range, or falls back to the route and unnamed', () => {
|
||||
const groups = groupFerratas([
|
||||
ferrata('way/1', 'Pisciadù', 2),
|
||||
ferrata('way/2', 'Pisciadù', 4, { lat: 46.51, plus: '+' }),
|
||||
// Picks up where way/1 ends: one ferrata in two segments.
|
||||
ferrata('way/2', 'Pisciadù', 4, { lat: 46.51, lng: 11.71, plus: '+' }),
|
||||
ferrata('way/3', null, 3, { routeName: 'Sentiero attrezzato', lat: 47 }),
|
||||
ferrata('way/4', null, null, { lat: 48 }),
|
||||
]);
|
||||
@@ -183,7 +185,7 @@ describe('FerrataLayerLeaflet', () => {
|
||||
root.style.setProperty('--map-ferrata-lit', 'navy');
|
||||
const groups = groupFerratas([
|
||||
ferrata('way/1', 'Via A', 2),
|
||||
ferrata('way/2', 'Via A', 3, { lat: 46.51 }),
|
||||
ferrata('way/2', 'Via A', 3, { lat: 46.51, lng: 11.71 }),
|
||||
ferrata('way/3', 'Via B', 3, { lat: 47 }),
|
||||
]);
|
||||
const { rerender } = render(<FerrataLayerLeaflet groups={groups} onSelect={vi.fn()} />);
|
||||
|
||||
@@ -49,11 +49,11 @@ describe('routeFerrataCrossings', () => {
|
||||
});
|
||||
|
||||
it('FE-FERRATA-CROSS-004: a short gap in the data does not split the stretch', () => {
|
||||
const route = northFrom([47.4, 11.0], 20);
|
||||
// The route steps 25 m aside for two points, still within the join gap.
|
||||
route[10] = [route[10][0], 11.0004];
|
||||
route[11] = [route[11][0], 11.0004];
|
||||
expect(routeFerrataCrossings(route, groups)).toHaveLength(1);
|
||||
// Two pieces of one ferrata with 44 m missing between them: the route point
|
||||
// in the middle of the hole is out of reach, the ones beside it are not.
|
||||
const pieces = groupFerratas([ferrata(2, [47.4, 11.0], 10), ferrata(3, [47.4 + 14 * STEP, 11.0], 11)]);
|
||||
expect(pieces).toHaveLength(1);
|
||||
expect(routeFerrataCrossings(northFrom([47.4, 11.0], 25), pieces)).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -37,14 +37,14 @@ const HIT = 'trek-ferratas-hit';
|
||||
const LABEL = 'trek-ferratas-label';
|
||||
const LAYERS = [CASING, LINE, HIGHLIGHT_CASING, HIGHLIGHT, HIT];
|
||||
|
||||
const ferrata = (id: string, lat: number, name: string): Ferrata => ({
|
||||
const ferrata = (id: string, lat: number, name: string, lng = 11.7): Ferrata => ({
|
||||
id,
|
||||
name,
|
||||
grade: { raw: '2', level: 2, plus: null },
|
||||
routeName: null,
|
||||
geometry: [
|
||||
[lat, 11.7],
|
||||
[lat + 0.01, 11.71],
|
||||
[lat, lng],
|
||||
[lat + 0.01, lng + 0.01],
|
||||
],
|
||||
osmUrl: `https://www.openstreetmap.org/${id}`,
|
||||
});
|
||||
@@ -52,7 +52,7 @@ const ferrata = (id: string, lat: number, name: string): Ferrata => ({
|
||||
/** Two ferratas: way/1 and way/2 are one (same name, touching), way/3 another. */
|
||||
const GROUPS = groupFerratas([
|
||||
ferrata('way/1', 46.5, 'Via A'),
|
||||
ferrata('way/2', 46.51, 'Via A'),
|
||||
ferrata('way/2', 46.51, 'Via A', 11.71),
|
||||
ferrata('way/3', 47, 'Via B'),
|
||||
]);
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ describe('useFerrataMapLayer', () => {
|
||||
expect(result.current.layer.active).toBe(false);
|
||||
expect(result.current.layer.count).toBe(0);
|
||||
expect(result.current.selected).toBeNull();
|
||||
expect(lastCall()).toEqual([7, null, false, null]);
|
||||
expect(lastCall()).toEqual([7, null, false, null, []]);
|
||||
});
|
||||
|
||||
it('FE-FERRATA-MAPLAYER-002: an area reported while off is remembered without a re-render, and used once it is on', () => {
|
||||
|
||||
Reference in New Issue
Block a user