mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 15:40:06 +00:00
fix(roadtrip): a hotel visited again on its check-in day is the night only at its last visit
A stop counted as the booked night whenever a stay began at its place on its day, so a hotel on its check-in day twice (the booking's own stop and a rest the traveller planned there) was read as two nights. Both were held to the check-in: the rest waited for the room or was set back to it, and with a check-in far from its arrival the rest and every stop behind it moved onto the next day's card. oneNightPerStay in shared keeps the night and its check-in on the last visit of the place and turns the earlier ones into ordinary stops, still a hotel. The browser and calculate_roadtrip both run it, the stored ride slot times only that row by the check-in, and opening an earlier visit in road trip mode opens the stop rather than the night. Refs #2636
This commit is contained in:
@@ -1405,6 +1405,34 @@ describe('a booked night at both ends of its days', () => {
|
||||
expect(runs).toContainEqual(['driving', [HOTEL[0], P[4][0], P[5][0], HOTEL[0]]])
|
||||
})
|
||||
|
||||
it('FE-ROADTRIP-ROUTES-065: a hotel visited again on its check-in day is the night only at its last visit (#2636)', async () => {
|
||||
switchTo(false)
|
||||
const days = [day(1, 1), day(2, 2)]
|
||||
// A rest at the hotel at noon, a place, and back to the hotel for the night.
|
||||
const assignments = map(1, [
|
||||
{ id: 1, at: P[0], time: '09:00', dwell: 0 },
|
||||
{ id: 2, at: HOTEL, dwell: 60 },
|
||||
{ id: 3, at: P[1], dwell: 30 },
|
||||
{ id: 4, at: HOTEL },
|
||||
]) as AssignmentsMap
|
||||
Object.assign(assignments['1'][3], { place_id: 20 })
|
||||
const stays = [stayOf(5, 2, 1, 2, HOTEL, { check_in: '15:00' })]
|
||||
const { result } = renderHook(() => useRoadtripRoutes(7, days, assignments, 'driving', {}, [], stays))
|
||||
await waitFor(() => expect(result.current.loading).toBe(false))
|
||||
|
||||
const [card] = result.current.days
|
||||
expect(card.stops.map(s => [s.name, s.night, s.checkInTime])).toEqual([
|
||||
['Stop 1', false, null],
|
||||
['Stop 2', false, null],
|
||||
['Stop 3', false, null],
|
||||
['Stop 4', true, '15:00'],
|
||||
])
|
||||
// The rest is reached when the drive gets there, the night waits for the room.
|
||||
expect(card.schedule.entries.map(e => e.arrival)).toEqual(['09:00', '10:00', '12:00', '15:00'])
|
||||
expect(card.schedule.warnings).toEqual([])
|
||||
expect(result.current.days.map(d => d.dayId)).toEqual([1])
|
||||
})
|
||||
|
||||
it('FE-ROADTRIP-ROUTES-064: the stop tonight’s booking put first on its day gives way to the evening at the stay (#2546)', async () => {
|
||||
const { days } = cam()
|
||||
const stays = [stayOf(1, 1, 1, 2, GETAWAY), stayOf(2, 4, 2, 3, WALLINGA)]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useRoadtripSettings } from '../../hooks/useRoadtripSettings'
|
||||
import { assembleRoadtrip, bookendStaysOf, carrierLegsFor, carrierSeam, foldRouteRun, hotelBookendsOn, isCarrierMode, isStationaryJoin, mergeRouteSegments, seatCarrierStops, seatNightBookends, standsAsDay, terminalAssignmentId, viasOnLeg, type CarrierSeam, type RoadtripStop, type RoadtripRoutes, type PlanDay, type QuietDay, type RoutedLeg } from '@trek/shared/roadtrip'
|
||||
import { assembleRoadtrip, bookendStaysOf, carrierLegsFor, carrierSeam, foldRouteRun, hotelBookendsOn, isCarrierMode, isStationaryJoin, mergeRouteSegments, oneNightPerStay, seatCarrierStops, seatNightBookends, standsAsDay, terminalAssignmentId, viasOnLeg, type CarrierSeam, type RoadtripStop, type RoadtripRoutes, type PlanDay, type QuietDay, type RoutedLeg } from '@trek/shared/roadtrip'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { avoidedClasses, calculateRouteWithLegs, routeEngineFor, RoutingRefusedError, type RouteEngine } from '../Map/RouteCalculator'
|
||||
import { resolveLegMode } from '../Planner/legMode'
|
||||
@@ -319,8 +319,9 @@ export function useRoadtripRoutes(
|
||||
.filter((x): x is { assignment: Assignment; stop: RoadtripStop } => x.stop !== null)
|
||||
// The index is filled in after the drop, because it is the index into THIS
|
||||
// list: an assignment whose place has no coordinates never becomes a stop, and
|
||||
// counting before the filter would name a row the rail does not draw.
|
||||
const stops = located.map((x, i) => ({ ...x.stop, ownerIndex: i }))
|
||||
// counting before the filter would name a row the rail does not draw. A hotel
|
||||
// visited twice on its check-in day is the night at its last visit only.
|
||||
const stops = oneNightPerStay(located.map((x, i) => ({ ...x.stop, ownerIndex: i })))
|
||||
return {
|
||||
dayId: d.id,
|
||||
dayNumber: d.day_number ?? 0,
|
||||
|
||||
Reference in New Issue
Block a user