mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 18:54:17 +00:00
fix(planner): show each leg's own seat on a flight with a stop
A flight with a stop saves a seat per leg, but every view read the booking's flat seat, which mirrors the first leg's. A seat booked only on the second leg showed nowhere, and one on the first leg showed on both. #2701 had fixed this for trains only. - getFlightLegs reads each leg's seat. The first leg falls back to the flat seat, as the booking form does, so older bookings keep theirs. - bookingSeats lists the seat of every leg that has one with its route. The detail views (the phone's transport sheet, the booking detail) show each leg's seat under its route ("Seat IST → JFK"), and a leg opened from its row shows its own. The cards and field grids (bookings list, the phone's Bookings and Transports tabs, the day plan's transport detail) hold every seat in one Seat cell, so a card cutting its grid short no longer drops the second leg's. - The day plan's flight leg rows carry their seat, and the PDF prints a flight's seat, direct or per leg. - The watch and the Wallet pass name every leg's seat of the booking. - A legs-only MCP update sets the flat seat, airline and flight number (train number and platform) again from the new first leg, so a seat taken off the first leg does not live on in the flat seat. A flat value the stored first leg never had stays. Closes #3158
This commit is contained in:
@@ -1712,3 +1712,63 @@ describe('Transport tools: the full type list', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// The flat seat mirrors the first leg's; the planner reads it as the first leg's
|
||||
// seat when that leg has none, so a legs-only update must not leave it stale.
|
||||
describe('update_transport: the flat keys of a legs-only update', () => {
|
||||
const create = async (h: McpHarness, tripId: number) =>
|
||||
parseToolResult(
|
||||
await h.client.callTool({
|
||||
name: 'create_transport',
|
||||
arguments: {
|
||||
tripId,
|
||||
type: 'flight',
|
||||
title: 'AMS to FCO',
|
||||
endpoints: stopoverEndpoints,
|
||||
legs: [
|
||||
{ from: 'AMS', to: 'CDG', airline: 'KLM', seat: '3A' },
|
||||
{ from: 'CDG', to: 'FCO', airline: 'Air France', seat: '14C' },
|
||||
],
|
||||
},
|
||||
}),
|
||||
) as any;
|
||||
const updateLegs = (h: McpHarness, tripId: number, reservationId: number, legs: object[]) =>
|
||||
h.client.callTool({ name: 'update_transport', arguments: { tripId, reservationId, legs } });
|
||||
|
||||
it("takes the first leg's seat away from the flat seat too, and follows a new one", async () => {
|
||||
const { user } = await makeUser(orm);
|
||||
const trip = await makeTrip(orm, user.id);
|
||||
await withHarness(user.id, async (h) => {
|
||||
const data = await create(h, trip.id);
|
||||
expect((await storedMetadata(data.reservation.id)).seat).toBe('3A');
|
||||
|
||||
await updateLegs(h, trip.id, data.reservation.id, [
|
||||
{ from: 'AMS', to: 'CDG', airline: 'KLM' },
|
||||
{ from: 'CDG', to: 'FCO', airline: 'Air France', seat: '14C' },
|
||||
]);
|
||||
const cleared = await storedMetadata(data.reservation.id);
|
||||
expect(cleared.seat).toBeUndefined();
|
||||
expect(cleared.airline).toBe('KLM');
|
||||
|
||||
await updateLegs(h, trip.id, data.reservation.id, [
|
||||
{ from: 'AMS', to: 'CDG', airline: 'Transavia', seat: '5C' },
|
||||
{ from: 'CDG', to: 'FCO', airline: 'Air France', seat: '14C' },
|
||||
]);
|
||||
const changed = await storedMetadata(data.reservation.id);
|
||||
expect([changed.seat, changed.airline]).toEqual(['5C', 'Transavia']);
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps a flat seat the first leg never had, as an older booking stores it', async () => {
|
||||
const { user } = await makeUser(orm);
|
||||
const trip = await makeTrip(orm, user.id);
|
||||
await withHarness(user.id, async (h) => {
|
||||
const data = await create(h, trip.id);
|
||||
const legs = [{ from: 'AMS', to: 'CDG' }, { from: 'CDG', to: 'FCO' }];
|
||||
await setMetadata(JSON.stringify({ seat: '22F', legs }), data.reservation.id);
|
||||
|
||||
await updateLegs(h, trip.id, data.reservation.id, legs);
|
||||
expect((await storedMetadata(data.reservation.id)).seat).toBe('22F');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -159,6 +159,61 @@ describe('wallet pass builder', () => {
|
||||
expect(request?.details?.[1]?.value).toBe('Lufthansa LH716');
|
||||
});
|
||||
|
||||
const ENDS = [
|
||||
{
|
||||
role: 'from',
|
||||
name: 'Milan',
|
||||
code: 'MXP',
|
||||
lat: 45.63,
|
||||
lng: 8.72,
|
||||
timezone: 'Europe/Rome',
|
||||
local_date: '2027-04-02',
|
||||
local_time: '11:00',
|
||||
},
|
||||
{
|
||||
role: 'to',
|
||||
name: 'New York',
|
||||
code: 'JFK',
|
||||
lat: 40.64,
|
||||
lng: -73.78,
|
||||
timezone: 'America/New_York',
|
||||
local_date: '2027-04-02',
|
||||
local_time: '20:40',
|
||||
},
|
||||
] as WalletPassSource['endpoints'];
|
||||
|
||||
it('WALLET-B-011: a flight with a stop shows the seat of each leg, also one booked only on the second', () => {
|
||||
const seat = (metadata: Record<string, unknown>) =>
|
||||
buildWalletPassRequest(
|
||||
source({ type: 'flight', reservation_time: '2027-04-02T11:00', metadata }, { endpoints: ENDS }),
|
||||
WORDS,
|
||||
)?.details?.find((d) => d.label === 'Seat')?.value;
|
||||
const legs = [
|
||||
{ from: 'MXP', to: 'IST' },
|
||||
{ from: 'IST', to: 'JFK', seat: '14C' },
|
||||
];
|
||||
expect(seat({ legs })).toBe('14C');
|
||||
expect(seat({ seat: '3A', legs: [{ from: 'MXP', to: 'IST', seat: '3A' }, legs[1]] })).toBe('3A / 14C');
|
||||
// An older booking keeps its flat seat on the first leg.
|
||||
expect(
|
||||
seat({
|
||||
seat: '3A',
|
||||
legs: [
|
||||
{ from: 'MXP', to: 'IST' },
|
||||
{ from: 'IST', to: 'JFK' },
|
||||
],
|
||||
}),
|
||||
).toBe('3A');
|
||||
expect(
|
||||
seat({
|
||||
legs: [
|
||||
{ from: 'MXP', to: 'IST' },
|
||||
{ from: 'IST', to: 'JFK' },
|
||||
],
|
||||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it('WALLET-B-007: a journey without both ends is a plain booking; a train shows its number and platform', () => {
|
||||
const half = buildWalletPassRequest(source({ type: 'train', metadata: {} }, { place: null, endpoints: [] }), WORDS);
|
||||
expect(half?.kind).toBe('other');
|
||||
|
||||
Reference in New Issue
Block a user