Files
TREK/client/src/components/Map/RouteHitBand.test.tsx
T
Maurice 31859651d7 feat(help): rewrite the help center for v5 with a Tours section, new pictures in every language, and fix the tour planner bugs it surfaced
Every help screen checked against the v5 redesign. Tours is documented for
the first time, as a screen of its own with twelve screens under it, and
notifications get help of their own. All pictures are taken again on a
realistic demo trip, with short loops where a still cannot show the motion.
The English is plain and every language is written naturally rather than
word for word.

The switcher shows two levels at most, a screen's overview lists its
sub-screens as cards above its guides, each wiki page is linked once, and
the help sidebar is wider.

Fixes found along the way: Save to Collection keeps a tour's route, a track
dropped on the places column opens the Tours import, tour Share on desktop,
the unsaved tour draft lives on the account, a route click no longer adds
an end point, Trip places leaves the trip's tours out, Escape closes a
stage's day menu, confirms before destructive deletes, DWD warnings sharing
one id kept apart, a booking's date moves with it, and smaller fixes across
notifications, bookings, the day plan, stays, Atlas, Collections, Vacay and
the admin screens.
2026-10-22 22:29:35 +02:00

54 lines
1.5 KiB
TypeScript

import { fireEvent, render, screen } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import { RouteHitBand } from './RouteHitBand';
// jsdom cannot reproduce Leaflet's event propagation, so the mock surfaces the
// option that governs it and hands the click on with a position.
vi.mock('react-leaflet', () => ({
Polyline: ({
eventHandlers,
bubblingMouseEvents,
}: {
eventHandlers?: { click?: (e: unknown) => void };
bubblingMouseEvents?: boolean;
}) => (
<div
data-testid="band"
data-bubbling={String(bubblingMouseEvents)}
onClick={() =>
eventHandlers?.click?.({ latlng: { lat: 46.58, lng: 11.75 }, originalEvent: new MouseEvent('click') })
}
/>
),
}));
describe('RouteHitBand', () => {
it('keeps its click from the map, which would add a point at the end of the tour', () => {
render(
<RouteHitBand
positions={[
[46.5, 11.7],
[46.6, 11.8],
]}
onRouteClick={vi.fn()}
/>
);
expect(screen.getByTestId('band')).toHaveAttribute('data-bubbling', 'false');
});
it('hands the clicked position to the route', () => {
const onRouteClick = vi.fn();
render(
<RouteHitBand
positions={[
[46.5, 11.7],
[46.6, 11.8],
]}
onRouteClick={onRouteClick}
/>
);
fireEvent.click(screen.getByTestId('band'));
expect(onRouteClick).toHaveBeenCalledWith(46.58, 11.75);
});
});