mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-30 18:46:00 +00:00
fix(airtrail): import the airline name, not the ICAO code (#1334)
AirTrail returns each airline as {icao, iata, name}, but the import reduced it to the ICAO/IATA code, so an imported flight showed e.g. 'EWG' instead of 'Eurowings'. The picker and the stored reservation now use the airline name (falling back to the code when AirTrail has none). The raw code is kept in metadata.airline_code so the writeback to AirTrail still sends a code, not a name (#1240), and the change-detection snapshot hash stays on the code so existing flights don't spuriously re-sync.
This commit is contained in:
@@ -47,7 +47,7 @@ describe('airtrailMapper.normalizeFlight', () => {
|
||||
fromCode: 'JFK',
|
||||
toCode: 'LHR',
|
||||
date: '2021-09-01',
|
||||
airline: 'BAW',
|
||||
airline: 'British Airways',
|
||||
flightNumber: 'BA178',
|
||||
seatClass: 'economy',
|
||||
});
|
||||
@@ -98,12 +98,19 @@ describe('airtrailMapper.mapFlightToReservation', () => {
|
||||
|
||||
it('carries flight metadata', () => {
|
||||
const m = mapFlightToReservation(flight());
|
||||
expect(m.metadata).toMatchObject({ airline: 'BAW', flight_number: 'BA178', aircraft: 'B772', aircraft_reg: 'G-VIIL', flight_reason: 'leisure', seat: '12A' });
|
||||
// #1334: display the airline name, keep the code in airline_code for the writeback.
|
||||
expect(m.metadata).toMatchObject({ airline: 'British Airways', airline_code: 'BAW', flight_number: 'BA178', aircraft: 'B772', aircraft_reg: 'G-VIIL', flight_reason: 'leisure', seat: '12A' });
|
||||
expect(m.type).toBe('flight');
|
||||
expect(m.status).toBe('confirmed');
|
||||
expect(m.notes).toBe('window seat');
|
||||
});
|
||||
|
||||
it('#1334 falls back to the airline code when AirTrail provides no name', () => {
|
||||
const a = { id: 9, icao: 'EWG', iata: 'EW' };
|
||||
expect(normalizeFlight(flight({ airline: a })).airline).toBe('EWG');
|
||||
expect(mapFlightToReservation(flight({ airline: a })).metadata).toMatchObject({ airline: 'EWG', airline_code: 'EWG' });
|
||||
});
|
||||
|
||||
it('uses only the seat number for the seat, not the cabin class (#1246)', () => {
|
||||
// AirTrail often has a class but no seat number until check-in; the class
|
||||
// must not leak into the seat field.
|
||||
|
||||
Reference in New Issue
Block a user