mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 01:28:55 +00:00
fix(roadtrip): a booked night holds its check-in and heads its day
A hotel entered under Days with a check-in at ten was reached at a quarter past twelve in road trip mode. Two things: the schedule read the check-in as a floor that held nothing once anything before it set the clock, and the server seated the night last unless something pinned later pulled it forward, so two stops without an hour stood ahead of it. The check-in now pins the night the way its own time would, in the plain schedule and in the daily window, where a check-in the drive cannot make is the conflict a missed pin is. The night is seated first on its day; only a stop with a clock at or before the check-in stays ahead of it, and the stops without one follow. A new check-in seats the night afresh, a change of notes leaves a dragged night where it is. A day that is nothing but its booked night stands among the days now, with the hotel and its check-in, instead of at the foot of the rail under "only X so far", which read as the hotel missing from the road trip. The client puts a stop the server seated at the front where the server put it, rather than appending it to draw second until the next reload.
This commit is contained in:
@@ -164,9 +164,16 @@ export class AccommodationsService {
|
||||
return this.mirrorStay(accommodationId, placeId, dayId, checkIn);
|
||||
}
|
||||
|
||||
/** Carry a stay's own stop over to where the stay now is. */
|
||||
moveStayStop(accommodationId: number, placeId: number | null, dayId: number, checkIn?: string | null): AccommodationMirror {
|
||||
return this.remirrorStay(accommodationId, placeId, dayId, checkIn);
|
||||
/** Carry a stay's own stop over to where the stay now is. `checkInChanged` says the
|
||||
* booking was given a new hour, which seats the night afresh (see remirrorStay). */
|
||||
moveStayStop(
|
||||
accommodationId: number,
|
||||
placeId: number | null,
|
||||
dayId: number,
|
||||
checkIn?: string | null,
|
||||
opts: { checkInChanged?: boolean } = {},
|
||||
): AccommodationMirror {
|
||||
return this.remirrorStay(accommodationId, placeId, dayId, checkIn, opts);
|
||||
}
|
||||
|
||||
/** Take back the stops of a stay that is being deleted elsewhere. */
|
||||
@@ -277,17 +284,16 @@ export class AccommodationsService {
|
||||
/**
|
||||
* Where in the day the booked night belongs.
|
||||
*
|
||||
* Last, unless the booking names an hour. A night usually ends the day, which is why
|
||||
* that is the default — but a check-in at eleven says the traveller is at the desk
|
||||
* before whatever they pinned to the afternoon, and dropping the stop behind it built
|
||||
* a drive that visits the hotel after the sixteen-hundred it was booked around.
|
||||
*
|
||||
* Only stops that carry a clock of their own are compared. One without a time takes
|
||||
* its position from the chain, not from the hour, so pushing past it would move a
|
||||
* stop the traveller placed deliberately.
|
||||
* First. The hotel is where the day is based: the traveller checks in and the stops
|
||||
* they placed without an hour follow from there. Only a stop with a clock of its
|
||||
* own can stand ahead of it, and only when that clock is at or before the check-in:
|
||||
* a stop pinned to eight with a check-in at ten puts the night second, one pinned
|
||||
* to the afternoon does not. It used to go last unless something pinned later
|
||||
* pulled it forward, and a night booked for ten in the morning sat behind a whole
|
||||
* day of unpinned stops, reached at a quarter past twelve.
|
||||
*/
|
||||
private positionForCheckIn(dayId: number, checkIn: string | null | undefined, excludeId?: number): number | undefined {
|
||||
if (!checkIn) return undefined;
|
||||
private positionForCheckIn(dayId: number, checkIn: string | null | undefined, excludeId?: number): number {
|
||||
if (!checkIn) return 0;
|
||||
// excludeId leaves the row being re-seated out of the chain it is measured
|
||||
// against. Without it a night parked at the end of the day can find itself.
|
||||
const rows = this.db.all<{ order_index: number; at: string | null }>(`
|
||||
@@ -295,18 +301,20 @@ export class AccommodationsService {
|
||||
FROM day_assignments da JOIN places p ON p.id = da.place_id
|
||||
WHERE da.day_id = ? AND da.id != ? ORDER BY da.order_index
|
||||
`, dayId, excludeId ?? -1);
|
||||
const later = rows.find(row => row.at !== null && row.at > checkIn);
|
||||
return later?.order_index;
|
||||
let seat = 0;
|
||||
for (const row of rows) if (row.at !== null && row.at <= checkIn) seat = row.order_index + 1;
|
||||
return seat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the night already sits where its check-in says it should.
|
||||
* Whether the night sits somewhere its check-in allows, on an edit that did not
|
||||
* touch the check-in.
|
||||
*
|
||||
* Read off the chain rather than recomputed, because the index a fresh insert would
|
||||
* get is not the index this row already occupies. Two ways to be wrong: something
|
||||
* with a later hour ahead of it, or something with an earlier one behind it. Stops
|
||||
* without an hour are passed over in both directions — their place in the chain is
|
||||
* the traveller's doing, not a clock's.
|
||||
* without an hour are passed over in both directions: the night may have been
|
||||
* dragged past them on purpose, and a change of notes is no reason to undo that.
|
||||
*/
|
||||
private seatedByCheckIn(dayId: number, ownId: number, checkIn: string | null | undefined): boolean {
|
||||
if (!checkIn) return true;
|
||||
@@ -493,7 +501,7 @@ export class AccommodationsService {
|
||||
this.db.run('UPDATE day_assignments SET day_id = ?, place_id = ?, order_index = ? WHERE id = ?', dayId, placeId, end, stop.id);
|
||||
|
||||
const seat = this.positionForCheckIn(dayId, checkIn, stop.id);
|
||||
if (seat !== undefined && seat < end) {
|
||||
if (seat < end) {
|
||||
this.db.run(
|
||||
'UPDATE day_assignments SET order_index = order_index + 1 WHERE day_id = ? AND order_index >= ? AND id != ?',
|
||||
dayId, seat, stop.id,
|
||||
@@ -519,9 +527,8 @@ export class AccommodationsService {
|
||||
if (this.db.get('SELECT id FROM day_assignments WHERE day_id = ? AND place_id = ?', dayId, placeId)) return mirror;
|
||||
|
||||
const before = this.stopOrders([dayId]);
|
||||
// Through AssignmentsService, so the stop lands at the end of the day with the
|
||||
// order_index every other new assignment gets. Evening is where you arrive at a
|
||||
// hotel, and the day planner has no drive to position it against anyway.
|
||||
// Through AssignmentsService, seated where the check-in says (see
|
||||
// positionForCheckIn), with everything behind it moved up one.
|
||||
//
|
||||
// The booking id goes in with the INSERT, not as an UPDATE afterwards: what this
|
||||
// returns is the row the answer hands the client, and stamping the id on later
|
||||
@@ -590,14 +597,24 @@ export class AccommodationsService {
|
||||
*
|
||||
* Runs inside the caller's transaction.
|
||||
*/
|
||||
private remirrorStay(accommodationId: number, placeId: number | null, dayId: number, checkIn?: string | null): AccommodationMirror {
|
||||
private remirrorStay(
|
||||
accommodationId: number,
|
||||
placeId: number | null,
|
||||
dayId: number,
|
||||
checkIn?: string | null,
|
||||
opts: { checkInChanged?: boolean } = {},
|
||||
): AccommodationMirror {
|
||||
const own = this.ownStops(accommodationId);
|
||||
if (own.length === 0) return noMirror();
|
||||
if (own.length === 1 && own[0].day_id === dayId && own[0].place_id === placeId) {
|
||||
// Same place, same day — but a check-in moved to a different hour can still put
|
||||
// the night somewhere else in the chain, and a stop sitting after the afternoon
|
||||
// it was booked around is the plan reading back wrong.
|
||||
if (this.seatedByCheckIn(dayId, own[0].id, checkIn)) return noMirror();
|
||||
// Same place, same day. A check-in given a new hour seats the night afresh, the
|
||||
// way booking it with that hour would have; any other edit leaves a stop where
|
||||
// it is unless the clocks around it say it is in the wrong place, so a night the
|
||||
// traveller dragged somewhere stays there through a change of notes.
|
||||
const settled = opts.checkInChanged
|
||||
? this.positionForCheckIn(dayId, checkIn, own[0].id) === own[0].order_index
|
||||
: this.seatedByCheckIn(dayId, own[0].id, checkIn);
|
||||
if (settled) return noMirror();
|
||||
}
|
||||
|
||||
const mirror = noMirror();
|
||||
@@ -689,7 +706,9 @@ export class AccommodationsService {
|
||||
'UPDATE day_accommodations SET place_id = ?, start_day_id = ?, end_day_id = ?, check_in = ?, check_in_end = ?, check_out = ?, confirmation = ?, notes = ? WHERE id = ?',
|
||||
newPlaceId, newStartDayId, newEndDayId, newCheckIn, newCheckInEnd, newCheckOut, newConfirmation, newNotes, id
|
||||
);
|
||||
return this.remirrorStay(Number(id), newPlaceId, newStartDayId, newCheckIn);
|
||||
return this.remirrorStay(Number(id), newPlaceId, newStartDayId, newCheckIn, {
|
||||
checkInChanged: fields.check_in !== undefined && (fields.check_in || null) !== (existing.check_in || null),
|
||||
});
|
||||
});
|
||||
|
||||
// Sync check-in/out/confirmation to every linked reservation. The booking form
|
||||
|
||||
@@ -846,6 +846,7 @@ export class ReservationsService {
|
||||
if (start_day_id && end_day_id) {
|
||||
this.requireResolvableStay(create_accommodation);
|
||||
if (resolvedAccId) {
|
||||
const prior = this.db.get<{ check_in: string | null }>('SELECT check_in FROM day_accommodations WHERE id = ?', resolvedAccId);
|
||||
this.db.run(
|
||||
'UPDATE day_accommodations SET place_id = ?, start_day_id = ?, end_day_id = ?, check_in = ?, check_out = ?, confirmation = ? WHERE id = ?',
|
||||
accPlaceId || null, start_day_id, end_day_id, check_in || null, check_out || null, accConf || confirmation_number || null, resolvedAccId
|
||||
@@ -853,7 +854,9 @@ export class ReservationsService {
|
||||
// The stay just moved. Its stop moves with it, or it is left sitting on a
|
||||
// day nobody sleeps there any more, hidden from the day list because it
|
||||
// still carries this booking's id and stranded in the middle of the drive.
|
||||
stayMirror = this.accommodations.moveStayStop(resolvedAccId, accPlaceId || null, start_day_id, check_in);
|
||||
stayMirror = this.accommodations.moveStayStop(resolvedAccId, accPlaceId || null, start_day_id, check_in, {
|
||||
checkInChanged: (check_in || null) !== (prior?.check_in ?? null),
|
||||
});
|
||||
} else if (accPlaceId) {
|
||||
const accResult = this.db.run(
|
||||
'INSERT INTO day_accommodations (trip_id, place_id, start_day_id, end_day_id, check_in, check_out, confirmation) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
type RoutedLeg,
|
||||
type SnappedWaypoint,
|
||||
type RouteAvoidClass,
|
||||
standsAsDay,
|
||||
} from '@trek/shared/roadtrip';
|
||||
|
||||
interface StoredDay {
|
||||
@@ -32,6 +33,8 @@ interface StoredDay {
|
||||
default_transport_mode: string | null;
|
||||
}
|
||||
interface VisitRow {
|
||||
/** The booking this stop stands for on its check-in day, when there is one. */
|
||||
stay_id: number | null;
|
||||
check_in: string | null;
|
||||
/** The drive does not read these two (#2357): they are the booking as get_roadtrip_context reports it. */
|
||||
check_out: string | null;
|
||||
@@ -75,7 +78,7 @@ export class RoadtripPlanService {
|
||||
`SELECT a.id, a.day_id, a.place_id, p.name, p.lat, p.lng,
|
||||
COALESCE(a.assignment_time, p.place_time) AS time, COALESCE(a.assignment_end_time, p.end_time) AS end_time,
|
||||
p.duration_minutes, a.end_day,
|
||||
a.leg_transport_mode, a.incoming_leg_transport_mode, p.stop_type, p.fill_percent, stay.check_in, stay.check_out, checkout.day_number AS checkout_day
|
||||
a.leg_transport_mode, a.incoming_leg_transport_mode, p.stop_type, p.fill_percent, stay.id AS stay_id, stay.check_in, stay.check_out, checkout.day_number AS checkout_day
|
||||
FROM day_assignments a JOIN days d ON d.id = a.day_id JOIN places p ON p.id = a.place_id
|
||||
LEFT JOIN day_accommodations stay ON stay.id = (SELECT id FROM day_accommodations WHERE place_id = p.id AND start_day_id = d.id ORDER BY id LIMIT 1)
|
||||
LEFT JOIN days checkout ON checkout.id = stay.end_day_id
|
||||
@@ -123,6 +126,7 @@ export class RoadtripPlanService {
|
||||
// planner makes in the browser (useRoadtripRoutes).
|
||||
leaveAt: v.end_time,
|
||||
checkInTime: v.check_in,
|
||||
night: v.stay_id !== null,
|
||||
dwellMinutes: v.duration_minutes,
|
||||
endDay: v.end_day === 1,
|
||||
legMode: v.leg_transport_mode,
|
||||
@@ -245,8 +249,8 @@ export class RoadtripPlanService {
|
||||
preferences.roadtrip_range_km,
|
||||
) || null;
|
||||
const calculated = assembleRoadtrip({
|
||||
plan: plan.filter((d) => d.stops.length > 1),
|
||||
quietDays: plan.filter((d) => d.stops.length < 2),
|
||||
plan: plan.filter((d) => standsAsDay(d.stops)),
|
||||
quietDays: plan.filter((d) => !standsAsDay(d.stops)),
|
||||
window,
|
||||
allLegs,
|
||||
snapByDay,
|
||||
|
||||
@@ -615,7 +615,10 @@ describe('the day stop a booking implies', () => {
|
||||
expect(mirror.created.accommodation_id).toBe(accommodation.id);
|
||||
});
|
||||
|
||||
it('ACC-022 the stop lands at the end of the day, where you arrive at a hotel', () => {
|
||||
it('ACC-022 the stop lands first: the hotel is where the day is based', () => {
|
||||
// It used to go last, and a night booked for the morning sat behind a whole day
|
||||
// of unpinned stops. The stops the traveller placed without an hour follow the
|
||||
// hotel; only a clock of their own can put one ahead of it (ACC-022c).
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const day = createDay(testDb, trip.id);
|
||||
@@ -625,13 +628,12 @@ describe('the day stop a booking implies', () => {
|
||||
|
||||
book(trip.id, hotel.id, day.id, day.id);
|
||||
|
||||
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([museum.id, hotel.id]);
|
||||
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([hotel.id, museum.id]);
|
||||
expect(stopsOn(day.id).map(a => a.order_index)).toEqual([0, 1]);
|
||||
});
|
||||
|
||||
it('ACC-022b a check-in puts the night before whatever is pinned to a later hour', () => {
|
||||
// The default is last, because a night usually ends the day. A check-in at eleven
|
||||
// says otherwise, and dropping the stop behind a stop pinned to the afternoon built
|
||||
// a drive that reaches the hotel after the hour it was booked around.
|
||||
// A stop pinned to the afternoon cannot stand ahead of a check-in at eleven.
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const day = createDay(testDb, trip.id);
|
||||
@@ -645,7 +647,7 @@ describe('the day stop a booking implies', () => {
|
||||
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([hotel.id, afternoon.id]);
|
||||
});
|
||||
|
||||
it('ACC-022c a check-in after everything pinned stays last, like a night without one', () => {
|
||||
it('ACC-022c a stop pinned to an earlier hour stays ahead of the check-in', () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const day = createDay(testDb, trip.id);
|
||||
@@ -659,18 +661,67 @@ describe('the day stop a booking implies', () => {
|
||||
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([morning.id, hotel.id]);
|
||||
});
|
||||
|
||||
it('ACC-022d a stop without an hour of its own is never pushed past', () => {
|
||||
// Its position came from the chain, not from a clock, so the traveller put it there.
|
||||
it('ACC-022d a stop without an hour of its own follows the night, whatever the check-in', () => {
|
||||
// A stop with no clock is planned from the hotel, not the other way round. This
|
||||
// is the day from Discord: two unpinned stops and a night booked for ten in the
|
||||
// morning, which the drive used to reach at a quarter past twelve.
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const day = createDay(testDb, trip.id);
|
||||
const untimed = createPlace(testDb, trip.id, { name: 'Hafen' });
|
||||
const hotel = createPlace(testDb, trip.id, { name: 'Billstedt' });
|
||||
createDayAssignment(testDb, day.id, untimed.id);
|
||||
const fuel = createPlace(testDb, trip.id, { name: 'Aral' });
|
||||
const farm = createPlace(testDb, trip.id, { name: 'Karls Erdbeerhof' });
|
||||
const hotel = createPlace(testDb, trip.id, { name: 'Rostock' });
|
||||
createDayAssignment(testDb, day.id, fuel.id);
|
||||
createDayAssignment(testDb, day.id, farm.id);
|
||||
|
||||
svc.createAccommodation(trip.id, { place_id: hotel.id, start_day_id: day.id, end_day_id: day.id, check_in: '11:00' });
|
||||
svc.createAccommodation(trip.id, { place_id: hotel.id, start_day_id: day.id, end_day_id: day.id, check_in: '10:00' });
|
||||
|
||||
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([untimed.id, hotel.id]);
|
||||
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([hotel.id, fuel.id, farm.id]);
|
||||
});
|
||||
|
||||
it('ACC-022f the night goes behind the last stop whose own hour is at or before the check-in', () => {
|
||||
// Pinned eight, unpinned, pinned two: a check-in at ten sits behind the eight and
|
||||
// ahead of everything else, the unpinned stop included.
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const day = createDay(testDb, trip.id);
|
||||
const [early, loose, late, hotel] = ['Aral', 'Hafen', 'Museum', 'Rostock'].map(name => createPlace(testDb, trip.id, { name }));
|
||||
const first = createDayAssignment(testDb, day.id, early.id);
|
||||
createDayAssignment(testDb, day.id, loose.id);
|
||||
const third = createDayAssignment(testDb, day.id, late.id);
|
||||
testDb.prepare("UPDATE day_assignments SET assignment_time = '08:00' WHERE id = ?").run(first.id);
|
||||
testDb.prepare("UPDATE day_assignments SET assignment_time = '14:00' WHERE id = ?").run(third.id);
|
||||
|
||||
svc.createAccommodation(trip.id, { place_id: hotel.id, start_day_id: day.id, end_day_id: day.id, check_in: '10:00' });
|
||||
|
||||
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([early.id, hotel.id, loose.id, late.id]);
|
||||
});
|
||||
|
||||
it('ACC-022g a new check-in seats the night afresh, a change of notes leaves a dragged night alone', () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const day = createDay(testDb, trip.id);
|
||||
const [harbour, market, hotel] = ['Hafen', 'Markt', 'Rostock'].map(name => createPlace(testDb, trip.id, { name }));
|
||||
createDayAssignment(testDb, day.id, harbour.id);
|
||||
createDayAssignment(testDb, day.id, market.id);
|
||||
const { accommodation } = svc.createAccommodation(trip.id, { place_id: hotel.id, start_day_id: day.id, end_day_id: day.id }) as any;
|
||||
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([hotel.id, harbour.id, market.id]);
|
||||
|
||||
// Dragged to the end of the day by hand.
|
||||
const own = stopsOn(day.id).find(a => a.place_id === hotel.id)!;
|
||||
testDb.prepare('UPDATE day_assignments SET order_index = order_index - 1 WHERE day_id = ? AND order_index > ?').run(day.id, own.order_index);
|
||||
testDb.prepare('UPDATE day_assignments SET order_index = 2 WHERE id = ?').run(own.id);
|
||||
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([harbour.id, market.id, hotel.id]);
|
||||
|
||||
let existing = svc.getAccommodation(accommodation.id, trip.id)!;
|
||||
const quiet = svc.updateAccommodation(accommodation.id, existing, { notes: 'late arrival' }) as any;
|
||||
expect(quiet.mirror.moved).toBeNull();
|
||||
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([harbour.id, market.id, hotel.id]);
|
||||
|
||||
existing = svc.getAccommodation(accommodation.id, trip.id)!;
|
||||
const reseated = svc.updateAccommodation(accommodation.id, existing, { check_in: '10:00' }) as any;
|
||||
expect(reseated.mirror.moved).toMatchObject({ oldDayId: day.id, assignment: { id: own.id } });
|
||||
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([hotel.id, harbour.id, market.id]);
|
||||
});
|
||||
|
||||
it('ACC-022e moving the check-in later re-seats the night', () => {
|
||||
@@ -887,7 +938,10 @@ describe('the day stop a booking implies', () => {
|
||||
createDayAssignment(testDb, day.id, dinner.id);
|
||||
const { accommodation } = book(trip.id, hotel.id, day.id, day.id);
|
||||
const stop = stopsOn(day.id).find((row: { place_id: number }) => row.place_id === hotel.id)!;
|
||||
expect(stop.order_index).toBe(1);
|
||||
// The backfill's placement, written by hand: the night behind the dinner.
|
||||
testDb.prepare('UPDATE day_assignments SET order_index = 0 WHERE day_id = ? AND place_id = ?').run(day.id, dinner.id);
|
||||
testDb.prepare('UPDATE day_assignments SET order_index = 1 WHERE id = ?').run(stop.id);
|
||||
expect(stopsOn(day.id).map((row: { place_id: number }) => row.place_id)).toEqual([dinner.id, hotel.id]);
|
||||
|
||||
const existing = svc.getAccommodation(accommodation.id, trip.id)!;
|
||||
const { mirror } = svc.updateAccommodation(accommodation.id, existing, { check_in: '15:00' }) as any;
|
||||
@@ -1051,13 +1105,13 @@ describe('the drawn roads a booking moves', () => {
|
||||
const pin = (assignmentId: number, time: string) =>
|
||||
testDb.prepare('UPDATE day_assignments SET assignment_time = ? WHERE id = ?').run(time, assignmentId);
|
||||
|
||||
/** A(0), B(1) pinned to noon, C(2): the day a check-in at eleven lands in the middle of. */
|
||||
/** A(0) pinned to nine, B(1) pinned to noon, C(2): the day a check-in at eleven lands in the middle of. */
|
||||
function afternoonDay() {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const day = createDay(testDb, trip.id);
|
||||
const [a, b, c, hotel] = ['Harbour', 'Mercure', 'Museum', 'Billstedt'].map(name => createPlace(testDb, trip.id, { name }));
|
||||
createDayAssignment(testDb, day.id, a.id);
|
||||
pin(createDayAssignment(testDb, day.id, a.id).id, '09:00');
|
||||
pin(createDayAssignment(testDb, day.id, b.id).id, '12:00');
|
||||
createDayAssignment(testDb, day.id, c.id);
|
||||
return { trip, day, a, b, c, hotel };
|
||||
@@ -1091,20 +1145,22 @@ describe('the drawn roads a booking moves', () => {
|
||||
}]);
|
||||
});
|
||||
|
||||
it('ACC-034b a night appended at the end of the day moves no road and reports none', () => {
|
||||
it('ACC-034b a night seated behind every drawn road moves none and reports none', () => {
|
||||
const { trip, day, a, b, c, hotel } = afternoonDay();
|
||||
const afterA = addVia(day.id, 0);
|
||||
const afterB = addVia(day.id, 1);
|
||||
|
||||
const { mirror } = svc.createAccommodation(trip.id, { place_id: hotel.id, start_day_id: day.id, end_day_id: day.id }) as any;
|
||||
const { mirror } = svc.createAccommodation(trip.id, { place_id: hotel.id, start_day_id: day.id, end_day_id: day.id, check_in: '18:00' }) as any;
|
||||
|
||||
expect(stopsOn(day.id)).toEqual([a.id, b.id, c.id, hotel.id]);
|
||||
expect(stopsOn(day.id)).toEqual([a.id, b.id, hotel.id, c.id]);
|
||||
expect(viaAnchors(day.id)).toEqual([{ id: afterA, after_order_index: 0 }, { id: afterB, after_order_index: 1 }]);
|
||||
expect(mirror.vias).toBeUndefined();
|
||||
});
|
||||
|
||||
it('ACC-034c re-seating the night by a later check-in re-pins the roads around it', () => {
|
||||
const { trip, day, a, b, c, hotel } = afternoonDay();
|
||||
// C pinned to the afternoon as well, so an evening check-in puts the night last.
|
||||
testDb.prepare("UPDATE day_assignments SET assignment_time = '15:00' WHERE day_id = ? AND place_id = ?").run(day.id, c.id);
|
||||
const { accommodation } = svc.createAccommodation(trip.id, { place_id: hotel.id, start_day_id: day.id, end_day_id: day.id, check_in: '11:00' }) as any;
|
||||
expect(stopsOn(day.id)).toEqual([a.id, hotel.id, b.id, c.id]);
|
||||
const afterA = addVia(day.id, 0);
|
||||
@@ -1134,7 +1190,7 @@ describe('the drawn roads a booking moves', () => {
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const day = createDay(testDb, trip.id);
|
||||
const [a, b, hotel] = ['Harbour', 'Mercure', 'Billstedt'].map(name => createPlace(testDb, trip.id, { name }));
|
||||
createDayAssignment(testDb, day.id, a.id);
|
||||
pin(createDayAssignment(testDb, day.id, a.id).id, '09:00');
|
||||
pin(createDayAssignment(testDb, day.id, b.id).id, '12:00');
|
||||
const { accommodation } = svc.createAccommodation(trip.id, { place_id: hotel.id, start_day_id: day.id, end_day_id: day.id, check_in: '11:00' }) as any;
|
||||
expect(stopsOn(day.id)).toEqual([a.id, hotel.id, b.id]);
|
||||
@@ -1168,7 +1224,7 @@ describe('the drawn roads a booking moves', () => {
|
||||
const day1 = createDay(testDb, trip.id);
|
||||
const day2 = createDay(testDb, trip.id);
|
||||
const [a, b, c, hotel] = ['Harbour', 'Mercure', 'Museum', 'Billstedt'].map(name => createPlace(testDb, trip.id, { name }));
|
||||
createDayAssignment(testDb, day1.id, a.id);
|
||||
pin(createDayAssignment(testDb, day1.id, a.id).id, '09:00');
|
||||
pin(createDayAssignment(testDb, day1.id, b.id).id, '12:00');
|
||||
pin(createDayAssignment(testDb, day2.id, c.id).id, '14:00');
|
||||
const { accommodation } = svc.createAccommodation(trip.id, { place_id: hotel.id, start_day_id: day1.id, end_day_id: day1.id, check_in: '11:00' }) as any;
|
||||
|
||||
Reference in New Issue
Block a user