mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 19:40:34 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 49b9ffc77d | |||
| 7006891ce0 | |||
| 4d01439c75 | |||
| adb6a2c80d |
@@ -259,6 +259,25 @@ describe('downloadTripPDF', () => {
|
||||
expect(iframe!.srcdoc).toContain('Air Italia · AI123 · CDG → FCO')
|
||||
})
|
||||
|
||||
it('FE-COMP-TRIPPDF-013s: a flight prints its seat, a direct one and each leg of one with a stop alike', async () => {
|
||||
const direct = { ...transportReservation, metadata: JSON.stringify({ airline: 'Air Italia', flight_number: 'AI123', seat: '31A', departure_airport: 'CDG', arrival_airport: 'FCO' }) }
|
||||
const stopover = {
|
||||
...multiLegFlight,
|
||||
metadata: JSON.stringify({
|
||||
legs: [
|
||||
{ from: 'FRA', to: 'BER', airline: 'Lufthansa', flight_number: 'LH1' },
|
||||
{ from: 'BER', to: 'HND', airline: 'Lufthansa', flight_number: 'LH2', seat: '14C' },
|
||||
],
|
||||
departure_airport: 'FRA', arrival_airport: 'HND', airline: 'Lufthansa', flight_number: 'LH1',
|
||||
}),
|
||||
}
|
||||
await downloadTripPDF({ ...richArgs, reservations: [direct, stopover] })
|
||||
const html = getIframe()?.srcdoc ?? ''
|
||||
expect(html).toContain('Air Italia · AI123 · reservations.meta.seat 31A · CDG → FCO')
|
||||
expect(html).toContain('Lufthansa · LH2 · reservations.meta.seat 14C · BER → HND')
|
||||
expect(html).not.toContain('LH1 · reservations.meta.seat')
|
||||
})
|
||||
|
||||
it('FE-COMP-TRIPPDF-013f: the stop a booked night wrote is not listed, so a morning flight prints before the hotel (#2434)', async () => {
|
||||
// The desktop toolbar hands the export the store's assignments, hidden stop and
|
||||
// all, and that stop heads its check-in day. The day plan hides it and shows the
|
||||
|
||||
@@ -417,7 +417,7 @@ export async function downloadTripPDF({ trip, days, places, assignments: allStor
|
||||
// flat metadata pair for legacy single-leg flights without endpoints.
|
||||
const stops = (r.endpoints || []).slice().sort((a, b) => (a.sequence ?? 0) - (b.sequence ?? 0)).map(e => e.code || e.name)
|
||||
const route = stops.length >= 2 ? stops.join(' → ') : (meta.departure_airport && meta.arrival_airport ? `${meta.departure_airport} → ${meta.arrival_airport}` : '')
|
||||
subtitle = [meta.airline, meta.flight_number, route].filter(Boolean).join(' · ')
|
||||
subtitle = [meta.airline, meta.flight_number, meta.seat ? `${tr('reservations.meta.seat')} ${meta.seat}` : '', route].filter(Boolean).join(' · ')
|
||||
}
|
||||
}
|
||||
else if (r.type === 'train') {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { BlurredCode } from '../shared/BookingCode'
|
||||
import { DialogButton, DialogFooter, DialogSection, DialogShell, FooterSpacer, PILL } from '../shared/DialogShell'
|
||||
import { useTripStore } from '../../store/tripStore'
|
||||
import { formatTime, splitReservationDateTime } from '../../utils/formatters'
|
||||
import { parseReservationMetadata } from '../../utils/flightLegs'
|
||||
import { parseReservationMetadata, seatCells } from '../../utils/flightLegs'
|
||||
import { BookingDialogHeader } from './bookings/BookingDialogShell'
|
||||
import { BOX, Eyebrow, Field, fs, toneColor, toneOf } from './bookings/bookingParts'
|
||||
import { filesFor } from '../../utils/reservationFiles'
|
||||
@@ -175,11 +175,13 @@ function detailCells(res: Reservation, meta: Record<string, unknown>, t: Transla
|
||||
add(t('reservations.meta.flightNumber'), meta.flight_number)
|
||||
add(t('reservations.meta.from'), meta.departure_airport)
|
||||
add(t('reservations.meta.to'), meta.arrival_airport)
|
||||
add(t('reservations.meta.seat'), meta.seat)
|
||||
} else if (res.type === 'train') {
|
||||
add(t('reservations.meta.trainNumber'), meta.train_number)
|
||||
add(t('reservations.meta.platform'), meta.platform)
|
||||
add(t('reservations.meta.seat'), meta.seat)
|
||||
}
|
||||
// Each leg's seat under its route on a booking with a stop, not just the first leg's.
|
||||
if (res.type === 'flight' || res.type === 'train') {
|
||||
for (const c of seatCells(res, t('reservations.meta.seat'))) add(c.label, c.value)
|
||||
}
|
||||
add(t('reservations.confirmationCode'), res.confirmation_number, true)
|
||||
// A stopover booking can carry its own reference per segment (#1943); the
|
||||
|
||||
@@ -118,6 +118,19 @@ describe('BookingDetailDialog', () => {
|
||||
expect(screen.getByText('#SEG2')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-PLANNER-BKDETAIL-015: a flight with a stop shows the seat booked on its second leg, once, under that leg', () => {
|
||||
const r = buildReservation({
|
||||
title: 'MXP to JFK', type: 'flight',
|
||||
metadata: JSON.stringify({ class: 'Economy', legs: [{ from: 'MXP', to: 'IST' }, { from: 'IST', to: 'JFK', seat: '14C' }] }),
|
||||
});
|
||||
renderDetail(r);
|
||||
const dialog = screen.getByRole('dialog', { name: 'MXP to JFK' });
|
||||
expect(within(dialog).getByText('14C')).toBeInTheDocument();
|
||||
expect(within(dialog).getByText('Seat IST → JFK')).toBeInTheDocument();
|
||||
// The tile stands for it; the field grid does not repeat it.
|
||||
expect(within(dialog).queryByText('14C, Economy')).toBeNull();
|
||||
});
|
||||
|
||||
it('FE-PLANNER-BKDETAIL-006: place, accommodation, linked stop, link, travelers and notes', () => {
|
||||
const place = buildPlace({ name: 'Kinkaku-ji', place_time: '10:00' });
|
||||
const a = buildAssignment({ id: 4401, day_id: 1302, place });
|
||||
|
||||
@@ -27,7 +27,7 @@ import { BookingDialogHeader, StatusPill, TypePill } from './BookingDialogShell'
|
||||
import { DeleteButton, DialogButton, DialogFooter, DialogSection as Section, DialogShell, FooterSpacer, PILL } from '../../shared/DialogShell'
|
||||
import FlightLiveCard from '../flightLive/FlightLiveCard'
|
||||
import { useFlightLiveCardLegs } from '../flightLive/useFlightLiveCard'
|
||||
import { getFlightLegs } from '../../../utils/flightLegs'
|
||||
import { bookingSeats, getFlightLegs, seatLabel } from '../../../utils/flightLegs'
|
||||
|
||||
export interface BookingDetailDialogProps {
|
||||
r: Reservation
|
||||
@@ -84,6 +84,7 @@ export default function BookingDetailDialog(p: BookingDetailDialogProps) {
|
||||
const subParts = [meta.airline, meta.flight_number, meta.train_number, facts.endpoints.length >= 2 ? facts.endpoints.map(e => e.code || e.name).join(' → ') : null].filter(Boolean)
|
||||
const sub = subParts.length ? subParts.join(' ') : null
|
||||
|
||||
const seats = bookingSeats(r)
|
||||
const stats: { value: string; label: string }[] = []
|
||||
if (facts.isHotel) {
|
||||
stats.push(...stayStats(facts, meta, t, locale))
|
||||
@@ -100,7 +101,8 @@ export default function BookingDetailDialog(p: BookingDetailDialogProps) {
|
||||
// Under a minute of walking is not worth a tile.
|
||||
if (transit && transit.walk > 59) stats.push({ value: t('transit.min', { count: Math.round(transit.walk / 60) }), label: t('transit.walkLabel') })
|
||||
if (meta.platform) stats.push({ value: meta.platform, label: t('reservations.meta.platform') })
|
||||
if (meta.seat) stats.push({ value: meta.seat, label: t('reservations.meta.seat') })
|
||||
// Each leg's seat under its route on a booking with a stop, not just the first leg's.
|
||||
for (const s of seats) stats.push({ value: s.seat, label: seatLabel(t('reservations.meta.seat'), s.route) })
|
||||
}
|
||||
// Cells already shown as a stat stay out of the field grid below.
|
||||
const shownAsStat = new Set([t('reservations.meta.platform'), t('reservations.meta.seat'), t('reservations.meta.checkIn'), t('reservations.meta.checkOut')])
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { Reservation } from '../../../types'
|
||||
import { useTranslation } from '../../../i18n'
|
||||
import { BlurredCode } from '../../shared/BookingCode'
|
||||
import { formatMoney } from '../../../utils/formatters'
|
||||
import { bookingSeats } from '../../../utils/flightLegs'
|
||||
import { TransitLegChips } from '../transitDisplay'
|
||||
import { displayTitle, parseMeta, type BookingGroup, type CostTotal } from './bookingsModel'
|
||||
import type { BookingFacts } from './bookingFacts'
|
||||
@@ -82,7 +83,7 @@ function Row({ r, p, facts, files, costs, t, locale }: {
|
||||
const sub = facts.endpoints.length >= 2
|
||||
? facts.endpoints.map(e => e.code || e.name).join(' → ')
|
||||
: facts.accommodation || facts.place || ''
|
||||
const extras: string[] = [meta.airline && meta.flight_number ? `${meta.airline} ${meta.flight_number}` : meta.flight_number || meta.airline, meta.train_number, meta.seat, meta.platform].filter(Boolean)
|
||||
const extras: string[] = [meta.airline && meta.flight_number ? `${meta.airline} ${meta.flight_number}` : meta.flight_number || meta.airline, meta.train_number, ...bookingSeats(r).map(s => s.seat), meta.platform].filter(Boolean)
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -231,3 +231,14 @@ describe('bookingFacts: codes, links and places', () => {
|
||||
expect(bookingFacts(buildReservation({ url: 'javascript:alert(1)' }), ctx()).url?.href).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('bookingFacts: seats of a flight with a stop', () => {
|
||||
it('FE-PLANNER-BKFACTS-025: the Seat cell holds the seat booked only on the second leg', () => {
|
||||
const r = buildReservation({
|
||||
type: 'flight',
|
||||
metadata: JSON.stringify({ class: 'Economy', legs: [{ from: 'MXP', to: 'IST' }, { from: 'IST', to: 'JFK', seat: '14C' }] }),
|
||||
});
|
||||
const facts = bookingFacts(r, ctx());
|
||||
expect(cell(facts, 'reservations.meta.seat')).toBe('14C, Economy');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Day, Reservation, ReservationEndpoint } from '../../../types'
|
||||
import { formatPriceText, formatTime, splitReservationDateTime } from '../../../utils/formatters'
|
||||
import { getFlightLegs, getTrainLegs, usesStationRoute } from '../../../utils/flightLegs'
|
||||
import { getFlightLegs, getTrainLegs, seatCells, usesStationRoute } from '../../../utils/flightLegs'
|
||||
import { safeExternalHref } from '../../../utils/safeUrl'
|
||||
import { bookingDates, daySpan, hotelStayTimes, parseMeta, type AssignmentLookupEntry } from './bookingsModel'
|
||||
|
||||
@@ -102,7 +102,8 @@ export function bookingFacts(r: Reservation, c: FactsContext): BookingFacts {
|
||||
if (!hasEndpoints && meta.arrival_airport) cells.push({ label: t('reservations.meta.to'), value: meta.arrival_airport })
|
||||
if (meta.train_number) cells.push({ label: t('reservations.meta.trainNumber'), value: meta.train_number })
|
||||
if (meta.platform) cells.push({ label: t('reservations.meta.platform'), value: meta.platform })
|
||||
if (meta.seat) cells.push({ label: t('reservations.meta.seat'), value: meta.class ? `${meta.seat}, ${meta.class}` : meta.seat })
|
||||
// One seat per leg on a booking with a stop, each under its route; otherwise the booking's own.
|
||||
cells.push(...seatCells(r, t('reservations.meta.seat'), meta.class ? `, ${meta.class}` : ''))
|
||||
if (!c.hasLinkedCost && meta.price != null && meta.price !== '') {
|
||||
cells.push({ label: t('reservations.price'), value: formatPriceText(meta.price, meta.priceCurrency, c.tripCurrency, locale) })
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useTranslation } from '../../../../i18n'
|
||||
import { useSettingsStore } from '../../../../store/settingsStore'
|
||||
import { RES_ICONS } from '../../../../components/Planner/DayPlanSidebar.constants'
|
||||
import { splitReservationDateTime } from '../../../../utils/formatters'
|
||||
import { getFlightLegs, getTrainLegs, usesStationRoute, type FlightLeg, type TrainLeg } from '../../../../utils/flightLegs'
|
||||
import { getFlightLegs, getTrainLegs, seatLabel, seatsOfLegs, usesStationRoute, type FlightLeg, type TrainLeg } from '../../../../utils/flightLegs'
|
||||
import { runsOnDay } from '../../../../utils/reservationRoutes'
|
||||
import { filesFor } from '../../../../utils/reservationFiles'
|
||||
import { bookingDayLabel, segmentCodeLabel } from '../../../../components/Planner/transportDetailModel'
|
||||
@@ -169,8 +169,12 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
if (leg && (leg.from || leg.to)) subParts.push(flowText([leg.from, leg.to].filter((n): n is string => !!n)))
|
||||
else if (from?.name && to?.name) subParts.push(flowText([from.name, to.name]))
|
||||
|
||||
// A flight's legs carry no seat or platform of their own, so those stay the booking's.
|
||||
const seat = leg && !isFlight ? legDetail.seat : meta.seat
|
||||
// Opened from a leg, that leg's own seat; the whole booking lists the seat of
|
||||
// every leg that has one, each under its route, rather than only the first's.
|
||||
const seats: { route: string | null; seat: string }[] = leg ? (legDetail.seat ? [{ route: null, seat: legDetail.seat }] : []) : seatsOfLegs(routeLegs, meta.seat)
|
||||
const ownSeat = seats.find(s => s.route == null)?.seat
|
||||
const legSeats = seats.filter(s => s.route != null)
|
||||
// A flight's legs carry no platform of their own, so that stays the booking's.
|
||||
const platform = leg && !isFlight ? legDetail.platform : meta.platform
|
||||
const transitLegs: TransitLeg[] = Array.isArray(meta.transit?.legs) ? meta.transit.legs : []
|
||||
|
||||
@@ -212,6 +216,9 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
)
|
||||
: []
|
||||
|
||||
// The times, platform and booking seat; each leg's seat gets a row of its own below it.
|
||||
const statRow = hotelStats.length === 0 && ((showTimes && (depTime || arrTime)) || !!ownSeat || !!platform)
|
||||
|
||||
// The editor that fits the booking: transports have their own, everything
|
||||
// else (a stay, a table, a ticket) the booking editor, as in the Bookings tab.
|
||||
const editTransport = () => {
|
||||
@@ -275,7 +282,7 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
))}
|
||||
|
||||
{/* ── Times / seat stats (the live card already shows the times) ── */}
|
||||
{hotelStats.length === 0 && ((showTimes && (depTime || arrTime)) || seat || platform) && (
|
||||
{statRow && (
|
||||
<div className="mt-[14px] flex gap-[6px]">
|
||||
{showTimes && depTime && (
|
||||
<StatBox caption={depDate} value={displayTime(depTime, locale, timeFormat)} label={depLabel} />
|
||||
@@ -284,7 +291,12 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
<StatBox caption={arrDate} value={displayTime(arrTime, locale, timeFormat)} label={arrLabel} />
|
||||
)}
|
||||
{platform && <StatBox value={platform} label={t('reservations.meta.platform')} />}
|
||||
{seat && <StatBox value={seat} label={t('reservations.meta.seat')} />}
|
||||
{ownSeat && <StatBox value={ownSeat} label={t('reservations.meta.seat')} />}
|
||||
</div>
|
||||
)}
|
||||
{hotelStats.length === 0 && legSeats.length > 0 && (
|
||||
<div className={`${statRow ? 'mt-[6px]' : 'mt-[14px]'} flex gap-[6px]`}>
|
||||
{legSeats.map((s, i) => <StatBox key={i} value={s.seat} label={seatLabel(t('reservations.meta.seat'), s.route)} />)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import { cardWhen, parseTransportMeta, timeRange } from './transportsModel'
|
||||
import { BOOKING_TYPE_COLOR, hotelStayTimes } from '../../../../components/Planner/bookings/bookingsModel'
|
||||
import { useReservationListFilter } from '../../../../components/Planner/bookings/useReservationListFilter'
|
||||
import { useReservationCard } from '../../../../components/Planner/bookings/useReservationCard'
|
||||
import { orderedEndpoints } from '../../../../utils/flightLegs'
|
||||
import { orderedEndpoints, seatCells } from '../../../../utils/flightLegs'
|
||||
import { filesFor } from '../../../../utils/reservationFiles'
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ function BookingCard({ res, planner, canEdit, compact, onView }: {
|
||||
if (!hasEndpoints && meta.departure_airport) metaCells.push({ label: t('reservations.meta.from'), value: meta.departure_airport })
|
||||
if (!hasEndpoints && meta.arrival_airport) metaCells.push({ label: t('reservations.meta.to'), value: meta.arrival_airport })
|
||||
if (meta.platform) metaCells.push({ label: t('reservations.meta.platform'), value: meta.platform })
|
||||
if (meta.seat) metaCells.push({ label: t('reservations.meta.seat'), value: meta.seat + (meta.class ? ` · ${meta.class}` : '') })
|
||||
metaCells.push(...seatCells(res, t('reservations.meta.seat'), meta.class ? ` · ${meta.class}` : ''))
|
||||
if (meta.price != null && meta.price !== '') {
|
||||
metaCells.push({ label: t('reservations.price'), value: formatPriceText(meta.price, meta.priceCurrency, planner.trip?.currency, locale) })
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import { cardWhen, parseTransportMeta } from './transportsModel'
|
||||
import { TRANSPORT_TYPE_COLOR } from '../../../../components/Planner/bookings/bookingsModel'
|
||||
import { useReservationListFilter } from '../../../../components/Planner/bookings/useReservationListFilter'
|
||||
import { useReservationCard } from '../../../../components/Planner/bookings/useReservationCard'
|
||||
import { orderedEndpoints } from '../../../../utils/flightLegs'
|
||||
import { orderedEndpoints, seatCells } from '../../../../utils/flightLegs'
|
||||
import { filesFor } from '../../../../utils/reservationFiles'
|
||||
import MFlightLiveStrip from '../MFlightLiveStrip'
|
||||
|
||||
@@ -113,7 +113,7 @@ function TransportCard({ res, planner, shell, canEdit, compact }: {
|
||||
if (!hasEndpoints && meta.arrival_airport) metaCells.push({ label: t('reservations.meta.to'), value: meta.arrival_airport })
|
||||
if (meta.train_number) metaCells.push({ label: t('reservations.meta.trainNumber'), value: meta.train_number })
|
||||
if (meta.platform) metaCells.push({ label: t('reservations.meta.platform'), value: meta.platform })
|
||||
if (meta.seat) metaCells.push({ label: t('reservations.meta.seat'), value: meta.seat + (meta.class ? ` · ${meta.class}` : '') })
|
||||
metaCells.push(...seatCells(res, t('reservations.meta.seat'), meta.class ? ` · ${meta.class}` : ''))
|
||||
if (meta.price != null && meta.price !== '') {
|
||||
metaCells.push({ label: t('reservations.price'), value: formatPriceText(meta.price, meta.priceCurrency, planner.trip?.currency, locale) })
|
||||
}
|
||||
|
||||
@@ -168,6 +168,20 @@ describe('watchBooking', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('carries the seat of every leg of a flight with a stop, also one booked only on the second', () => {
|
||||
const stopover = reservation({
|
||||
...flight,
|
||||
metadata: JSON.stringify({
|
||||
legs: [
|
||||
{ from: 'MXP', to: 'IST' },
|
||||
{ from: 'IST', to: 'JFK', seat: '14C' },
|
||||
],
|
||||
}),
|
||||
});
|
||||
const b = watchBooking(stopover, { day: '2026-11-17', time: '13:05' }, { dayDates: new Map(), places: new Map() });
|
||||
expect(b.seat).toBe('14C');
|
||||
});
|
||||
|
||||
it('gives a stay its check-in, check-out, dates from its days and the hotel as the place to go', () => {
|
||||
const dayDates = new Map([
|
||||
[2, '2026-11-18'],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Day, PackingItem, Place, Reservation, TodoItem, Trip } from '../types';
|
||||
import { parseReservationMetadata } from '../utils/flightLegs';
|
||||
import { bookingSeats, parseReservationMetadata } from '../utils/flightLegs';
|
||||
import { splitReservationDateTime } from '../utils/formatters';
|
||||
import { hasNativeFeature } from './capabilities';
|
||||
import { isNativeIos } from './platform';
|
||||
@@ -274,7 +274,13 @@ export function watchBooking(
|
||||
to: point(to),
|
||||
code: text(r.confirmation_number, 40),
|
||||
carrier: carrierOf(meta),
|
||||
seat: metaText(meta, 'seat'),
|
||||
// A flight or train with a stop: the seat of every leg, not only the first leg's.
|
||||
seat: text(
|
||||
bookingSeats(r)
|
||||
.map((s) => s.seat)
|
||||
.join(', '),
|
||||
20
|
||||
),
|
||||
platform: metaText(meta, 'platform'),
|
||||
...whereOf(r, places),
|
||||
checkIn: metaText(meta, 'check_in_time'),
|
||||
|
||||
@@ -192,6 +192,23 @@ describe('getTransportForDay', () => {
|
||||
expect(day2[0].__leg).toMatchObject({ index: 1, from: 'Frankfurt', to: 'München', train_number: 'ICE 500', platform: '9' })
|
||||
})
|
||||
|
||||
it('gives each leg of a flight with a stop its own seat, the first leg the flat one when it has none', () => {
|
||||
const flight = (legs: object[], seat?: string) => [{
|
||||
id: 42, type: 'flight', day_id: 1, end_day_id: 1,
|
||||
metadata: JSON.stringify({ ...(seat ? { seat } : {}), legs }),
|
||||
}]
|
||||
const legs = [
|
||||
{ from: 'MXP', to: 'IST', dep_day_id: 1, dep_time: '11:00', arr_day_id: 1, arr_time: '15:10' },
|
||||
{ from: 'IST', to: 'JFK', seat: '14C', dep_day_id: 1, dep_time: '17:05', arr_day_id: 1, arr_time: '20:40' },
|
||||
]
|
||||
const rows = getTransportForDay({ reservations: flight(legs), dayId: 1, dayAssignmentIds: [], days })
|
||||
expect(rows.map(r => r.__leg.seat)).toEqual([null, '14C'])
|
||||
// A booking saved before legs had seats keeps its flat seat on the first leg only.
|
||||
const unseated = [{ ...legs[0] }, { ...legs[1], seat: undefined }]
|
||||
const legacy = getTransportForDay({ reservations: flight(unseated, '3A'), dayId: 1, dayAssignmentIds: [], days })
|
||||
expect(legacy.map(r => r.__leg.seat)).toEqual(['3A', null])
|
||||
})
|
||||
|
||||
it('leaves a single-leg train untouched (no __leg)', () => {
|
||||
const reservations = [{ id: 41, type: 'train', day_id: 1, end_day_id: 1, metadata: JSON.stringify({ train_number: 'RE 1' }) }]
|
||||
const rows = getTransportForDay({ reservations, dayId: 1, dayAssignmentIds: [], days })
|
||||
|
||||
@@ -156,7 +156,12 @@ function parseMultiLegs(r: any): any[] | null {
|
||||
// Defensive: recover metadata that was accidentally double-encoded by an earlier
|
||||
// bug (a JSON string of a JSON string) so already-saved bookings heal on read.
|
||||
if (typeof meta === 'string') { try { meta = JSON.parse(meta || '{}') } catch { meta = {} } }
|
||||
if (meta && Array.isArray(meta.legs) && meta.legs.length > 1) return meta.legs
|
||||
if (meta && Array.isArray(meta.legs) && meta.legs.length > 1) {
|
||||
// The flat seat mirrors the first leg's, so a booking saved before legs had
|
||||
// seats keeps it on its first leg (flightLegs' legSeat reads it the same way).
|
||||
const flatSeat = typeof meta.seat === 'string' && meta.seat ? meta.seat : null
|
||||
return meta.legs.map((l: Record<string, unknown> | null, i: number) => (i === 0 && flatSeat && !l?.seat ? { ...l, seat: flatSeat } : l))
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -200,9 +205,10 @@ export function expandFlightLegsForDay(
|
||||
index: i, total: legs.length,
|
||||
from: leg.from ?? null, to: leg.to ?? null,
|
||||
airline: leg.airline ?? null, flight_number: leg.flight_number ?? null,
|
||||
// Train legs carry their own per-leg detail; added only for trains so a
|
||||
// flight's __leg object stays byte-identical to before.
|
||||
...(r.type === 'train' ? { train_number: leg.train_number ?? null, platform: leg.platform ?? null, seat: leg.seat ?? null } : {}),
|
||||
// Each leg's own seat, a flight's too: it is saved per leg, and reading the
|
||||
// booking's flat seat showed the first leg's on every leg.
|
||||
seat: leg.seat ?? null,
|
||||
...(r.type === 'train' ? { train_number: leg.train_number ?? null, platform: leg.platform ?? null } : {}),
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { getFlightLegs, getTrainLegs, isMultiLegTrain, stripAirportCode, usesStationRoute } from './flightLegs'
|
||||
import { bookingSeats, getFlightLegs, getTrainLegs, isMultiLegTrain, seatCells, seatLabel, stripAirportCode, usesStationRoute } from './flightLegs'
|
||||
import type { Reservation } from '../types'
|
||||
|
||||
function res(partial: Partial<Reservation>): Reservation {
|
||||
@@ -97,6 +97,42 @@ describe('per-segment booking references (#1943)', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('the seats of a booking with a stop', () => {
|
||||
const stopover = (legs: object[], extra: Record<string, unknown> = {}) =>
|
||||
res({ type: 'flight', metadata: JSON.stringify({ ...extra, legs }) })
|
||||
|
||||
it('reads each flight leg its own seat, so one booked only on the second leg is not lost', () => {
|
||||
const r = stopover([{ from: 'MXP', to: 'IST' }, { from: 'IST', to: 'JFK', seat: '14C' }])
|
||||
expect(getFlightLegs(r).map(l => l.seat)).toEqual([undefined, '14C'])
|
||||
expect(bookingSeats(r)).toEqual([{ route: 'IST → JFK', seat: '14C' }])
|
||||
})
|
||||
|
||||
it('gives the first leg the flat seat when it has none of its own, as the booking form does', () => {
|
||||
const r = stopover([{ from: 'MXP', to: 'IST' }, { from: 'IST', to: 'JFK' }], { seat: '3A' })
|
||||
expect(getFlightLegs(r).map(l => l.seat)).toEqual(['3A', undefined])
|
||||
expect(bookingSeats(r)).toEqual([{ route: 'MXP → IST', seat: '3A' }])
|
||||
})
|
||||
|
||||
it('lists a train with a stop leg by leg too', () => {
|
||||
const r = res({ metadata: JSON.stringify({ legs: [{ from: 'Takayama', to: 'Nagoya', seat: '10-4C' }, { from: 'Nagoya', to: 'Kyoto', seat: '4-5A' }] }) })
|
||||
expect(bookingSeats(r)).toEqual([{ route: 'Takayama → Nagoya', seat: '10-4C' }, { route: 'Nagoya → Kyoto', seat: '4-5A' }])
|
||||
})
|
||||
|
||||
it('gives a booking of one leg, of any type, its own seat without a route', () => {
|
||||
expect(bookingSeats(res({ type: 'flight', metadata: JSON.stringify({ seat: '31A' }) }))).toEqual([{ route: null, seat: '31A' }])
|
||||
expect(bookingSeats(res({ type: 'event', metadata: JSON.stringify({ seat: 'Row 4' }) }))).toEqual([{ route: null, seat: 'Row 4' }])
|
||||
expect(bookingSeats(res({ type: 'flight', metadata: null }))).toEqual([])
|
||||
})
|
||||
|
||||
it('labels a leg seat with its route and a booking seat plainly', () => {
|
||||
expect(seatLabel('Seat', 'IST → JFK')).toBe('Seat IST → JFK')
|
||||
expect(seatLabel('Seat', null)).toBe('Seat')
|
||||
const r = stopover([{ from: 'MXP', to: 'IST', seat: '3A' }, { from: 'IST', to: 'JFK', seat: '14C' }])
|
||||
expect(seatCells(r, 'Seat', ' · Economy')).toEqual([{ label: 'Seat', value: '3A, 14C · Economy' }])
|
||||
expect(seatCells(res({ type: 'flight', metadata: null }), 'Seat')).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('stripAirportCode', () => {
|
||||
it('drops the code the forms and the airport backfill append, and nothing else', () => {
|
||||
expect(stripAirportCode('Paris Charles de Gaulle (CDG)')).toBe('Paris Charles de Gaulle')
|
||||
|
||||
@@ -19,6 +19,8 @@ export interface FlightLeg {
|
||||
to: string | null
|
||||
airline?: string
|
||||
flight_number?: string
|
||||
/** This leg's own seat; the first leg falls back to the booking's flat seat (see legSeat). */
|
||||
seat?: string
|
||||
/** This segment's own booking reference, when it was booked separately (#1943). */
|
||||
confirmation_number?: string
|
||||
dep_day_id?: number | null
|
||||
@@ -67,11 +69,12 @@ export function stripAirportCode(name: string): string {
|
||||
export function getFlightLegs(r: Reservation): FlightLeg[] {
|
||||
const meta = parseReservationMetadata(r)
|
||||
if (Array.isArray(meta.legs) && meta.legs.length > 0) {
|
||||
return meta.legs.map((l: any): FlightLeg => ({
|
||||
return meta.legs.map((l: any, i: number): FlightLeg => ({
|
||||
from: l.from ?? null,
|
||||
to: l.to ?? null,
|
||||
airline: l.airline || undefined,
|
||||
flight_number: l.flight_number || undefined,
|
||||
seat: legSeat(l, i, meta),
|
||||
confirmation_number: l.confirmation_number || undefined,
|
||||
dep_day_id: l.dep_day_id ?? null,
|
||||
dep_time: l.dep_time ?? null,
|
||||
@@ -91,6 +94,7 @@ export function getFlightLegs(r: Reservation): FlightLeg[] {
|
||||
to: toCode,
|
||||
airline: meta.airline || undefined,
|
||||
flight_number: meta.flight_number || undefined,
|
||||
seat: meta.seat || undefined,
|
||||
// The single segment IS the booking, so its reference is the booking's.
|
||||
confirmation_number: r.confirmation_number || undefined,
|
||||
dep_day_id: r.day_id ?? null,
|
||||
@@ -127,12 +131,12 @@ export interface TrainLeg {
|
||||
export function getTrainLegs(r: Reservation): TrainLeg[] {
|
||||
const meta = parseReservationMetadata(r)
|
||||
if (Array.isArray(meta.legs) && meta.legs.length > 0) {
|
||||
return meta.legs.map((l: any): TrainLeg => ({
|
||||
return meta.legs.map((l: any, i: number): TrainLeg => ({
|
||||
from: l.from ?? null,
|
||||
to: l.to ?? null,
|
||||
train_number: l.train_number || undefined,
|
||||
platform: l.platform || undefined,
|
||||
seat: l.seat || undefined,
|
||||
seat: legSeat(l, i, meta),
|
||||
confirmation_number: l.confirmation_number || undefined,
|
||||
dep_day_id: l.dep_day_id ?? null,
|
||||
dep_time: l.dep_time ?? null,
|
||||
@@ -161,6 +165,52 @@ export function getTrainLegs(r: Reservation): TrainLeg[] {
|
||||
}]
|
||||
}
|
||||
|
||||
/**
|
||||
* A leg's own seat. The flat `metadata.seat` mirrors the first leg's, so a
|
||||
* booking saved before legs carried seats, or one an import gave only the flat
|
||||
* seat, still shows it on its first leg, as the booking form reads it.
|
||||
*/
|
||||
function legSeat(leg: { seat?: unknown } | null | undefined, index: number, meta: { seat?: unknown }): string | undefined {
|
||||
if (typeof leg?.seat === 'string' && leg.seat) return leg.seat
|
||||
return index === 0 && typeof meta.seat === 'string' && meta.seat ? meta.seat : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* The seats of a booking, each with the route of the leg it belongs to. A flight
|
||||
* or train with a stop lists one per leg that has a seat, so a seat booked only
|
||||
* on the second leg is not lost behind the first leg's empty one; any other
|
||||
* booking gives its own seat with no route.
|
||||
*/
|
||||
export function bookingSeats(r: Reservation): { route: string | null; seat: string }[] {
|
||||
const legs: (FlightLeg | TrainLeg)[] =
|
||||
r.type === 'flight' ? getFlightLegs(r) : usesStationRoute(r.type) ? getTrainLegs(r) : []
|
||||
return seatsOfLegs(legs, parseReservationMetadata(r).seat)
|
||||
}
|
||||
|
||||
/** bookingSeats for legs already read (getFlightLegs or getTrainLegs) and the booking's flat seat. */
|
||||
export function seatsOfLegs(legs: readonly (FlightLeg | TrainLeg)[], flatSeat: unknown): { route: string | null; seat: string }[] {
|
||||
if (legs.length > 1) {
|
||||
return legs.flatMap((l) => (l.seat ? [{ route: [l.from, l.to].filter(Boolean).join(' → ') || null, seat: l.seat }] : []))
|
||||
}
|
||||
return typeof flatSeat === 'string' && flatSeat ? [{ route: null, seat: flatSeat }] : []
|
||||
}
|
||||
|
||||
/** The label of one of bookingSeats' seats: "Seat", or "Seat FRA → IST" for a leg. */
|
||||
export function seatLabel(seatWord: string, route: string | null): string {
|
||||
return route ? `${seatWord} ${route}` : seatWord
|
||||
}
|
||||
|
||||
/**
|
||||
* bookingSeats as the one Seat cell of a booking's field grid: every leg's seat
|
||||
* in route order, then `suffix` (its class). One cell, because a card cuts its
|
||||
* grid after a few cells and a route in the label does not fit a narrow one;
|
||||
* the detail views name each leg's seat under its route.
|
||||
*/
|
||||
export function seatCells(r: Reservation, seatWord: string, suffix = ''): { label: string; value: string }[] {
|
||||
const seats = bookingSeats(r)
|
||||
return seats.length ? [{ label: seatWord, value: seats.map((s) => s.seat).join(', ') + suffix }] : []
|
||||
}
|
||||
|
||||
/** Number of flight segments. 1 for a simple from -> to booking. */
|
||||
export function legCount(r: Reservation): number {
|
||||
return getFlightLegs(r).length
|
||||
|
||||
@@ -500,10 +500,43 @@ describe('MTransportSheet', () => {
|
||||
expect(screen.queryByText('10-4C')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-TRSH-035: without a leg the sheet still shows the booking as a whole', () => {
|
||||
it('FE-MOB-TRSH-035: without a leg the sheet shows the booking as a whole, with the seat of each leg under its route', () => {
|
||||
render(<MTransportSheet planner={makePlanner({ reservations: [TRAIN] })} shell={makeShell({ sheet: { id: 'transport', payload: { reservationId: 8 } } })} />)
|
||||
expect(screen.getByText('10-4C')).toBeInTheDocument()
|
||||
expect(screen.queryByText('4-5A')).not.toBeInTheDocument()
|
||||
expect(screen.getByText('10-4C').nextElementSibling).toHaveTextContent('Seat Takayama → Nagoya')
|
||||
expect(screen.getByText('4-5A').nextElementSibling).toHaveTextContent('Seat Nagoya → Kyoto')
|
||||
})
|
||||
})
|
||||
|
||||
// A flight with a stop saves a seat per leg; the sheet showed only the first leg's.
|
||||
describe('the seats of a flight with a stop', () => {
|
||||
const STOPOVER = {
|
||||
...FLIGHT, id: 9, title: 'MXP to JFK',
|
||||
metadata: JSON.stringify({
|
||||
airline: 'Turkish Airlines', flight_number: 'TK 1874',
|
||||
legs: [
|
||||
{ from: 'MXP', to: 'IST', airline: 'Turkish Airlines', flight_number: 'TK 1874', dep_time: '11:00', arr_time: '15:10' },
|
||||
{ from: 'IST', to: 'JFK', airline: 'Turkish Airlines', flight_number: 'TK 1', seat: '14C', dep_time: '17:05', arr_time: '20:40' },
|
||||
],
|
||||
}),
|
||||
} as unknown as Reservation
|
||||
const open = (legIndex?: number) => render(
|
||||
<MTransportSheet planner={makePlanner({ reservations: [STOPOVER] })} shell={makeShell({ sheet: { id: 'transport', payload: { reservationId: 9, legIndex } } })} />,
|
||||
)
|
||||
|
||||
it('FE-MOB-TRSH-045: the second leg shows its own seat', () => {
|
||||
open(1)
|
||||
expect(screen.getByText('14C').nextElementSibling).toHaveTextContent('Seat')
|
||||
})
|
||||
|
||||
it('FE-MOB-TRSH-046: the first leg, booked without a seat, shows none', () => {
|
||||
open(0)
|
||||
expect(screen.queryByText('14C')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('Seat')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-TRSH-047: the whole booking names the seat booked on its second leg', () => {
|
||||
open()
|
||||
expect(screen.getByText('14C').nextElementSibling).toHaveTextContent('Seat IST → JFK')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -146,6 +146,23 @@ const legsSchema = z.array(z.strictObject(transportLegInputSchema.shape)).option
|
||||
|
||||
type MetaRecord = Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* The stored metadata a legs-only update starts from, without the flat keys
|
||||
* that only mirrored the stored first leg's own detail. Those are set again
|
||||
* from the new legs; kept, a first leg's seat taken away stayed in the flat
|
||||
* seat, and the planner, which reads that as the first leg's, brought it back.
|
||||
* A flat value the first leg never had (an older booking) is the booking's own
|
||||
* and stays.
|
||||
*/
|
||||
function withoutLegMirrors(stored: MetaRecord, type: string): MetaRecord {
|
||||
const mirrored = type === 'flight' ? ['airline', 'flight_number', 'seat'] : ['train_number', 'platform', 'seat'];
|
||||
const leg: unknown = Array.isArray(stored.legs) ? stored.legs[0] : null;
|
||||
const firstLeg = leg && typeof leg === 'object' ? (leg as MetaRecord) : null;
|
||||
return Object.fromEntries(
|
||||
Object.entries(stored).filter(([key, value]) => !(firstLeg && mirrored.includes(key) && firstLeg[key] === value)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* `reservations.metadata` as stored: a JSON string, or (from an old
|
||||
* double-encoding bug the client readers still heal around) a JSON string of a
|
||||
@@ -827,8 +844,8 @@ export class ReservationsMcp {
|
||||
})),
|
||||
// metadata keeps replacing wholesale when it is sent; a legs-only update
|
||||
// must not drop departure_airport / airtrail_ids / transit, so it merges
|
||||
// into what is stored instead.
|
||||
baseMetadata: metadata !== undefined ? { ...metadata } : { ...stored },
|
||||
// into what is stored instead, less the first leg's mirrored detail.
|
||||
baseMetadata: metadata !== undefined ? { ...metadata } : withoutLegMirrors(stored, resolvedType),
|
||||
previousLegs: Array.isArray(stored.legs) ? stored.legs as unknown[] : [],
|
||||
startDayId: start_day_id,
|
||||
endDayId: end_day_id,
|
||||
|
||||
@@ -193,6 +193,23 @@ function text(meta: Record<string, unknown>, key: string, max = 64): string | un
|
||||
return typeof value === 'string' || typeof value === 'number' ? clean(value, max) : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* The seat a pass shows. One pass covers a whole flight or train with a stop,
|
||||
* so it lists the seat of every leg that has one (the first leg falling back
|
||||
* to the flat seat, which mirrors it); before, a seat booked only on a later
|
||||
* leg was missing and the first leg's stood for the whole route.
|
||||
*/
|
||||
function seatsOf(meta: Record<string, unknown>): string | undefined {
|
||||
const legs = Array.isArray(meta.legs) && meta.legs.length > 1 ? (meta.legs as unknown[]) : null;
|
||||
if (!legs) return text(meta, 'seat', 16);
|
||||
const seats = legs.flatMap((leg, i) => {
|
||||
const own = leg && typeof leg === 'object' ? (leg as Record<string, unknown>).seat : undefined;
|
||||
const seat = typeof own === 'string' && own.trim() ? own : i === 0 ? meta.seat : undefined;
|
||||
return typeof seat === 'string' && seat.trim() ? [seat.trim()] : [];
|
||||
});
|
||||
return seats.length ? clean(seats.join(' / '), 16) : undefined;
|
||||
}
|
||||
|
||||
/** A stable serial for the booking, so adding its pass again replaces the one in Wallet. */
|
||||
export function serialFor(reservation: WalletPassSource['reservation']): string {
|
||||
const digest = createHash('sha256')
|
||||
@@ -258,7 +275,7 @@ export function buildWalletPassRequest(src: WalletPassSource, words: WalletWords
|
||||
add(words.flightNumber, number || undefined);
|
||||
}
|
||||
if (kind === 'train') add(words.trainNumber, text(meta, 'train_number', 20));
|
||||
add(words.seat, text(meta, 'seat', 16));
|
||||
add(words.seat, seatsOf(meta));
|
||||
add(words.platform, text(meta, 'platform', 16));
|
||||
if (endLocal) add(words.arrival, when(endLocal.date, endLocal.time));
|
||||
} else if (kind === 'hotel') {
|
||||
|
||||
@@ -1712,3 +1712,66 @@ 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 { reservation: { id: number } };
|
||||
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