Files
TREK/server/tests/helpers/place-activities-fixture.ts
T
Maurice 382ba79584 feat(places): visits read from trips, change history, linked tours and bookings, personal tags
A visit is a place planned on a day of one of the reader's trips; nothing is kept
or confirmed by hand. A place keeps a log of changes to its details, links the
tours and bookings it is about, and carries tags private to the reader, which a
copy into a trip takes along only when picked. Contracts, routes, MCP tools and
migrations for both engines.
2026-11-29 21:16:50 +01:00

53 lines
2.6 KiB
TypeScript

/**
* The bookings and tours the place activity suites (PLC-18) read, on top of
* the All places fixture (`seedLibrary`): in Alps, a guided tour booking on
* no place and a dinner booked against Café Central's plan entry; a lake
* cabin booking against the stay at Camp Lake; the tour Ridge walk with a
* station standing for Museum, and a second tour, Old town walk, on no place.
* Food keeps two tours. Hotel Sonne's own booking names the place already.
*/
import { DayAccommodations } from '../../src/db/entities/DayAccommodations.entity';
import { DayAssignments } from '../../src/db/entities/DayAssignments.entity';
import type { FactoryOrm } from './factories/context';
import { makeKeptTour } from './factories/place-activities';
import { makePlace } from './factories/places';
import { makeReservation } from './factories/reservations';
import { findRow } from './factories/rows';
import { addTourWaypoints, makeTour } from './factories/tours';
import { seedLibrary } from './places-library-fixture';
export async function seedPlaceActivities(orm: FactoryOrm) {
const f = await seedLibrary(orm);
const { alps, places, lists, day1 } = f;
const guided = await makeReservation(orm, alps.id, {
title: 'Guided tour',
type: 'tour',
status: 'confirmed',
reservation_time: '2026-07-01T10:00',
day: day1.id,
});
const plan = await findRow(orm, DayAssignments, { place: places.cafe.id });
if (!plan) throw new Error('seedPlaceActivities: Café Central has no plan entry');
const dinner = await makeReservation(orm, alps.id, { title: 'Dinner', type: 'restaurant', assignment: plan.id });
const stay = await findRow(orm, DayAccommodations, { place: places.camp.id });
if (!stay) throw new Error('seedPlaceActivities: Camp Lake has no stay');
const cabin = await makeReservation(orm, alps.id, {
title: 'Lake cabin',
type: 'hotel',
accommodation_id: `${stay.id}.0`,
});
await addTourWaypoints(orm, places.ridge.id, [
{ lat: 47.26, lng: 11.39 },
{ lat: 47.2681, lng: 11.3933, linkedPlace: places.museum.id },
{ lat: 47.27, lng: 11.4 },
]);
const walk = await makePlace(orm, alps.id, { name: 'Old town walk' });
await makeTour(orm, walk.id, { tourTypeRef: 'walk' });
const keptRidge = await makeKeptTour(orm, lists.food.id, { name: 'Kept ridge' });
const keptLake = await makeKeptTour(orm, lists.food.id, { name: 'Kept lake loop' });
const keptRome = await makeKeptTour(orm, lists.sights.id, { name: 'Rome by night' });
return { ...f, bookings: { guided, dinner, cabin }, tours: { walk }, kept: { keptRidge, keptLake, keptRome } };
}
export type PlaceActivitiesFixture = Awaited<ReturnType<typeof seedPlaceActivities>>;