mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
fix(roadtrip): keep the stay on each visit, not on the place (#3092)
A nullable day_assignments.stay_minutes holds the stay of one visit; a visit without one keeps reading the place's duration, so existing trips drive as before. REST PUT /trips/:tripId/assignments/:id/stay and the MCP tool set_assignment_stay write it with day_edit.
This commit is contained in:
@@ -110,7 +110,31 @@ describe('Tool: assign_place_to_day', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('MDT-MCP-001: puts one stage of a multi-day tour on a day, refusing as REST does', async () => {
|
||||
it('set_assignment_stay: changes the stay of one visit and leaves the other visit of the place alone (#3092)', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const day = createDay(testDb, trip.id);
|
||||
const place = createPlace(testDb, trip.id);
|
||||
const first = createDayAssignment(testDb, day.id, place.id);
|
||||
const second = createDayAssignment(testDb, day.id, place.id);
|
||||
await withHarness(user.id, async (h) => {
|
||||
const changed = await h.client.callTool({
|
||||
name: 'set_assignment_stay',
|
||||
arguments: { tripId: trip.id, assignmentId: second.id, stay_minutes: 5 },
|
||||
});
|
||||
expect(parseToolResult(changed)).toMatchObject({ assignment: { id: second.id, stay_minutes: 5 } });
|
||||
const other = createTrip(testDb, user.id);
|
||||
const refused = await h.client.callTool({
|
||||
name: 'set_assignment_stay',
|
||||
arguments: { tripId: other.id, assignmentId: second.id, stay_minutes: 5 },
|
||||
});
|
||||
expect(refused.isError).toBe(true);
|
||||
});
|
||||
const rows = await findRows(orm, DayAssignments, { id: { $in: [first.id, second.id] } }, { id: 'asc' });
|
||||
expect(rows.map((r) => r.stay_minutes)).toEqual([null, 5]);
|
||||
});
|
||||
|
||||
it('MDT-MCP-001:puts one stage of a multi-day tour on a day, refusing as REST does', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const day = createDay(testDb, trip.id);
|
||||
|
||||
Reference in New Issue
Block a user