From e40e576e39f0c167b7ea78599e9e8740251a89ea Mon Sep 17 00:00:00 2001 From: Maurice Date: Tue, 20 Oct 2026 16:57:27 +0200 Subject: [PATCH] fix(tours): preset a ski tour's actual track as ski, and cover the run and ride presets Ski has been an importable type since SKI-02, yet a ski tour's recording still opened in the GPX preview as a hike. It now opens as ski with the tour's discipline, and its technique for cross-country. The run profile fallback and the ride preset get their tests. --- .../Tours/activity/tourActivityModel.test.ts | 20 +++++++++++++++++++ .../Tours/activity/tourActivityModel.ts | 17 ++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/client/src/components/Tours/activity/tourActivityModel.test.ts b/client/src/components/Tours/activity/tourActivityModel.test.ts index 2bf2952c7..a5db75d1b 100644 --- a/client/src/components/Tours/activity/tourActivityModel.test.ts +++ b/client/src/components/Tours/activity/tourActivityModel.test.ts @@ -120,6 +120,26 @@ describe('the GPX preset', () => { }); expect(importFieldsFor(tour({ tour_type: 'walk' }))).toEqual({ tour_type: 'walk' }); expect(importFieldsFor(tour({ tour_type: 'ski' }))).toEqual({ tour_type: 'hike' }); + expect(importFieldsFor(tour({ tour_type: 'ski', ski_discipline: 'touring', ski_technique: null }))).toEqual({ + tour_type: 'ski', + ski_discipline: 'touring', + }); + const skating = { tour_type: 'ski', ski_discipline: 'cross_country', ski_technique: 'skating' } as const; + expect(importFieldsFor(tour(skating))).toEqual(skating); + expect(importFieldsFor(tour({ tour_type: 'ski', ski_discipline: 'cross_country', ski_technique: null }))).toEqual({ + tour_type: 'ski', + ski_discipline: 'cross_country', + ski_technique: 'unknown', + }); + expect(importFieldsFor(tour({ tour_type: 'run', run_profile: 'trail' }))).toEqual({ + tour_type: 'run', + run_profile: 'trail', + }); + expect(importFieldsFor(tour({ tour_type: 'run', run_profile: null }))).toEqual({ + tour_type: 'run', + run_profile: 'running', + }); + expect(importFieldsFor(tour({ tour_type: 'horse' }))).toEqual({ tour_type: 'horse' }); }); }); diff --git a/client/src/components/Tours/activity/tourActivityModel.ts b/client/src/components/Tours/activity/tourActivityModel.ts index 95f6e34c5..60652e89a 100644 --- a/client/src/components/Tours/activity/tourActivityModel.ts +++ b/client/src/components/Tours/activity/tourActivityModel.ts @@ -80,15 +80,24 @@ export function trackCandidates(tours: readonly TourListItem[], placeId: number) /** * The type a recording of this tour is imported as, preset in the GPX - * preview: the tour's own, with its bike or run profile or its boat and water where - * it has them. A type the import does not offer starts as a hike, as the - * preview always did. + * preview: the tour's own, with its bike or run profile, its boat and water, + * or its ski discipline and technique where it has them. A type the import + * does not offer, and a ski tour without a discipline (which the import + * refuses for ski), starts as a hike, as the preview always did. */ export function importFieldsFor( tour: Pick & - Partial> + Partial> ): TourGpxImportFields { switch (tour.tour_type) { + case 'ski': + if (!tour.ski_discipline) return { tour_type: 'hike' }; + return { + tour_type: 'ski', + ski_discipline: tour.ski_discipline, + // Only cross-country is done in a technique; unknown when the travellers did not know it. + ...(tour.ski_discipline === 'cross_country' ? { ski_technique: tour.ski_technique ?? 'unknown' } : {}), + }; case 'bike': return { tour_type: 'bike', bike_profile: tour.bike_profile ?? 'touring' }; case 'run':