test(shared): type the cluster icon size check and tighten the comments

iconSize is a PointExpression, which has no x on its tuple form, so the client typecheck refused the size assertion; it now compares against L.point. The test ids follow the FE-PAGE-SHARED-MAP scheme in the order they run, and the comments around the cluster group say in a line what they said in a paragraph.
This commit is contained in:
Maurice
2026-09-15 22:47:46 +02:00
parent 12eabbb685
commit 8a72d98bc6
4 changed files with 14 additions and 40 deletions
+3 -13
View File
@@ -1,12 +1,8 @@
import L from 'leaflet'
/**
* The cluster group every place map is drawn with.
*
* The planner and the public share page draw the same trip, so they have to
* cluster it the same way: a shared link that opens on three dozen overlapping
* pins while the planner shows four tidy bubbles is one trip told two different
* ways. Both maps build their group from this block and this factory (#2343).
* The cluster group the planner and the public share page both draw places with,
* so a shared link clusters a trip the way the planner does (#2343).
*/
export const CLUSTER_OPTIONS = {
chunkedLoading: true,
@@ -26,13 +22,7 @@ export interface ClusterLike {
getChildCount: () => number
}
/**
* A count bubble, sized by what it stands for.
*
* Markup rather than a component because Leaflet owns this element:
* `L.divIcon`'s html lands in the marker pane, outside React's tree — which is
* also why its styling lives in index.css (`.marker-cluster-custom`).
*/
/** A count bubble sized by its count, styled by `.marker-cluster-custom` in index.css. */
export function createClusterIcon(cluster: ClusterLike) {
const count = cluster.getChildCount()
const size = count < 10 ? 36 : count < 50 ? 42 : 48
+1 -4
View File
@@ -24,10 +24,7 @@ vi.mock('react-leaflet', () => ({
}),
}));
// The markers now reach the map through a cluster group (#2343). The real wrapper
// asks React Leaflet's context for the map it belongs to, and the stubbed
// MapContainer above provides none — so it is stubbed for the same reason
// everything else here is.
// The real cluster group needs the map context the stubbed MapContainer lacks (#2343).
vi.mock('react-leaflet-cluster', () => ({
default: ({ children }: { children?: React.ReactNode }) => (
<div data-testid="marker-cluster-group">{children}</div>
+2 -7
View File
@@ -19,9 +19,7 @@ import { createElement, useEffect, useRef } from 'react';
import { renderIconMarkup } from '../utils/iconMarkup';
import { MapContainer, Marker, Polyline, TileLayer, Tooltip, useMap } from 'react-leaflet';
import MarkerClusterGroup from 'react-leaflet-cluster';
// leaflet.markercluster's own sheets travel with the planner's MapView, which this
// page never mounts: without them the bubbles keep the library's default styling
// and spiderfy's legs are invisible.
// MapView brings these sheets for the planner, and this page never mounts it.
import 'leaflet.markercluster/dist/MarkerCluster.css';
import 'leaflet.markercluster/dist/MarkerCluster.Default.css';
import { CLUSTER_OPTIONS, createClusterIcon } from '../components/Map/markerCluster';
@@ -461,10 +459,7 @@ export default function SharedTripPage() {
interactive={false}
/>
)}
{/* Clustered like the planner's map (#2343). A shared link draws the
whole trip at once on a 300px-tall map, where a stop a few blocks
from the next one is the same few pixels: unclustered, the pins
cover each other and the ones underneath cannot be tapped. */}
{/* Clustered like the planner's map, so nearby stops stay tappable (#2343). */}
<MarkerClusterGroup {...CLUSTER_OPTIONS} iconCreateFunction={createClusterIcon}>
{mapPlaces.map((p: any) => (
<Marker key={p.id} position={[p.lat, p.lng]} icon={createMarkerIcon(p, dayOrderMap[p.id] ?? null)}>