/** * FE-FERRATA-LEAFLET-001 to FE-FERRATA-LEAFLET-011: the via ferrata layer on * the Leaflet renderer. * * Leaflet itself is not under test: the mock reflects each polyline's and * marker's props back as data attributes, so the assertions read which lines * are drawn, in which order and with what options. Casing and line stay * non-interactive so they cannot swallow clicks meant for places; only the * invisible hit line on top carries the tooltip, the hover and the click. */ import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'; import type { ReactNode } from 'react'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import type { Ferrata } from '@trek/shared'; import FerrataLayerLeaflet from './FerrataLayerLeaflet'; import { groupFerratas } from './ferrataGroups'; vi.mock('../../i18n', () => ({ useTranslation: () => ({ t: (key: string, params?: Record) => params ? `${key}(${Object.values(params).join(',')})` : key, }), })); const zoom = { value: 12 }; const zoomEnd: { handler: (() => void) | null } = { handler: null }; type Handlers = Record void) | undefined>; const at = { latlng: { lat: 46.505, lng: 11.705 } }; vi.mock('react-leaflet', () => ({ Polyline: ({ positions, pathOptions, interactive, bubblingMouseEvents, eventHandlers, children, }: { positions: unknown; pathOptions: { color: string; weight: number; opacity: number; dashArray?: string; className?: string }; interactive?: boolean; bubblingMouseEvents?: boolean; eventHandlers?: Handlers; children?: ReactNode; }) => (
eventHandlers?.click?.(at)} onMouseOver={() => eventHandlers?.mouseover?.(at)} onMouseOut={() => eventHandlers?.mouseout?.(at)} > {children}
), Marker: ({ position, eventHandlers }: { position: [number, number]; eventHandlers?: Handlers }) => (