fix(tours): keep the shipped ski migrations and follow the ski tour through

The winter label and four-discipline migrations are already on
feat/tours-board-rest, so a database that ran them would refuse to boot
or fail the old CHECK. 045500, 045520 and 046100 are back as they
shipped, and a new migration drops both winter_activity columns and
adds ski_discipline again with the six disciplines. The entity and
table types follow the column to its new place.

German, Hungarian, Indonesian and English no longer name the whole type
with the ski touring word, and the info dot speaks of ski tours and
tracks. search_tour_pois and its wiki row list rides and ski and winter
tours. Snowshoeing gets a snowshoe glyph instead of the walk's
footprints, a ski import without a discipline can be planned over (the
planner asks for it), and an overlay shown by default tries its tiles
afresh each time it comes on.
This commit is contained in:
Maurice
2026-10-20 18:39:04 +02:00
parent 164a3633ac
commit be6702f3ab
48 changed files with 273 additions and 84 deletions
@@ -11,7 +11,7 @@ describe('TourActivityBadge (ACT-01)', () => {
<TourActivityBadge tour={{ activity_tracks: [{ id: 1, track_place_id: 9, assignment_id: null }] }} />
);
expect(screen.getByTestId('tour-activity-badge')).toHaveAttribute('aria-label', 'tours.activity.badgeHint');
// The done mark, never footprints, which name a snowshoe hike and a walk's moving time.
// The done mark, never footprints, which name a walk's moving time.
expect(screen.getByTestId('tour-activity-badge').querySelector('svg.lucide-check-check')).not.toBeNull();
expect(screen.getByTestId('tour-activity-badge').querySelector('svg.lucide-footprints')).toBeNull();
@@ -32,8 +32,8 @@ interface PlanSide {
/**
* The tile of a recording: the done mark every actual track goes by (on the
* list row, in the tour's head and here), with a small dot at its foot that
* says it was recorded. Never footprints, which name a snowshoe hike and a
* walk's moving time.
* says it was recorded. Never footprints, which name a city walk and a walk's
* moving time.
*/
function RecordedTile() {
return (
@@ -244,18 +244,25 @@ describe('useGpxConversion', () => {
);
});
it('SKI-02: a ski track that names no discipline is not planned over: nothing is offered and no router is asked', () => {
it('SKI-02: a ski track that names no discipline is planned over too, the planner asks for it', async () => {
const ski = { ...imported, tour_type: 'ski' as const, ski_discipline: null, max_hiking_difficulty: null };
const controller = planner({
mode: { type: 'view-gpx', placeId: ski.place_id, tour: ski },
readOnlyGpxTour: { tour: ski, routeGeometry: null },
} as Partial<TourPlannerController>);
const { result } = renderHook(() => useGpxConversion(controller));
expect(result.current.available).toBe(false);
const { container } = render(<TourConversionSection conversion={result.current} />);
expect(container).toBeEmptyDOMElement();
expect(routing.route).not.toHaveBeenCalled();
expect(routing.run).not.toHaveBeenCalled();
expect(result.current.available).toBe(true);
expect(result.current.ski).toBe(true);
await act(async () => {
await result.current.analyze();
});
act(() => {
result.current.adopt('new');
});
// Nothing is chosen for the skier: the draft opens without a discipline, and saving waits for one.
expect(controller.startDerivedTour).toHaveBeenCalledWith(
expect.objectContaining({ tourType: 'ski', ski: { discipline: null, technique: null } })
);
});
it('PR1-05B: nothing is adopted before the suggestion is ready', () => {
@@ -5,7 +5,7 @@ import { isTourRoute } from '../planner/tourRouteOutcome';
import { routeBikeTour, routeRun, routeWalkingTour } from '../planner/tourRouting';
import { paddleFieldsOf } from '../planner/usePaddleFields';
import type { TourPlannerController } from '../planner/useTourPlanner';
import { skiChoiceMissing, skiChoiceOf } from '../ski/skiChoice';
import { skiChoiceOf } from '../ski/skiChoice';
import { compareRoutes, deriveControlPoints, type RouteComparison, type TrackPoint } from './gpxConversion';
/** The grade a planned version routes with when the import carries none: the paths a T3 walk may take. */
@@ -132,12 +132,12 @@ export function useGpxConversion(planner: TourPlannerController) {
...current,
/**
* The import shown can be planned from: it has a track and the user may add tours. A ski
* track (SKI-02) once it names its discipline, planned as a ski tour with its legs drawn.
* track (SKI-02) is planned as a ski tour with its legs drawn; one saved before it named a
* discipline is offered too, and the planner asks for the discipline before it saves.
* A ride (HOR-01) never: no router plans one, and walking it again on foot would be no ride.
*/
available:
tour !== null &&
(ski === null || skiChoiceMissing(ski) === null) &&
tour.tour_type !== 'horse' &&
(track?.length ?? 0) >= 2 &&
planner.canEdit,
@@ -1,5 +1,5 @@
import type { SkiDiscipline, SkiTechnique, TourListItem } from '@trek/shared';
import { CableCar, createLucideIcon, Footprints, Snowflake, Spline, TrendingUp, type LucideIcon } from 'lucide-react';
import { CableCar, createLucideIcon, Snowflake, Spline, TrendingUp, type LucideIcon } from 'lucide-react';
/**
* SKI-02: a snowboard seen from above, laid across the square with its two
@@ -14,19 +14,34 @@ const Snowboard = createLucideIcon('snowboard', [
['path', { d: 'M15.5 10v4', transform: BOARD, key: 'binding-back' }],
]);
/**
* SKI-02: a snowshoe seen from above, the racket frame narrowing to its tail,
* with the lacing across and the binding in the middle. Footprints already
* mean a city walk and a walk's moving time, so a snowshoe tile marked with
* them would read as a walk.
*/
export const Snowshoe = createLucideIcon('snowshoe', [
['path', { d: 'M12 3c3.3 0 5.5 2.8 5.5 6.5 0 4-2.4 7.6-5.5 12-3.1-4.4-5.5-8-5.5-12S8.7 3 12 3z', key: 'frame' }],
['path', { d: 'M7 7.5h10', key: 'lacing-front' }],
['path', { d: 'M7.3 13.5h9.4', key: 'lacing-back' }],
['path', { d: 'M12 3v18.5', key: 'lacing-middle' }],
['path', { d: 'M9.5 10.5h5', key: 'binding' }],
]);
/**
* SKI-02: the icon each discipline goes by, each its own: a lift for alpine
* skiing, a board for snowboarding, a winding trail for cross-country, the
* climb on skins for ski touring, footprints in the snow for snowshoeing and a
* snowflake for winter hiking. They all take the same corner of a tile, so no
* two share a glyph, and none is the tile's own mountain.
* climb on skins for ski touring, a snowshoe for snowshoeing and a snowflake
* for winter hiking. They all take the same corner of a tile, so no two share
* a glyph, none is the tile's own mountain, and none is the mark of another
* tour type or fact (footprints stay the walk's).
*/
export const SKI_DISCIPLINE_ICON: Record<SkiDiscipline, LucideIcon> = {
alpine: CableCar,
snowboard: Snowboard,
cross_country: Spline,
touring: TrendingUp,
snowshoe: Footprints,
snowshoe: Snowshoe,
winter_hike: Snowflake,
};
@@ -78,12 +78,18 @@ describe('ski marks (SKI-02)', () => {
expect(icons).toHaveLength(6);
expect(new Set(icons).size).toBe(icons.length);
expect(icons).not.toContain(tourDayRowIcon('ski'));
// No discipline borrows the mark of another tour type either.
for (const type of ['hike', 'bike', 'walk', 'run', 'kayak', 'horse']) {
expect(icons).not.toContain(tourDayRowIcon(type));
}
});
it('FE-TOUR-SKI-MARK-007: snowshoeing and winter hiking are ski tours with their own marks, a hike carries none', () => {
const { rerender } = render(<SkiCornerMark tour={{ tour_type: 'ski', ski_discipline: 'snowshoe' }} />);
const snowshoe = screen.getByRole('img', { name: 'tours.ski.discipline.snowshoe' });
expect(snowshoe.querySelector('svg.lucide-footprints')).not.toBeNull();
expect(snowshoe.querySelector('svg.lucide-snowshoe')).not.toBeNull();
// Footprints are the city walk's mark, so a snowshoe tile never carries them.
expect(snowshoe.querySelector('svg.lucide-footprints')).toBeNull();
rerender(<SkiCornerMark tour={{ tour_type: 'ski', ski_discipline: 'winter_hike' }} />);
const winterHike = screen.getByRole('img', { name: 'tours.ski.discipline.winter_hike' });
expect(winterHike.querySelector('svg.lucide-snowflake')).not.toBeNull();
@@ -67,6 +67,23 @@ describe('useTourRasterOverlay', () => {
expect(result.current.status).toBe('on');
});
it('tries afresh each time it comes on without its switch, as the pistes of a ski tour do', () => {
const toggle = vi.fn();
const { result, rerender } = renderHook(({ active }) => useTourRasterOverlay(SEAMARKS, true, active, toggle), {
initialProps: { active: true },
});
act(() => {
for (let i = 0; i < 4; i++) result.current.onTileError();
});
expect(result.current.status).toBe('down');
// The tour closes, a later one shows the overlay by default: it opens on, not down.
rerender({ active: false });
expect(result.current.status).toBe('off');
rerender({ active: true });
expect(result.current.status).toBe('on');
expect(toggle).not.toHaveBeenCalled();
});
it('marks an overlay that is on while the map is further out than its first tiles, and nothing at an unknown zoom', () => {
const { result, rerender } = renderHook(
({ active, zoom }: { active: boolean; zoom: number | null }) =>
@@ -44,7 +44,9 @@ export function useBaseMapHealth(baseLayer: string): BaseMapHealth | undefined {
/**
* An overlay the planner offers, off until switched on; whether it is on is
* the planner's (`active`, `onToggle`), so it outlasts the map. Its tile
* health shows on the switch, and switching it off and on again tries afresh.
* health shows on the switch, and each time it comes on it tries afresh,
* whether switched on or shown by default (the pistes of a ski tour), so a
* source that failed earlier never opens a later tour already marked down.
* While it is on and the map (`zoom`, on the raster tile scale) is further out
* than its first tiles, it is marked so: nothing is drawn there, and the switch
* says to zoom in. An unknown zoom marks nothing.
@@ -60,6 +62,10 @@ export function useTourRasterOverlay(
const on = active && offered;
const belowMinZoom = on && zoom !== null && zoom < definition.minZoom;
useEffect(() => {
if (on) reset();
}, [on, reset]);
const onToggle = useCallback(() => {
reset();
toggle();