mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-12 23:31:02 +00:00
fix(booking-import): every leg of a connecting flight keeps its own seat
The grouped flight wrote a seat only on the booking itself, from the first segment. Each leg in metadata.legs now carries the seat of its own segment, which the planner and the PDF already show per leg.
This commit is contained in:
@@ -304,11 +304,13 @@ function mapFlightGroup(legs: KiReservation[], source: ParsedBookingItem['source
|
||||
const arrEp = makeEndpoint(f.arrivalAirport, isLast ? 'to' : 'stop', onward.time, onward.date);
|
||||
if (arrEp) endpoints.push(arrEp);
|
||||
const airline = f.airline?.name ?? f.airline?.iataCode ?? '';
|
||||
const { seat } = segmentDetail(legs[i]);
|
||||
metaLegs.push({
|
||||
from: iataOf(f.departureAirport),
|
||||
to: iataOf(f.arrivalAirport),
|
||||
...(airline ? { airline } : {}),
|
||||
...(f.flightNumber ? { flight_number: f.flightNumber } : {}),
|
||||
...(seat != null ? { seat } : {}),
|
||||
dep_time: splitIso(f.departureTime).time,
|
||||
arr_time: arr.time,
|
||||
});
|
||||
|
||||
@@ -654,3 +654,30 @@ describe('kitinerary mapper: the seat as KItinerary writes it', () => {
|
||||
expect(items[0].metadata).toMatchObject({ seat: '23A' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('kitinerary mapper: the seat on each leg of a connecting flight', () => {
|
||||
it('keeps every leg its own seat', () => {
|
||||
const { items } = mapReservations(
|
||||
legs(
|
||||
{ ...flight('ABC123', FRA, BER, '2026-06-11T10:00:00', '2026-06-11T12:00:00', 'LH 100'), airplaneSeat: '12C' },
|
||||
{ ...flight('ABC123', BER, HND, '2026-06-11T14:30:00', '2026-06-11T23:30:00', 'LH 200'), airplaneSeat: '40A' },
|
||||
),
|
||||
'test.json',
|
||||
);
|
||||
const legsMeta = (items[0].metadata as { legs: { seat?: string }[] }).legs;
|
||||
expect(legsMeta.map((leg) => leg.seat)).toEqual(['12C', '40A']);
|
||||
});
|
||||
|
||||
it('leaves the seat off a leg that has none', () => {
|
||||
const { items } = mapReservations(
|
||||
legs(flight('ABC123', FRA, BER, '2026-06-11T10:00:00', '2026-06-11T12:00:00', 'LH 100'), {
|
||||
...flight('ABC123', BER, HND, '2026-06-11T14:30:00', '2026-06-11T23:30:00', 'LH 200'),
|
||||
airplaneSeat: '40A',
|
||||
}),
|
||||
'test.json',
|
||||
);
|
||||
const legsMeta = (items[0].metadata as { legs: Record<string, unknown>[] }).legs;
|
||||
expect(legsMeta[0]).not.toHaveProperty('seat');
|
||||
expect(legsMeta[1]).toMatchObject({ seat: '40A' });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user