Merge remote-tracking branch 'origin/dev' into feat/orm

This commit is contained in:
jubnl
2026-09-20 21:45:48 +02:00
47 changed files with 1079 additions and 173 deletions
@@ -0,0 +1,223 @@
/**
* The step that seats every booked night where its check-in says.
*
* A night's stop used to go last on its check-in day unless a stop pinned to a later
* hour pulled it forward, and the backfill for older bookings appended it as well. The
* night leads its day now (AccommodationsService.positionForCheckIn), and this step
* brings the trips planned under the old rule along, drawn roads included.
*
* The rules live in reseat-booked-nights.ts and are tested there directly on a fully
* migrated database: the columns the step reads (assignment_time, accommodation_id)
* and the vias table come from migrations, so seeding before runMigrations is not an
* option, and rewinding schema_version would tie this file to the tail of the
* append-only array.
*/
import { describe, it, expect } from 'vitest';
import Database from 'better-sqlite3';
import { createTables } from '../../../src/db/schema';
import { runMigrations } from '../../../src/db/migrations';
import { reseatBookedNights } from '../../../src/db/reseat-booked-nights';
function freshDb() {
const db = new Database(':memory:');
db.exec('PRAGMA journal_mode = WAL');
db.exec('PRAGMA foreign_keys = ON');
createTables(db);
runMigrations(db);
db.prepare("INSERT INTO users (id, username, email, password_hash, role) VALUES (1, 'u', 'u@test.local', 'x', 'user')").run();
db.prepare("INSERT INTO trips (id, user_id, title) VALUES (1, 1, 'T')").run();
db.prepare("INSERT INTO days (id, trip_id, day_number, date) VALUES (1, 1, 1, '2026-10-02')").run();
return db;
}
let nextPlace = 1;
function place(db: Database.Database, name: string, time: string | null = null, located = true) {
const id = nextPlace++;
db.prepare('INSERT INTO places (id, trip_id, name, lat, lng, place_time) VALUES (?, 1, ?, ?, ?, ?)')
.run(id, name, located ? 50 + id / 100 : null, located ? 10 : null, time);
return id;
}
let nextStop = 1;
function stop(db: Database.Database, placeId: number, orderIndex: number, time: string | null = null, accommodationId: number | null = null) {
const id = nextStop++;
db.prepare('INSERT INTO day_assignments (id, day_id, place_id, order_index, assignment_time, accommodation_id) VALUES (?, 1, ?, ?, ?, ?)')
.run(id, placeId, orderIndex, time, accommodationId);
return id;
}
function night(db: Database.Database, placeId: number, checkIn: string | null) {
return Number(db.prepare('INSERT INTO day_accommodations (trip_id, place_id, start_day_id, end_day_id, check_in) VALUES (1, ?, 1, 1, ?)')
.run(placeId, checkIn).lastInsertRowid);
}
const order = (db: Database.Database) =>
(db.prepare('SELECT place_id FROM day_assignments WHERE day_id = 1 ORDER BY order_index').all() as { place_id: number }[]).map((r) => r.place_id);
const indexes = (db: Database.Database) =>
(db.prepare('SELECT order_index FROM day_assignments WHERE day_id = 1 ORDER BY order_index').all() as { order_index: number }[]).map((r) => r.order_index);
const vias = (db: Database.Database) =>
db.prepare('SELECT id, after_order_index, sequence FROM roadtrip_vias WHERE day_id = 1 ORDER BY after_order_index, sequence, id').all() as
{ id: number; after_order_index: number; sequence: number }[];
const via = (db: Database.Database, afterOrderIndex: number, sequence = 0) =>
Number(db.prepare('INSERT INTO roadtrip_vias (day_id, after_order_index, sequence, lat, lng) VALUES (1, ?, ?, 50, 10)').run(afterOrderIndex, sequence).lastInsertRowid);
describe('booked night reseat', () => {
it('RESEAT-001: a night appended behind stops without an hour leads the day', () => {
const db = freshDb();
const [fuel, farm, hotel] = [place(db, 'Aral'), place(db, 'Karls'), place(db, 'Rostock')];
stop(db, fuel, 0);
stop(db, farm, 1);
stop(db, hotel, 2, null, night(db, hotel, '10:00'));
expect(reseatBookedNights(db)).toBe(1);
expect(order(db)).toEqual([hotel, fuel, farm]);
expect(indexes(db)).toEqual([0, 1, 2]);
});
it('RESEAT-002: a night without a check-in leads the day too', () => {
const db = freshDb();
const [museum, hotel] = [place(db, 'Museum'), place(db, 'Adlon')];
stop(db, museum, 0);
stop(db, hotel, 1, null, night(db, hotel, null));
reseatBookedNights(db);
expect(order(db)).toEqual([hotel, museum]);
});
it('RESEAT-003: a stop with its own hour at or before the check-in stays ahead', () => {
const db = freshDb();
const [early, loose, late, hotel] = [place(db, 'Aral'), place(db, 'Hafen'), place(db, 'Museum'), place(db, 'Rostock')];
stop(db, early, 0, '08:00');
stop(db, loose, 1);
// The place's own hour counts as much as the visit's.
stop(db, late, 2, null);
db.prepare("UPDATE places SET place_time = '14:00' WHERE id = ?").run(late);
stop(db, hotel, 3, null, night(db, hotel, '10:00'));
reseatBookedNights(db);
expect(order(db)).toEqual([early, hotel, loose, late]);
});
it('RESEAT-004: a night already in its seat, and a stop the traveller placed, are left alone', () => {
const db = freshDb();
const [hotel, museum, own] = [place(db, 'Adlon'), place(db, 'Museum'), place(db, 'Campsite')];
stop(db, hotel, 0, null, night(db, hotel, '15:00'));
stop(db, museum, 1);
// Booked in road trip mode: the stop is the traveller's, the booking owns no row.
night(db, own, '18:00');
stop(db, own, 2);
expect(reseatBookedNights(db)).toBe(0);
expect(order(db)).toEqual([hotel, museum, own]);
});
it('RESEAT-005: the drawn roads follow the stops they were drawn after', () => {
const db = freshDb();
const [a, b, hotel] = [place(db, 'Harbour'), place(db, 'Mercure'), place(db, 'Rostock')];
stop(db, a, 0);
stop(db, b, 1);
stop(db, hotel, 2, null, night(db, hotel, '10:00'));
const afterA = via(db, 0);
const afterB = via(db, 1);
const afterHotel = via(db, 2);
reseatBookedNights(db);
// The rules the service applies when it moves a night: a via follows the stop
// it was drawn after, so A's road is on leg one now and the hotel's on leg
// zero; B is last now and has no leg to keep a via on, so its road goes.
expect(order(db)).toEqual([hotel, a, b]);
expect(vias(db)).toEqual([
{ id: afterHotel, after_order_index: 0, sequence: 0 },
{ id: afterA, after_order_index: 1, sequence: 0 },
]);
expect(vias(db).map((v) => v.id)).not.toContain(afterB);
});
it('RESEAT-006: a road behind the last stop stays with it, and the roads ahead follow their stops', () => {
// The hotel moves from the middle to the front. C is last before and after, so the
// drive into the next day stays behind it; the hotel's road follows the hotel to
// leg zero and A's follows A to leg one. Nothing merges in a pure reorder.
const db = freshDb();
const [a, hotel, c] = [place(db, 'Harbour'), place(db, 'Rostock'), place(db, 'Museum')];
stop(db, a, 0);
stop(db, hotel, 1, null, night(db, hotel, '10:00'));
stop(db, c, 2);
const afterHotel = via(db, 1);
const afterA = via(db, 0);
const intoTomorrow = via(db, 2);
reseatBookedNights(db);
expect(order(db)).toEqual([hotel, a, c]);
expect(vias(db)).toEqual([
{ id: afterHotel, after_order_index: 0, sequence: 0 },
{ id: afterA, after_order_index: 1, sequence: 0 },
{ id: intoTomorrow, after_order_index: 2, sequence: 0 },
]);
});
it('RESEAT-007: a stop without coordinates is not counted among the positions the roads are pinned to', () => {
const db = freshDb();
const [a, ghost, hotel] = [place(db, 'Harbour'), place(db, 'No map', null, false), place(db, 'Rostock')];
stop(db, a, 0);
stop(db, ghost, 1);
stop(db, hotel, 2, null, night(db, hotel, '10:00'));
const afterA = via(db, 0);
reseatBookedNights(db);
expect(order(db)).toEqual([hotel, a, ghost]);
// Located stops went [A, hotel] to [hotel, A]: A is last now, so its road has
// no leg left.
expect(vias(db).map((v) => v.id)).not.toContain(afterA);
});
it('RESEAT-010: two nights on one day settle by their check-ins', () => {
const db = freshDb();
const [later, earlier] = [place(db, 'Rue de Paris'), place(db, 'Brandenburger Tor')];
stop(db, later, 0, null, night(db, later, '12:00'));
stop(db, earlier, 1, null, night(db, earlier, '10:00'));
reseatBookedNights(db);
expect(order(db)).toEqual([earlier, later]);
expect(reseatBookedNights(db)).toBe(0);
});
it('RESEAT-008: runs again without moving anything', () => {
const db = freshDb();
const [fuel, hotel] = [place(db, 'Aral'), place(db, 'Rostock')];
stop(db, fuel, 0);
stop(db, hotel, 1, null, night(db, hotel, '10:00'));
reseatBookedNights(db);
const once = order(db);
expect(reseatBookedNights(db)).toBe(0);
expect(order(db)).toEqual(once);
});
it('RESEAT-009: the migration runs the step on a database being upgraded', () => {
// Seeded through the tables the base schema has, so the step fires on its normal
// pass: the backfill for older bookings appends the night last first, then the
// reseat brings it to the front.
const db = new Database(':memory:');
db.exec('PRAGMA journal_mode = WAL');
db.exec('PRAGMA foreign_keys = ON');
createTables(db);
db.prepare("INSERT INTO users (id, username, email, password_hash, role) VALUES (1, 'u', 'u@test.local', 'x', 'user')").run();
db.prepare("INSERT INTO trips (id, user_id, title) VALUES (1, 1, 'T')").run();
db.prepare("INSERT INTO days (id, trip_id, day_number, date) VALUES (1, 1, 1, '2026-10-02')").run();
db.prepare("INSERT INTO places (id, trip_id, name, lat, lng) VALUES (901, 1, 'Aral', 50.1, 10), (902, 1, 'Rostock', 50.2, 10)").run();
db.prepare('INSERT INTO day_assignments (day_id, place_id, order_index) VALUES (1, 901, 0)').run();
db.prepare("INSERT INTO day_accommodations (trip_id, place_id, start_day_id, end_day_id, check_in) VALUES (1, 902, 1, 1, '10:00')").run();
runMigrations(db);
expect(order(db)).toEqual([902, 901]);
});
});
@@ -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', () => {
@@ -692,6 +743,52 @@ describe('the day stop a booking implies', () => {
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([afternoon.id, hotel.id]);
});
it('ACC-022i a second night on the day counts by its check-in', () => {
const { user } = createUser(testDb);
const trip = createTrip(testDb, user.id);
const day = createDay(testDb, trip.id);
const [noon, morning] = ['Rue de Paris', 'Brandenburger Tor'].map(name => createPlace(testDb, trip.id, { name }));
svc.createAccommodation(trip.id, { place_id: noon.id, start_day_id: day.id, end_day_id: day.id, check_in: '12:00' });
svc.createAccommodation(trip.id, { place_id: morning.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([morning.id, noon.id]);
const evening = createPlace(testDb, trip.id, { name: 'Late' });
svc.createAccommodation(trip.id, { place_id: evening.id, start_day_id: day.id, end_day_id: day.id, check_in: '18:00' });
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([morning.id, noon.id, evening.id]);
});
it('ACC-022h an edit that leaves the check-in alone still corrects a night the clocks contradict', () => {
// Dragged behind a stop pinned to the afternoon, with a check-in at ten: a change of
// notes puts it back ahead of that stop, because a night sitting after an afternoon it
// was booked before is the plan reading back wrong. Dragged behind a stop without an
// hour, the same edit leaves it where the traveller put it.
const { user } = createUser(testDb);
const trip = createTrip(testDb, user.id);
const day = createDay(testDb, trip.id);
const [harbour, museum, hotel] = ['Hafen', 'Museum', 'Rostock'].map(name => createPlace(testDb, trip.id, { name }));
createDayAssignment(testDb, day.id, harbour.id);
const pinned = createDayAssignment(testDb, day.id, museum.id);
testDb.prepare("UPDATE day_assignments SET assignment_time = '14:00' WHERE id = ?").run(pinned.id);
const { accommodation } = svc.createAccommodation(trip.id, { place_id: hotel.id, start_day_id: day.id, end_day_id: day.id, check_in: '10:00' }) as any;
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([hotel.id, harbour.id, museum.id]);
const own = stopsOn(day.id).find(a => a.place_id === hotel.id)!;
// Behind the harbour only: allowed, and left alone.
testDb.prepare('UPDATE day_assignments SET order_index = 0 WHERE day_id = ? AND place_id = ?').run(day.id, harbour.id);
testDb.prepare('UPDATE day_assignments SET order_index = 1 WHERE id = ?').run(own.id);
let existing = svc.getAccommodation(accommodation.id, trip.id)!;
expect((svc.updateAccommodation(accommodation.id, existing, { notes: 'late' }) as any).mirror.moved).toBeNull();
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([harbour.id, hotel.id, museum.id]);
// Behind the afternoon: contradicted by the clocks, and seated afresh, which is
// the front, ahead of the harbour that has no hour of its own.
testDb.prepare('UPDATE day_assignments SET order_index = 1 WHERE day_id = ? AND place_id = ?').run(day.id, museum.id);
testDb.prepare('UPDATE day_assignments SET order_index = 2 WHERE id = ?').run(own.id);
existing = svc.getAccommodation(accommodation.id, trip.id)!;
expect((svc.updateAccommodation(accommodation.id, existing, { notes: 'later' }) as any).mirror.moved).not.toBeNull();
expect(stopsOn(day.id).map(a => a.place_id)).toEqual([hotel.id, harbour.id, museum.id]);
});
it('ACC-023 the place is typed as lodging, so the rail draws it as a service stop', () => {
const { user } = createUser(testDb);
const trip = createTrip(testDb, user.id);
@@ -887,7 +984,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 +1151,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 +1191,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 +1236,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 +1270,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;