mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
fix(roadtrip): match cross-day returns to their rental
Keep located waypoints when the return desk is missing and assign them unique IDs. Join separate days only for the same hire car in both the planner and server. Keep the existing public terminal roles.
This commit is contained in:
@@ -454,6 +454,49 @@ describe('a booking the traveller rides (#2428)', () => {
|
||||
expect(card.distance).toBe(240_000);
|
||||
expect(calculated.totalStops).toBe(3);
|
||||
});
|
||||
|
||||
it('routes a hire car through its waypoint and across days to its own return desk', async () => {
|
||||
const { user, trip, plans, visits } = await setup();
|
||||
const start = await dayOf(visits[0].id);
|
||||
const end = createDay(db, trip.id);
|
||||
const destination = createPlace(db, trip.id, { name: 'Destination', lat: 52.51, lng: 13.41 });
|
||||
const destinationVisit = createDayAssignment(db, end.id, destination.id);
|
||||
await setVisit(destinationVisit.id, { assignment_time: '01:00' });
|
||||
const car = await addReservation({
|
||||
trip: trip.id,
|
||||
type: 'car',
|
||||
title: 'Hire car',
|
||||
day: start.day_id,
|
||||
endDay: end.id,
|
||||
reservation_time: '08:00',
|
||||
reservation_end_time: '02:00',
|
||||
});
|
||||
await addEndpoint(car, 'from', 0, 'Pick-up', null, 53.55, 10.0);
|
||||
await addEndpoint(car, 'stop', 1, 'On the way', null, 53.43, 10.4);
|
||||
await addEndpoint(car, 'to', 2, 'Return', null, 52.52, 13.41);
|
||||
|
||||
const { calculated } = await plans.calculate(trip.id, user.id);
|
||||
|
||||
expect(calculated.days[0].stops.map((stop) => stop.name)).toEqual([
|
||||
'Pick-up',
|
||||
'On the way',
|
||||
'Hamburg',
|
||||
'Lueneburg',
|
||||
'Celle',
|
||||
]);
|
||||
expect(calculated.days[1].stops.map((stop) => stop.name)).toEqual(['Destination', 'Return']);
|
||||
expect(calculated.days[1].arrivingFrom).toMatchObject({ name: 'Celle' });
|
||||
expect(calculated.days[1].arrivingLeg?.distance).toBe(60_000);
|
||||
|
||||
const tool = new RoadtripPlanningMcp(plans, {} as never, {} as never);
|
||||
const answer = await tool.calculate({ tripId: trip.id, includeGeometry: true }, { userId: user.id } as McpContext);
|
||||
const body = JSON.parse(answer.content[0].text);
|
||||
expect(body.days[0].stops[0].carrier.role).toBe('pickup');
|
||||
expect(body.days[0].stops[1]).toMatchObject({ name: 'On the way', lat: 53.43, lng: 10.4 });
|
||||
expect(body.days[0].stops[1]).not.toHaveProperty('carrier');
|
||||
expect(body.days[1].stops[1].carrier.role).toBe('return');
|
||||
expect(body.days[1].distanceMetres).toBe(120_000);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user