mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-13 15:51:00 +00:00
fix(roadtrip): a hire car picked up after a night sets off from the stay (#2993)
With hotel bookends on, a day whose first stop was a hire car pick-up got no morning bookend, so the drive from the stay to the desk was missing. Only a landing means the traveller was not at the hotel; the pick-up is the first drive of the day.
This commit is contained in:
@@ -232,16 +232,30 @@ describe('a transfer day', () => {
|
||||
describe('a day that starts or ends on a ride or at a hire car desk', () => {
|
||||
const hotel = stay(5, D1, D4, HOTEL);
|
||||
|
||||
// Landing, or at the desk the car is picked up at: the traveller was not at the hotel.
|
||||
it.each([{ role: 'arrival' }, { role: 'pickup' }] as const)(
|
||||
'ROADTRIP-BOOKENDS-010: no morning when $role opens the day',
|
||||
({ role }) => {
|
||||
const [day] = seatNightBookends([planDay(D2, [terminal(D2, 0, role), visit(D2, 0, { name: 'P' })])], days, [
|
||||
hotel,
|
||||
]);
|
||||
expect(shape(day)).toEqual([role, 'P', 'evening:5']);
|
||||
},
|
||||
);
|
||||
// Landing: the traveller was not at the hotel.
|
||||
it('ROADTRIP-BOOKENDS-010: no morning when an arrival opens the day', () => {
|
||||
const [day] = seatNightBookends([planDay(D2, [terminal(D2, 0, 'arrival'), visit(D2, 0, { name: 'P' })])], days, [
|
||||
hotel,
|
||||
]);
|
||||
expect(shape(day)).toEqual(['arrival', 'P', 'evening:5']);
|
||||
});
|
||||
|
||||
// The desk the car is picked up at is where the first drive goes, from the hotel.
|
||||
it('ROADTRIP-BOOKENDS-039: a hire car picked up after a night sets off from the hotel (#2993)', () => {
|
||||
const [day] = seatNightBookends([planDay(D2, [terminal(D2, 0, 'pickup'), visit(D2, 0, { name: 'P' })])], days, [
|
||||
hotel,
|
||||
]);
|
||||
expect(shape(day)).toEqual(['morning:5', 'pickup', 'P', 'evening:5']);
|
||||
});
|
||||
|
||||
it('ROADTRIP-BOOKENDS-040: on a check-out day, the pick-up comes after the stay checked out of (#2993)', () => {
|
||||
const left = stay(1, D1, D2, GETAWAY);
|
||||
const next = stay(2, D2, D3, WALLINGA);
|
||||
// The desk a short drive from the hotel checked out of, like the airport of the report.
|
||||
const desk = { ...terminal(D2, 0, 'pickup'), lat: GETAWAY[0] + 0.1, lng: GETAWAY[1] + 0.1 };
|
||||
const [day] = seatNightBookends([planDay(D2, [desk, visit(D2, 0, { name: 'P' })])], days, [left, next]);
|
||||
expect(shape(day)).toEqual(['morning:1', 'pickup', 'P', 'evening:2']);
|
||||
});
|
||||
|
||||
// At the gate, or where the car goes back: the traveller is not driving to the hotel.
|
||||
it.each([{ role: 'departure' }, { role: 'return' }] as const)(
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
isDayInAccommodationRange,
|
||||
type DayRef,
|
||||
} from '../day/stay-bookends';
|
||||
import { closesTheDay, isCarrierType, opensTheDay, type CarrierBooking } from './carriers';
|
||||
import { closesTheDay, isCarrierType, type CarrierBooking } from './carriers';
|
||||
import { withinDriveRange } from './corridor';
|
||||
import { stationary } from './dayWindow';
|
||||
import type { BookendPhase, PlanDay, RoadtripStop, RoutedLeg } from './planning-types';
|
||||
@@ -229,7 +229,9 @@ const withinReach = (hotel: BookendStay, stop: RoadtripStop | undefined): boolea
|
||||
* hold them in any order, and the server choose the same one where two overlap.
|
||||
*
|
||||
* The morning gets the stay slept in, unless the day already starts there, or starts on
|
||||
* landing or at a hire car's desk, where the traveller was not at the hotel. The evening
|
||||
* landing, where the traveller was not at the hotel. A day that starts at a hire car's
|
||||
* desk still sets off from the hotel: the traveller checked out and drove or rode to the
|
||||
* desk, and that is the first drive of the day (#2993). The evening
|
||||
* gets tonight's stay, unless the day already ends there, or ends at a departure or at the
|
||||
* desk the hire car goes back to. A day without a stop of its own gets both or neither: a
|
||||
* morning at one hotel and an evening at another is the drive between them, while a day
|
||||
@@ -276,7 +278,7 @@ export function seatNightBookends(
|
||||
const head =
|
||||
!!hotels.morning &&
|
||||
!!hotels.morningIsSleptHere &&
|
||||
!(first && (hotelIsTheStop(hotels.morning, first) || opensTheDay(first.carrier?.role))) &&
|
||||
!(first && (hotelIsTheStop(hotels.morning, first) || first.carrier?.role === 'arrival')) &&
|
||||
withinReach(hotels.morning, first);
|
||||
const tail =
|
||||
!!hotels.evening &&
|
||||
|
||||
+1
-1
@@ -310,7 +310,7 @@ With it on:
|
||||
- These rows are not stops you planned, and nothing is stored for them: they cannot be dragged, removed or given a stay. Clicking one opens the night's booking, or the hotel's place when there is no booking to open. On the phone, a night without a booking opens the stay for somebody who may edit days.
|
||||
- Only real nights count: a stay that checks in and out on the same day adds no row, and neither does a hotel without coordinates. Where two stays overlap, the choice is the one **Days** makes: the day ends at a stay checked in that day, otherwise at one that runs on past that day, and it starts at the stay checked into last before that day, the one entered first where two were checked into on the same day. A drive between two different hotels is then a real drive.
|
||||
- The stop a booking put on its check-in day gives way to that evening's row, the way **Days** hides it: the day checks out, drives its places and ends at tonight's hotel, instead of visiting the hotel in the middle of the day and coming back to it at night. It stays while it is already the day's last stop, or when the day ends at a departure terminal instead. A hotel you placed on the day yourself always stays.
|
||||
- A side of the day that already starts or ends at the hotel gets no row. Neither does a day that starts where a flight, train or ferry lands or at a hire car's pick-up desk, or ends at a departure terminal or where the hire car goes back.
|
||||
- A side of the day that already starts or ends at the hotel gets no row. Neither does a day that starts where a flight, train or ferry lands, or ends at a departure terminal or where the hire car goes back. A day that starts at a hire car's pick-up desk still sets off from the stay, so the drive from the hotel to the desk is on the route.
|
||||
- A day with one place becomes a drive from the hotel to it and back. A day between two nights in the same hotel with no place planned has no drive, and a check-out day with no places is the drive from one hotel to the next.
|
||||
- The drive from and to the hotel keeps its road. Clicking it on the map places no via point and says *No via point on the drive to or from your stay. Add a stop there instead.*, and its drive band offers no **Other ways**. Where the day drives the same road again between two of its places, a click there places the via point on that leg as usual. A place added from the search along that drive goes to the start or the end of the day.
|
||||
- With **Connect the days** on or daily travel times set, a night at one hotel is no drive between the two days. A via point on the drive from one day into the next is kept, but not used while that day ends at a hotel.
|
||||
|
||||
Reference in New Issue
Block a user