fix: the CI findings on the 5.0 release notes and the demo fixes

The overview of a trip's tours decides for itself when it shows, which keeps the planner page hook inside its complexity and length limits, and adds nothing to the camera's key while there is no tour to frame. The elevation helper names its empty case for the strict type check, the self-host wording exemption for the retired Dawarich card goes, the day plan test reads the wrapping pills, and the new tests drop their non-null assertions and loops.
This commit is contained in:
Maurice
2026-10-25 11:03:03 +01:00
parent 9fc98b5d49
commit 6b6d971f07
9 changed files with 40 additions and 29 deletions
@@ -201,9 +201,9 @@ describe('DayPlanSidebar', () => {
const view = render(<DayPlanSidebar {...props} />);
const tourPreview = view.container.querySelector('[data-testid="trip-plan-tour-description"]') as HTMLElement;
expect(tourPreview).toHaveTextContent(description);
// One line like the row's name, so hover controls make the description give way instead of wrapping.
// The description keeps to one line; the pills beside it wrap rather than run out of the row.
expect(tourPreview).toHaveStyle({ whiteSpace: 'nowrap', maxHeight: '1.3em' });
expect(tourPreview.parentElement).toHaveClass('flex-nowrap', 'overflow-hidden');
expect(tourPreview.parentElement).toHaveClass('flex-wrap', 'overflow-hidden');
expect(screen.getByTestId('trip-plan-tour-walking-time')).toHaveTextContent('Walk: 1 h');
expect(screen.getByTestId('trip-plan-tour-breaks')).toHaveTextContent('Breaks: 35 min');
expect(screen.getByTestId('trip-plan-tour-planned-duration')).toHaveTextContent('Planned: 1 h 35 min');
@@ -6,6 +6,13 @@ import { resetAllStores } from '../../../tests/helpers/store';
import type { Place } from '../../types';
import { useTourOverview } from './useTourOverview';
const OPEN = {
activeTab: 'tour-planner',
tourPlanner: { mode: { type: 'neutral' } },
wandererBrowser: { open: false },
} as const;
const EDITING = { ...OPEN, tourPlanner: { mode: { type: 'new-draft' } } } as const;
const PLACES = [
{ id: 1, lat: 46.6, lng: 12.1, route_geometry: '[[46.5,12.0],[46.7,12.2],[46.6,12.3]]' },
{ id: 2, lat: 45.4, lng: 12.3, route_geometry: '[[45.43,12.32],[45.44,12.34]]' },
@@ -18,12 +25,12 @@ describe('useTourOverview', () => {
beforeEach(() => resetAllStores());
it('FE-TP-TOUROVERVIEW-001: shows the tours with a line, not the other places', () => {
const { result } = renderHook(() => useTourOverview(5, PLACES, TOURS, true));
const { result } = renderHook(() => useTourOverview(5, PLACES, TOURS, OPEN));
expect(result.current.tourPlaces.map((place) => place.id)).toEqual([1, 2]);
});
it('FE-TP-TOUROVERVIEW-002: frames each line by its corners', () => {
const { result } = renderHook(() => useTourOverview(5, PLACES, TOURS, true));
const { result } = renderHook(() => useTourOverview(5, PLACES, TOURS, OPEN));
expect(result.current.framePoints).toEqual([
[46.5, 12.0],
[46.7, 12.3],
@@ -34,7 +41,7 @@ describe('useTourOverview', () => {
});
it('FE-TP-TOUROVERVIEW-003: shows nothing while a tour is open', () => {
const { result } = renderHook(() => useTourOverview(5, PLACES, TOURS, false));
const { result } = renderHook(() => useTourOverview(5, PLACES, TOURS, EDITING));
expect(result.current).toEqual({ tourPlaces: [], framePoints: [], focusSuffix: '' });
});
});
@@ -1,4 +1,5 @@
import { useMemo } from 'react';
import type { TourPlannerController } from '../../components/Tours/planner/useTourPlanner';
import { useTourMapVisibility } from '../../components/Tours/useTourMapVisibility';
import type { Place } from '../../types';
import { parseRenderableRouteGeometry } from '../../utils/routeGeometry';
@@ -7,15 +8,21 @@ import { parseRenderableRouteGeometry } from '../../utils/routeGeometry';
* The trip's tours on the Tours map while none is open, as the plan map shows them:
* each tour's place, whose line and marker the map draws in the tour's colour, and the
* corners of those lines for the camera to frame. A tour hidden from the map in the
* list stays off it here too. Empty while `showing` is off (a tour open, an import
* viewed, the wanderer browser up), so the map then shows that alone.
* list stays off it here too. Empty off the Tours tab and while a tour is open, an
* import viewed or the wanderer browser up, so the map then shows that alone.
*/
export function useTourOverview(
tripId: number,
places: readonly Place[],
tourPlaceIds: ReadonlySet<number>,
showing: boolean
view: {
activeTab: string;
tourPlanner: Pick<TourPlannerController, 'mode'>;
wandererBrowser: { open: boolean };
}
) {
const showing =
view.activeTab === 'tour-planner' && view.tourPlanner.mode.type === 'neutral' && !view.wandererBrowser.open;
const { hiddenIds } = useTourMapVisibility(tripId, tourPlaceIds);
const tourPlaces = useMemo(
() =>
@@ -29,7 +36,7 @@ export function useTourOverview(
tourPlaces,
framePoints,
// Part of the camera's key, so the map frames the tours again once they are loaded or one is shown or hidden.
focusSuffix: showing ? `:tours:${tourPlaces.map((place) => place.id).join(',')}` : '',
focusSuffix: tourPlaces.length ? `:tours:${tourPlaces.map((place) => place.id).join(',')}` : '',
};
}
@@ -42,11 +42,7 @@ export function useTripPlannerPage() {
useAssistantEntityLinks({ planner, workspace })
const tourDetailOpenerRef = useRef<{ placeId: number; element: HTMLElement } | null>(null)
// With no tour open, the Tours map shows the trip's tours and frames them.
const tourOverview = useTourOverview(
tripId, places, planner.tourPlaceIds,
activeTab === 'tour-planner' && tourPlanner.mode.type === 'neutral' && !wandererBrowser.open,
)
const tourOverview = useTourOverview(tripId, places, planner.tourPlaceIds, { activeTab, tourPlanner, wandererBrowser })
const { focusPoints, lastPlanMapViewportRef } = usePlannerFocusPoints(activeTab, places, tourPlanner, wandererBrowser, tourOverview.framePoints)
// PAD-06: an obstacle or area the paddle checklist asks for moves the camera as a picked search result does.
+3 -3
View File
@@ -31,9 +31,9 @@ describe('analyzeRouteGeometry', () => {
const analysis = analyzeRouteGeometry(JSON.stringify([
[45.44, 12.32, 2], [45.441, 12.32, 9], [45.442, 12.32, 1], [45.443, 12.32, 4], [45.444, 12.32, 3],
]))
expect(analysis!.maxEle).toBe(9)
expect(analysis!.gain).toBe(7)
expect(analysis!.loss).toBe(8)
expect(analysis?.maxEle).toBe(9)
expect(analysis?.gain).toBe(7)
expect(analysis?.loss).toBe(8)
})
it('maps route endpoints and interpolates focus between prepared samples', () => {