feat(tours): read the walking time left of a city walk on a day over MCP, apart from its stays and the whole walk

This commit is contained in:
Maurice
2026-10-21 12:16:57 +02:00
parent 4eaf5e6a11
commit 43353b9394
12 changed files with 743 additions and 17 deletions
+70 -2
View File
@@ -1,6 +1,8 @@
import { Places } from '../../db/entities/Places.entity';
import { TourStationVisits } from '../../db/entities/TourStationVisits.entity';
import { TourWaypoints } from '../../db/entities/TourWaypoints.entity';
import { Tours } from '../../db/entities/Tours.entity';
import type { PlacesRepository } from '../../db/repositories/Places.repository';
import type {
TourStationVisitRow,
TourStationVisitsRepository,
@@ -8,15 +10,26 @@ import type {
import type { TourWaypointRow, TourWaypointsRepository } from '../../db/repositories/TourWaypoints.repository';
import type { ToursRepository } from '../../db/repositories/Tours.repository';
import { PlacesService } from '../places/places.service';
import { parseRouteGeometry } from './tours.helpers';
import { InjectRepository } from '@mikro-orm/nestjs';
import { Injectable, NotFoundException } from '@nestjs/common';
import { walkStationsOf, type TourVisit, type TourVisitListResponse, type TourVisitUpdateRequest } from '@trek/shared';
import {
isClosedLoop,
walkRemainderOf,
walkStationsOf,
type TourVisit,
type TourVisitListResponse,
type TourVisitUpdateRequest,
type WalkRemainder,
} from '@trek/shared';
/** A city walk on one of its days: the assignment, the walk and its stations in order. */
export interface WalkOnDay {
assignmentId: number;
dayId: number;
placeId: number;
/** The walk ends where it starts, so its line leads back to the start after the last station. */
loop: boolean;
stations: TourWaypointRow[];
visits: TourStationVisitRow[];
}
@@ -33,6 +46,7 @@ export class TourVisitsService {
@InjectRepository(TourStationVisits) private readonly visitsRepo: TourStationVisitsRepository,
@InjectRepository(Tours) private readonly toursRepo: ToursRepository,
@InjectRepository(TourWaypoints) private readonly waypointsRepo: TourWaypointsRepository,
@InjectRepository(Places) private readonly placesRepo: PlacesRepository,
private readonly places: PlacesService,
) {}
@@ -52,6 +66,7 @@ export class TourVisitsService {
assignmentId,
dayId: assignment.day_id,
placeId: assignment.place_id,
loop: isClosedLoop(points),
stations: walkStationsOf(points),
visits: await this.visitsRepo.listForAssignment(assignmentId),
};
@@ -59,6 +74,40 @@ export class TourVisitsService {
/** CW-09: a walk on one day, read for an assistant; nothing changes. */
async progress(tripId: number, placeId: number, dayId: number): Promise<WalkProgress> {
return (await this.dayRun(tripId, placeId, dayId)).progress;
}
/**
* CW-13: what is left of a walk on one day, read for an assistant: the
* reference it counts from, the walking time left along the saved line and
* the stays still open, apart. Read afresh each time, so a station checked
* off since counts; nothing changes.
*/
async remaining(tripId: number, placeId: number, dayId: number): Promise<WalkRemaining> {
const [{ walk, progress }, place] = await Promise.all([
this.dayRun(tripId, placeId, dayId),
this.placesRepo.findInTrip(placeId, tripId),
]);
const remainder = walkRemainderOf({
stations: progress.stations.map((station) => ({ ...station, stayMinutes: station.stay_minutes })),
line: parseRouteGeometry(place?.route_geometry),
walkingMinutes: progress.walking_minutes,
});
return {
place_id: placeId,
day_id: progress.day_id,
assignment_id: progress.assignment_id,
loop: walk.loop,
...remainder,
derived: REMAINDER_DERIVED,
};
}
private async dayRun(
tripId: number,
placeId: number,
dayId: number,
): Promise<{ walk: WalkOnDay; progress: WalkProgress }> {
const assignmentId = await this.visitsRepo.assignmentOnDay(tripId, placeId, dayId);
if (assignmentId === undefined) throw new NotFoundException('City walk not on this day');
const walk = await this.walkOnDay(tripId, assignmentId);
@@ -78,7 +127,7 @@ export class TourVisitsService {
linked_place_id: station.linked_place_id ?? null,
}));
const open = stations.filter((station) => station.status === 'planned');
return {
const progress: WalkProgress = {
place_id: placeId,
day_id: walk.dayId,
assignment_id: assignmentId,
@@ -90,6 +139,7 @@ export class TourVisitsService {
},
walking_minutes: tour?.duration ?? null,
};
return { walk, progress };
}
/** Marks a station of a walk on one of its days, or takes it back to planned. */
@@ -144,6 +194,24 @@ export interface WalkProgress {
walking_minutes: number | null;
}
/** The fields of a remaining time worked out on reading, never stored with the walk. */
const REMAINDER_DERIVED = [
'reference',
'finished',
'walking.remaining_minutes',
'walking.after_last_station_minutes',
'open_stations.walk_minutes_from_reference',
] as const;
/** CW-13: what is left of a walk on one day, for an assistant. */
export type WalkRemaining = {
place_id: number;
day_id: number;
assignment_id: number;
loop: boolean;
derived: readonly string[];
} & WalkRemainder;
/** A visit as the routes and the trip's socket send it. */
export function toVisit(row: TourStationVisitRow): TourVisit {
return { assignment_id: row.assignment_id, station_key: row.station_key, status: row.status };
+27 -1
View File
@@ -178,7 +178,7 @@ export class ToursMcp {
@Tool({
name: 'get_city_walk_progress',
description:
'Read how far a city walk (tour_type walk) got on one day it is on: every station in order with its key (its own id, as get_tour_plan gives it), its status that day (planned, visited or skipped, as the travellers checked them off in the day plan), its importance (normal, optional, must; get_tour_plan says null for normal), whether it is protected (a station a proposed change must leave where it is, neither removed, replaced nor moved), its stay in minutes (null when not known, 0 for a point passed through), its opening hours as OpenStreetMap writes them (null when none is known) and its linked place. "open" sums what is still planned: the stations, their known stays and how many stays are unknown; walking_minutes is the walking time of the whole walk. Visits belong to that day only: the same walk on another day, or a copy, has none. Anything the traveller tells you besides (for instance "continue from 2 pm") is theirs to say, not stored here. Reading changes nothing.',
'Read how far a city walk (tour_type walk) got on one day it is on: every station in order with its key (its own id, as get_tour_plan gives it), its status that day (planned, visited or skipped, as the travellers checked them off in the day plan), its importance (normal, optional, must; get_tour_plan says null for normal), whether it is protected (a station a proposed change must leave where it is, neither removed, replaced nor moved), its stay in minutes (null when not known, 0 for a point passed through), its opening hours as OpenStreetMap writes them (null when none is known) and its linked place. "open" sums what is still planned: the stations, their known stays and how many stays are unknown; walking_minutes is the walking time of the whole walk. Visits belong to that day only: the same walk on another day, or a copy, has none. Anything the traveller tells you besides (for instance "continue from 2 pm") is theirs to say, not stored here. For the walking time still ahead, read get_city_walk_remaining_time: walking_minutes here is the whole walk. Reading changes nothing.',
inputSchema: {
tripId: idSchema,
placeId: idSchema.describe('The place id of the city walk, as list_tours gives it'),
@@ -201,6 +201,32 @@ export class ToursMcp {
}
}
@Tool({
name: 'get_city_walk_remaining_time',
description:
'Read what is left of a city walk (tour_type walk) on one day it is on, from the stations the travellers checked off that day: the walking time still ahead, the stays still open and the stations still open, each apart. reference says what the estimate counts from: start (nothing visited yet), last_visited (the last station checked off as visited; its stay counts as done) or ambiguous (a station is still planned before the last one visited, so where the walk stands cannot be told: ask the travellers where they are rather than guessing). A status says what was done, never where anyone is now: live_position is always false, TREK knows no live position and no clock. walking.total_minutes is the walking time of the whole walk as saved; walking.remaining_minutes is the part of it still ahead of the reference, the saved walking time shared out by how far along the saved line each station is passed (never by how many stations are open), so stretches already walked are not in it; it holds no stay. walking.upper_bound is true when a station ahead was skipped (listed in skipped_ahead): the saved line still leads through it and the shorter way was never planned, so the time is at most that. walking.after_last_station_minutes is the part from the last station to the end of the line, for a loop (loop true) the way back to its start, still ahead even once every station is done. walking.remaining_minutes is null, with unknown_because, when it cannot be told: no_stations, route_pending (saved with its points only, no line yet), no_walking_time or progress_ambiguous; it is never given as 0 or as the whole walk instead. stays.remaining_known_minutes sums the stays of the open stations as far as entered, stays.unknown lists the open stations whose stay is not known (never counted as 0), stays.optional_known_minutes is the part of the known minutes at optional stations. open_stations lists the stations still planned in order, with importance, stay_minutes and walk_minutes_from_reference (walking time from the reference to it, null where the remaining time is not known); a skipped station is done and not in it. finished is true when no station is open. Visits belong to that day only: the same walk on another day, or a copy, starts from the beginning. A time the traveller tells you (for instance "continue from 2 pm") is theirs to add, not stored here. derived names the fields worked out on reading. Reading changes nothing: no status, tour or day plan.',
inputSchema: {
tripId: idSchema,
placeId: idSchema.describe('The place id of the city walk, as list_tours gives it'),
dayId: idSchema.describe('The day the walk is on, as find_tours_for_day gives it'),
},
annotations: TOOL_ANNOTATIONS_READONLY,
when: addonGate(ADDON_IDS.TOURS),
access: { group: 'trips', mode: 'read' },
})
async getCityWalkRemainingTime(
{ tripId, placeId, dayId }: { tripId: number; placeId: number; dayId: number },
ctx: McpContext,
) {
if (!(await this.access.findAccessible(tripId, ctx.userId))) return noAccess();
try {
return ok(await this.visits.remaining(tripId, placeId, dayId));
} catch (err: unknown) {
if (err instanceof NotFoundException) return errorResult('No city walk of this trip is on that day.');
throw err;
}
}
@Tool({
name: 'find_tours_for_day',
description: 'List the saved tours put on one day of a trip, with the same facts as list_tours.',
+51 -2
View File
@@ -1,8 +1,8 @@
/**
* Tours e2e for city walks (CW-01 to CW-03, CW-10, CW-11): a walk saved and read
* Tours e2e for city walks (CW-01 to CW-03, CW-10, CW-11, CW-13): a walk saved and read
* with its stations, one saved with its stations only waiting for its way, the
* keys of its stations kept through an edit, and the stations checked off on
* the days the walk is on, through the real
* the days the walk is on, and what is left of it read over MCP, through the real
* JwtAuthGuard, AddonGuard and TripAccessGuard against a migrated and seeded
* temp SQLite db. The permission check is a container spy and the broadcast
* goes to a FakeRealtimeService, as in tours.e2e.test.ts.
@@ -17,13 +17,17 @@ import { Places } from '../../src/db/entities/Places.entity';
import { TourStationVisits } from '../../src/db/entities/TourStationVisits.entity';
import { Tours } from '../../src/db/entities/Tours.entity';
import { Trips } from '../../src/db/entities/Trips.entity';
import { trekMcpAccessPolicy, trekMcpValidateAccess } from '../../src/mcp/nest-mcp-policy';
import { createTestRegistry, type McpContext } from '../../src/nest-mcp';
import { AssignmentsModule } from '../../src/nest/assignments/assignments.module';
import { TrekExceptionFilter } from '../../src/nest/common/trek-exception.filter';
import { ZodValidationPipe } from '../../src/nest/common/zod-validation.pipe';
import { withRequestContext } from '../../src/nest/database/request-context';
import { JourneyDomainService } from '../../src/nest/journey/journey-domain.service';
import { PermissionsService } from '../../src/nest/permissions/permissions.service';
import { RealtimeModule } from '../../src/nest/realtime/realtime.module';
import { RealtimeService } from '../../src/nest/realtime/realtime.service';
import { ToursMcp } from '../../src/nest/tours/tours.mcp';
import { ToursModule } from '../../src/nest/tours/tours.module';
import { createSnapshotTestDb } from '../helpers/db-mock';
import { makePlace } from '../helpers/factories/places';
@@ -36,6 +40,7 @@ import { FakeRealtimeService } from '../helpers/fake-realtime';
import { createTestMikroOrmModule, createTestOrm, type TestOrm } from '../helpers/test-orm';
import { TestUnitOfWorkModule } from '../helpers/test-uow';
import { sessionCookie } from './harness';
import { MikroORM } from '@mikro-orm/core';
import { Test } from '@nestjs/testing';
import { stationKeySchema } from '@trek/shared';
@@ -472,6 +477,50 @@ describe('City walks e2e (real guards + temp SQLite)', () => {
});
});
describe('remaining time over MCP (CW-13)', () => {
const remainingOf = (placeId: number, dayId: number) =>
withRequestContext(app.get(MikroORM), async () => {
const mcp = app.get(ToursMcp);
const result = await mcp.getCityWalkRemainingTime({ tripId: 5, placeId, dayId }, {
userId: VIEWER,
} as McpContext);
return JSON.parse(result.content[0]?.text ?? '{}');
});
it('is registered as a read of the trip', () => {
expect(() =>
createTestRegistry([app.get(ToursMcp)], {
accessPolicy: trekMcpAccessPolicy,
validateAccess: trekMcpValidateAccess,
}),
).not.toThrow();
});
it('counts from the stations checked off over REST, and the same walk on another day from its start', async () => {
const { placeId, assignmentId, cathedral, market } = await walkOnDay3();
await assign(placeId, 4);
expect((await mark(assignmentId, cathedral, { status: 'visited' })).status).toBe(200);
expect((await remainingOf(placeId, 3)).walking).toMatchObject({ total_minutes: 60, remaining_minutes: 60 });
expect((await mark(assignmentId, market, { status: 'visited' })).status).toBe(200);
const day3 = await remainingOf(placeId, 3);
expect(day3.reference).toMatchObject({ kind: 'last_visited', station: { key: market, name: 'Market' } });
expect(day3.walking).toMatchObject({ remaining_minutes: 40, upper_bound: false });
expect(day3.open_stations).toEqual([
expect.objectContaining({ name: 'Park', importance: 'optional', walk_minutes_from_reference: 40 }),
]);
expect(day3.stays).toMatchObject({
remaining_known_minutes: 0,
unknown: [expect.objectContaining({ name: 'Park' })],
});
const day4 = await remainingOf(placeId, 4);
expect(day4.reference).toEqual({ kind: 'start' });
expect(day4.walking.remaining_minutes).toBe(60);
expect(await countRows(orm, TourStationVisits)).toBe(2);
});
});
describe('refusals', () => {
it('404 for an assignment of another trip, a walk that is none, and a station the walk does not have', async () => {
const { placeId: hikeId } = await saveWalk(
@@ -4,13 +4,14 @@
* The service comes out of ToursModule over a snapshot test db; rows are
* seeded through the ORM factories and broadcasts go to a FakeRealtimeService.
*/
import { Places } from '../../../src/db/entities/Places.entity';
import { TourStationVisits } from '../../../src/db/entities/TourStationVisits.entity';
import { TourVisitsService, type WalkOnDay, type WalkProgress } from '../../../src/nest/tours/tour-visits.service';
import { ToursModule } from '../../../src/nest/tours/tours.module';
import { createSnapshotTestDb } from '../../helpers/db-mock';
import { makeDayAssignment } from '../../helpers/factories/itinerary';
import { makePlace } from '../../helpers/factories/places';
import { countRows } from '../../helpers/factories/rows';
import { countRows, updateRows } from '../../helpers/factories/rows';
import { addTourWaypoints, makeTour, markStationVisit } from '../../helpers/factories/tours';
import { makeDay, makeTrip } from '../../helpers/factories/trips';
import { makeUser } from '../../helpers/factories/users';
@@ -174,6 +175,7 @@ describe('TourVisitsService', () => {
assignmentId: onDay1.id,
dayId: day1.id,
placeId: walk.id,
loop: false,
stations: expect.any(Array),
visits: [{ assignment_id: onDay1.id, station_key: 'stop-market', status: 'skipped' }],
});
@@ -330,4 +332,66 @@ describe('TourVisitsService', () => {
new NotFoundException('City walk not on this day'),
);
});
it('TOUR-VISITS-008: remaining counts from the last visit along the saved line, a point without a key passed behind it', async () => {
const { trip, day1, walk, onDay1 } = await fixture();
// Straight north through the four stations, one stretch of 0.01 degrees between each.
const line = [
[48.1, 11.5],
[48.11, 11.51],
[48.12, 11.52],
[48.13, 11.53],
];
await updateRows(orm(), Places, { id: walk.id }, { route_geometry: JSON.stringify(line) });
await markStationVisit(orm(), onDay1.id, 'stop-cathedral', 'visited');
await markStationVisit(orm(), onDay1.id, 'stop-market', 'visited');
const before = await countRows(orm(), TourStationVisits, {});
const remaining = await visits.remaining(trip.id, walk.id, day1.id);
expect(remaining).toMatchObject({
place_id: walk.id,
day_id: day1.id,
assignment_id: onDay1.id,
loop: false,
reference: { kind: 'last_visited', station: { position: 2, key: 'stop-market', name: null } },
walking: { total_minutes: 95, remaining_minutes: 63, upper_bound: false, after_last_station_minutes: 0 },
stays: { remaining_known_minutes: 45, unknown: [{ position: 3, key: null, name: null }] },
});
expect(remaining.open_stations.map((station) => [station.position, station.walk_minutes_from_reference])).toEqual([
[3, 31],
[4, 63],
]);
expect(await countRows(orm(), TourStationVisits, {})).toBe(before);
expect(t.realtime.broadcastMock).not.toHaveBeenCalled();
});
it('TOUR-VISITS-009: a loop keeps its way back once every station is done, and a walk not on that day is a 404', async () => {
const { trip, day1, day3, walk } = await fixture();
const loop = await makePlace(orm(), trip.id, {
name: 'Round',
route_geometry: JSON.stringify([
[48.1, 11.5],
[48.11, 11.5],
[48.11, 11.51],
[48.1, 11.5],
]),
});
await makeTour(orm(), loop.id, { tourTypeRef: 'walk', duration: 60 });
await addTourWaypoints(orm(), loop.id, [
{ lat: 48.1, lng: 11.5, station_key: 'stop-start', stay_minutes: 0 },
{ lat: 48.11, lng: 11.51, station_key: 'stop-tower', stay_minutes: 15 },
{ lat: 48.1, lng: 11.5, station_key: 'stop-back' },
]);
const onDay1 = await makeDayAssignment(orm(), day1.id, loop.id);
await markStationVisit(orm(), onDay1.id, 'stop-start', 'visited');
await markStationVisit(orm(), onDay1.id, 'stop-tower', 'visited');
const remaining = await visits.remaining(trip.id, loop.id, day1.id);
expect(remaining).toMatchObject({ loop: true, finished: true, open_stations: [] });
expect(remaining.walking.after_last_station_minutes).toBeGreaterThan(0);
expect(remaining.walking.remaining_minutes).toBe(remaining.walking.after_last_station_minutes);
await expect(visits.remaining(trip.id, walk.id, day3.id)).rejects.toEqual(
new NotFoundException('City walk not on this day'),
);
});
});
+154
View File
@@ -796,4 +796,158 @@ describe('ToursMcp', () => {
'routed where the piste router planned it and free',
);
});
/** CW-13: the walk of walkFixture with a saved line through its three stops, the market halfway along. */
async function remainingFixture() {
const base = await walkFixture();
const orm = await createTestOrm(db);
const line = [
[48.1, 11.5],
[48.11, 11.51],
[48.12, 11.52],
];
await updateRows(orm, Places, { id: base.walk.id }, { route_geometry: JSON.stringify(line) });
await orm.close();
const remaining = async (userId: number, dayId = base.day1.id) =>
read(await mcp.getCityWalkRemainingTime({ tripId: base.trip.id, placeId: base.walk.id, dayId }, ctx(userId)));
return { ...base, remaining };
}
it('TOURS-MCP-028: get_city_walk_remaining_time counts from the last visit, with walking time, stays and the whole walk apart', async () => {
const { member, trip, day1, walk, onDay1, remaining } = await remainingFixture();
const first = await remaining(member.id);
expect(first).toMatchObject({
place_id: walk.id,
day_id: day1.id,
assignment_id: onDay1.id,
loop: false,
live_position: false,
finished: false,
reference: { kind: 'last_visited', station: { position: 1, key: 'stop-cathedral', name: 'Cathedral' } },
});
// The market ahead was skipped, but the saved line still leads through it.
expect(first.walking).toEqual({
total_minutes: 80,
remaining_minutes: 80,
unknown_because: null,
upper_bound: true,
skipped_ahead: [{ position: 2, key: 'stop-market', name: null }],
after_last_station_minutes: 0,
});
expect(first.stays).toEqual({
remaining_known_minutes: 0,
unknown: [{ position: 3, key: 'stop-park', name: null }],
optional_known_minutes: 0,
});
expect(first.open_stations).toEqual([
{
position: 3,
key: 'stop-park',
name: null,
importance: 'must',
stay_minutes: null,
walk_minutes_from_reference: 80,
},
]);
expect(first.derived).toEqual(expect.arrayContaining(['walking.remaining_minutes', 'reference']));
// Checked off since: read again, the stretch to the market is behind.
await t.get(TourVisitsService).update(String(trip.id), onDay1.id, 'stop-market', { status: 'visited' });
const again = await remaining(member.id);
expect(again.reference).toEqual({
kind: 'last_visited',
station: { position: 2, key: 'stop-market', name: null },
});
expect(again.walking).toMatchObject({ remaining_minutes: 40, upper_bound: false, skipped_ahead: [] });
expect(again.open_stations[0].walk_minutes_from_reference).toBe(40);
});
it("TOURS-MCP-029: the same walk on another day counts from its start, none of the first day's visits in it", async () => {
const { member, day2, walk, remaining } = await remainingFixture();
const orm = await createTestOrm(db);
const onDay2 = await makeDayAssignment(orm, day2.id, walk.id);
await orm.close();
const result = await remaining(member.id, day2.id);
expect(result).toMatchObject({ assignment_id: onDay2.id, reference: { kind: 'start' }, finished: false });
expect(result.walking).toMatchObject({ remaining_minutes: 80, upper_bound: false });
expect(result.open_stations.map((station: { key: string }) => station.key)).toEqual([
'stop-cathedral',
'stop-market',
'stop-park',
]);
expect(result.stays).toMatchObject({ remaining_known_minutes: 50 });
});
it('TOURS-MCP-030: without a line or with a station open before the last visit, the time stays unknown with its reason', async () => {
const { user, trip, walk, onDay1, remaining } = await remainingFixture();
const visits = t.get(TourVisitsService);
await visits.update(String(trip.id), onDay1.id, 'stop-cathedral', { status: 'planned' });
await visits.update(String(trip.id), onDay1.id, 'stop-market', { status: 'visited' });
const unclear = await remaining(user.id);
expect(unclear.reference).toEqual({
kind: 'ambiguous',
last_visited: { position: 2, key: 'stop-market', name: null },
open_before: [{ position: 1, key: 'stop-cathedral', name: 'Cathedral' }],
});
expect(unclear.walking).toMatchObject({
total_minutes: 80,
remaining_minutes: null,
unknown_because: 'progress_ambiguous',
});
const orm = await createTestOrm(db);
await updateRows(orm, Places, { id: walk.id }, { route_geometry: null });
await orm.close();
await visits.update(String(trip.id), onDay1.id, 'stop-cathedral', { status: 'visited' });
const pending = await remaining(user.id);
expect(pending.walking).toMatchObject({
total_minutes: 80,
remaining_minutes: null,
unknown_because: 'route_pending',
after_last_station_minutes: null,
});
expect(pending.open_stations[0].walk_minutes_from_reference).toBeNull();
});
it('TOURS-MCP-031: reading changes nothing, tells an outsider nothing and names no walk for a day without it', async () => {
const { user, outsider, trip, day2, walk, remaining } = await remainingFixture();
const orm = await createTestOrm(db);
const before = await countRows(orm, TourStationVisits, {});
const revision = (await findRow(orm, Tours, { place: walk.id }))?.revision;
await remaining(user.id);
expect(await countRows(orm, TourStationVisits, {})).toBe(before);
expect((await findRow(orm, Tours, { place: walk.id }))?.revision).toBe(revision);
await orm.close();
expect(await remaining(outsider.id)).toEqual({ error: 'Trip not found or access denied.' });
expect(await remaining(user.id, day2.id)).toEqual({ error: 'No city walk of this trip is on that day.' });
const failure = new Error('database gone');
const spy = vi.spyOn(t.get(TourVisitsService), 'remaining').mockRejectedValueOnce(failure);
try {
await expect(
mcp.getCityWalkRemainingTime({ tripId: trip.id, placeId: walk.id, dayId: day2.id }, ctx(user.id)),
).rejects.toBe(failure);
} finally {
spy.mockRestore();
}
});
it('TOURS-MCP-032: the remaining time names its reference, its bounds and that no live position is known', () => {
const entry = getEntry(ToursMcp as unknown as ClassRef, 'getCityWalkRemainingTime');
const description = entry?.kind === 'tool' ? (entry.options.description ?? '') : '';
for (const field of [
'reference',
'live_position',
'upper_bound',
'after_last_station_minutes',
'unknown_because',
'stays.unknown',
'never by how many stations are open',
'Reading changes nothing',
]) {
expect(description).toContain(field);
}
const progress = getEntry(ToursMcp as unknown as ClassRef, 'getCityWalkProgress');
expect(progress?.kind === 'tool' ? progress.options.description : '').toContain('get_city_walk_remaining_time');
});
});