mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-22 23:16:46 +00:00
fix(roadtrip): sort a booked night by its check-in, and clear the lint the cut left
Pinning an afternoon stop sorted that one and left the hotel it was booked around sitting behind it. The day's auto-sort reads each stop's own hour, and a booked night has none: nobody types a time into a hotel row, they type a check-in, and that lives on the booking. It counts now, so the night moves with everything else instead of staying where it was dropped. The assignments e2e builds its own tables and had neither the accommodation column nor day_accommodations, so every create in that file 500'd as soon as the insert learned to carry a booking id. Both are there now. And the shared lint, which is stricter than the other two and which I had not run: three leftovers from taking the check-out out of the chain, none of them used any more.
This commit is contained in:
@@ -369,6 +369,25 @@ describe('updateTime', () => {
|
||||
expect([order(a.id), order(c.id), order(b.id)]).toEqual([0, 1, 2]);
|
||||
});
|
||||
|
||||
it('ASG-SVC-022b: a booked night sorts by its check-in, which is where its hour lives', () => {
|
||||
// Nobody types a time into a hotel row, they type a check-in, and it sits on the
|
||||
// booking. Counted as untimed, the night stayed wherever it had been dropped: pin an
|
||||
// afternoon stop and the hotel it was booked around ended up behind it.
|
||||
const { trip, day, place } = fixture();
|
||||
const hotel = createPlace(testDb, trip.id, { name: 'Billstedt' });
|
||||
const afternoon = createDayAssignment(testDb, day.id, place.id, { order_index: 0 });
|
||||
const night = createDayAssignment(testDb, day.id, hotel.id, { order_index: 1 });
|
||||
const stay = testDb.prepare(
|
||||
"INSERT INTO day_accommodations (trip_id, place_id, start_day_id, end_day_id, check_in) VALUES (?, ?, ?, ?, '11:00')"
|
||||
).run(trip.id, hotel.id, day.id, day.id);
|
||||
testDb.prepare('UPDATE day_assignments SET accommodation_id = ? WHERE id = ?').run(Number(stay.lastInsertRowid), night.id);
|
||||
|
||||
svc.updateTime(afternoon.id, '16:00', null);
|
||||
|
||||
const order = (id: number) => (testDb.prepare('SELECT order_index FROM day_assignments WHERE id = ?').get(id) as { order_index: number }).order_index;
|
||||
expect(order(night.id)).toBeLessThan(order(afternoon.id));
|
||||
});
|
||||
|
||||
it('ASG-SVC-023: clearing with null persists but skips the auto-sort (falsy gate)', () => {
|
||||
const { day, place } = fixture();
|
||||
const a = createDayAssignment(testDb, day.id, place.id, { order_index: 0 });
|
||||
|
||||
Reference in New Issue
Block a user