mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-14 00:01:03 +00:00
fix(booking-import): read the seat that KItinerary gives
KItinerary writes a flight seat as airplaneSeat and a ticket seat as reservedTicket.ticketedSeat.seatNumber, the schema.org fields, and it removes seat and seatNumber from a script result. segmentDetail read only seat and seatNumber, so an imported booking lost its seat. segmentDetail now also reads airplaneSeat, and then the ticket seat when no other key has a value. seat and seatNumber stay first, so a booking that already has a seat gets the same result.
This commit is contained in:
@@ -709,7 +709,12 @@ function segmentDetail(r: KiReservation): {
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
const seat = pick('seat', 'seatNumber');
|
||||
// KItinerary writes a flight seat as airplaneSeat and a rail seat as
|
||||
// reservedTicket.ticketedSeat.seatNumber, and drops any other seat key.
|
||||
const ticket = r.reservedTicket as { ticketedSeat?: { seatNumber?: unknown } } | undefined;
|
||||
const ticketSeat = ticket?.ticketedSeat?.seatNumber;
|
||||
const seat =
|
||||
pick('seat', 'seatNumber', 'airplaneSeat') ?? (ticketSeat != null && ticketSeat !== '' ? ticketSeat : undefined);
|
||||
const cls = pick('class', 'bookingClass', 'fareClass', 'serviceClass', 'seatingType');
|
||||
const platform = pick('platform', 'departurePlatform');
|
||||
const price = pick('price', 'priceAmount', 'totalPrice', 'total');
|
||||
|
||||
@@ -634,3 +634,23 @@ describe('kitinerary mapper: a prompt-shaped AI lodging (#2477)', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('kitinerary mapper: the seat as KItinerary writes it', () => {
|
||||
it('reads a flight seat from airplaneSeat', () => {
|
||||
const node = {
|
||||
...flight('CE9P8V', SFO, JFK, '2026-06-11T10:00:00', '2026-06-11T18:30:00', '450'),
|
||||
airplaneSeat: '4D',
|
||||
};
|
||||
const { items } = mapReservations(legs(node), 'test.json');
|
||||
expect(items[0].metadata).toMatchObject({ seat: '4D' });
|
||||
});
|
||||
|
||||
it('reads a seat from reservedTicket.ticketedSeat.seatNumber', () => {
|
||||
const node = {
|
||||
...flight('CE9P8V', SFO, JFK, '2026-06-11T10:00:00', '2026-06-11T18:30:00', '450'),
|
||||
reservedTicket: { ticketedSeat: { seatNumber: '23A' } },
|
||||
};
|
||||
const { items } = mapReservations(legs(node), 'test.json');
|
||||
expect(items[0].metadata).toMatchObject({ seat: '23A' });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user