mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 02:56:10 +00:00
fix(bookings): show the calendar date beside transport times
Tapping a transport in the compact Transports or Bookings list on the phone opens the transport sheet, and its time boxes showed only the clock time. The sheet named a date only in its subline, and only for a booking with no route and no airline or number, so a flight or ferry could not be placed on a day without unfolding the whole list. A transport holding only times (its date lives on the linked trip day) had no date at all, and the desktop transport detail dialog had the same gap: it read the date off reservation_time alone and never named the arrival day of an overnight trip. The dates now come from one helper, bookingDates(), which reads the booking's own date, then the stop's local date, then the linked day's date, the rule bookingFacts already used and now shares. The phone sheet prints the date above each time (a leg opened from its row uses its own days); when no time box carries a date, because no time is entered yet or the live flight card stands in their place, the subline names the day instead. The desktop dialog names the day, or both days of an overnight trip in reading order, in the user's locale. Closes #3122
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-PLANNER-DPTRANSPORT-001 to FE-PLANNER-DPTRANSPORT-021
|
||||
// FE-PLANNER-DPTRANSPORT-001 to FE-PLANNER-DPTRANSPORT-024
|
||||
import { render, screen, fireEvent, within } from '../../../tests/helpers/render'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { resetAllStores, seedStore } from '../../../tests/helpers/store'
|
||||
@@ -329,4 +329,29 @@ describe('DayPlanSidebarTransportDetailModal', () => {
|
||||
await user.click(screen.getByRole('button', { name: 'Close' }))
|
||||
expect(setTransportDetail).toHaveBeenCalledWith(null)
|
||||
})
|
||||
|
||||
// #3122: a transport holding only times showed them without the day they fall on.
|
||||
it('FE-PLANNER-DPTRANSPORT-022: a booking holding only times names the date of its linked day', () => {
|
||||
seedStore(useTripStore, { days: [{ id: 4, trip_id: 1, day_number: 2, date: '2025-06-16' }] as never })
|
||||
const res = { ...flight(), day_id: 4, reservation_time: '09:15', reservation_end_time: '11:00', endpoints: [] } as Reservation
|
||||
render(<DayPlanSidebarTransportDetailModal {...makeProps({ transportDetail: res })} />)
|
||||
expect(screen.getByText('09:15 → 11:00').parentElement).toHaveTextContent(/Mon, Jun 16/)
|
||||
})
|
||||
|
||||
it('FE-PLANNER-DPTRANSPORT-023: an overnight booking names the arrival date too', () => {
|
||||
const res = { ...flight(), reservation_time: '2025-06-15T22:30:00', reservation_end_time: '2025-06-16T06:05:00' } as Reservation
|
||||
render(<DayPlanSidebarTransportDetailModal {...makeProps({ transportDetail: res })} />)
|
||||
expect(screen.getByText('22:30 → 06:05').parentElement).toHaveTextContent(/Sun, Jun 15 → Mon, Jun 16/)
|
||||
})
|
||||
|
||||
it('FE-PLANNER-DPTRANSPORT-024: in a right-to-left UI the overnight days read in order', () => {
|
||||
document.documentElement.dir = 'rtl'
|
||||
try {
|
||||
const res = { ...flight(), reservation_time: '2025-06-15T22:30:00', reservation_end_time: '2025-06-16T06:05:00' } as Reservation
|
||||
render(<DayPlanSidebarTransportDetailModal {...makeProps({ transportDetail: res })} />)
|
||||
expect(screen.getByText('22:30 → 06:05').parentElement).toHaveTextContent('Sun, Jun 15 ← Mon, Jun 16')
|
||||
} finally {
|
||||
document.documentElement.dir = ''
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -14,7 +14,9 @@ import { BOX, Eyebrow, Field, fs, toneColor, toneOf } from './bookings/bookingPa
|
||||
import { filesFor } from '../../utils/reservationFiles'
|
||||
import { bookingDayLabel, segmentCodeLabel } from './transportDetailModel'
|
||||
import { TransitLegs, transitSummary } from './bookings/transitParts'
|
||||
import type { Reservation } from '../../types'
|
||||
import { bookingDates } from './bookings/bookingsModel'
|
||||
import { flowText } from '../../utils/flowText'
|
||||
import type { Day, Reservation } from '../../types'
|
||||
|
||||
type Translate = (key: string, params?: Record<string, string | number>) => string
|
||||
|
||||
@@ -50,11 +52,12 @@ export function DayPlanSidebarTransportDetailModal({ transportDetail, ...rest }:
|
||||
function TransportDetailDialog({ res, setTransportDetail, onNavigateToFiles, onEdit, t, locale, timeFormat }: Omit<DayPlanSidebarTransportDetailModalProps, 'transportDetail'> & { res: Reservation }) {
|
||||
const titleId = useId()
|
||||
const allFiles = useTripStore(s => s.files)
|
||||
const days = useTripStore(s => s.days)
|
||||
const close = () => setTransportDetail(null)
|
||||
const meta = parseReservationMetadata(res)
|
||||
const transit = transitSummary(meta)
|
||||
const files = filesFor(res, allFiles || [])
|
||||
const when = whenOf(res, locale, timeFormat)
|
||||
const when = whenOf(res, days, locale, timeFormat)
|
||||
const cells = detailCells(res, meta, t)
|
||||
const confirmed = res.status === 'confirmed'
|
||||
|
||||
@@ -192,11 +195,18 @@ function detailCells(res: Reservation, meta: Record<string, unknown>, t: Transla
|
||||
return cells
|
||||
}
|
||||
|
||||
/** The booking's day and its time or time range, each empty when the booking has none. */
|
||||
function whenOf(res: Reservation, locale: string, timeFormat: string): { day: string; time: string } {
|
||||
const { date, time } = splitReservationDateTime(res.reservation_time)
|
||||
/**
|
||||
* The booking's calendar day (both, when it arrives on a later one) and its time or
|
||||
* time range, each empty when the booking has none. A booking holding only times
|
||||
* takes the date of the day it is linked to (#3122).
|
||||
*/
|
||||
function whenOf(res: Reservation, days: Day[], locale: string, timeFormat: string): { day: string; time: string } {
|
||||
const { time } = splitReservationDateTime(res.reservation_time)
|
||||
const { time: endTime } = splitReservationDateTime(res.reservation_end_time)
|
||||
const day = date ? bookingDayLabel(date, locale) : ''
|
||||
const dates = bookingDates(res, days || [])
|
||||
// An arrival date alone would read as the departure, so it only joins a start date.
|
||||
const span = dates.start ? [dates.start, dates.end !== dates.start ? dates.end : null].filter((d): d is string => !!d) : []
|
||||
const day = span.length > 0 ? flowText(span.map(d => bookingDayLabel(d, locale))) : ''
|
||||
const start = time ? formatTime(time, locale, timeFormat) : ''
|
||||
const end = endTime ? formatTime(endTime, locale, timeFormat) : ''
|
||||
return { day, time: start && end ? `${start} → ${end}` : start }
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Day, Reservation, ReservationEndpoint } from '../../../types'
|
||||
import { formatPriceText, formatTime, splitReservationDateTime } from '../../../utils/formatters'
|
||||
import { getFlightLegs, getTrainLegs, usesStationRoute } from '../../../utils/flightLegs'
|
||||
import { safeExternalHref } from '../../../utils/safeUrl'
|
||||
import { daySpan, hotelStayTimes, parseMeta, type AssignmentLookupEntry } from './bookingsModel'
|
||||
import { bookingDates, daySpan, hotelStayTimes, parseMeta, type AssignmentLookupEntry } from './bookingsModel'
|
||||
|
||||
export interface FactsContext {
|
||||
t: (key: string, params?: Record<string, string | number>) => string
|
||||
@@ -84,6 +84,7 @@ export function bookingFacts(r: Reservation, c: FactsContext): BookingFacts {
|
||||
const eps = (r.endpoints || []).slice().sort((a, b) => (a.sequence ?? 0) - (b.sequence ?? 0))
|
||||
const from = eps.find(e => e.role === 'from')
|
||||
const to = eps.find(e => e.role === 'to')
|
||||
const dates = bookingDates(r, c.days)
|
||||
const startTime = startDt.time || from?.local_time || null
|
||||
const endTime = endDt.time || to?.local_time || null
|
||||
// A stay backed by an accommodation says its times as check-in and check-out;
|
||||
@@ -124,8 +125,8 @@ export function bookingFacts(r: Reservation, c: FactsContext): BookingFacts {
|
||||
|
||||
return {
|
||||
day, time, startTime, endTime,
|
||||
startDate: startDt.date || from?.local_date || span.start?.date || null,
|
||||
endDate: endDt.date || to?.local_date || span.end?.date || null,
|
||||
startDate: dates.start,
|
||||
endDate: dates.end,
|
||||
cells, endpoints: eps.length >= 2 ? eps : [], legCodes,
|
||||
place: r.location || r.place_name || null,
|
||||
accommodation: r.accommodation_name || null,
|
||||
|
||||
@@ -132,6 +132,23 @@ export function daySpan(r: Reservation, days: Day[]): DaySpan {
|
||||
return { start: byId(r.day_id), end: byId(r.end_day_id) }
|
||||
}
|
||||
|
||||
/**
|
||||
* The calendar dates a booking starts and ends on, as "YYYY-MM-DD", or null where it
|
||||
* knows none: its own date first, then the local date of its first or last stop,
|
||||
* then the date of the day it is linked to. A day-linked transport often carries
|
||||
* only times, so its day stands in.
|
||||
*/
|
||||
export function bookingDates(r: Reservation, days: Day[]): { start: string | null; end: string | null } {
|
||||
const span = daySpan(r, days)
|
||||
const eps = (r.endpoints || []).slice().sort((a, b) => (a.sequence ?? 0) - (b.sequence ?? 0))
|
||||
const from = eps.find(e => e.role === 'from')
|
||||
const to = eps.find(e => e.role === 'to')
|
||||
return {
|
||||
start: splitReservationDateTime(r.reservation_time).date || from?.local_date || span.start?.date || null,
|
||||
end: splitReservationDateTime(r.reservation_end_time).date || to?.local_date || span.end?.date || null,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The moment a booking starts, as "YYYY-MM-DDTHH:MM" in its own local time, or null
|
||||
* without any date. A day-linked transport often carries no date in reservation_time,
|
||||
|
||||
@@ -16,7 +16,7 @@ import { useSearchParams } from 'react-router'
|
||||
import { isTransportReservationType } from '@trek/shared'
|
||||
import { useBookingLink } from '../../../../hooks/useBookingLink'
|
||||
import { bookingFacts, stayStats } from '../../../../components/Planner/bookings/bookingFacts'
|
||||
import { parseMeta } from '../../../../components/Planner/bookings/bookingsModel'
|
||||
import { bookingDates, parseMeta } from '../../../../components/Planner/bookings/bookingsModel'
|
||||
import { ActionCircle, Eyebrow, INNER_CLS, StatBox, TileHeader, displayTime } from './MTripSheetUi'
|
||||
import { CardFiles } from '../tabs/MReservationCardParts'
|
||||
import { downloadAttachment, openAttachment } from '../../../../components/Planner/bookings/openAttachment'
|
||||
@@ -131,9 +131,10 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
const canEdit = liveRes != null && (isTransportReservationType(liveRes.type) ? canEditDays : canEditBookings)
|
||||
const ResIcon = RES_ICONS[res.type as keyof typeof RES_ICONS] || RES_ICONS.other
|
||||
|
||||
const from = (res.endpoints || []).find(e => e.role === 'from')
|
||||
const to = (res.endpoints || []).find(e => e.role === 'to')
|
||||
const { date, time: startTime } = splitReservationDateTime(res.reservation_time)
|
||||
const endpoints = res.endpoints || []
|
||||
const from = endpoints.find(e => e.role === 'from')
|
||||
const to = endpoints.find(e => e.role === 'to')
|
||||
const { time: startTime } = splitReservationDateTime(res.reservation_time)
|
||||
const { time: endTime } = splitReservationDateTime(res.reservation_end_time)
|
||||
const bookingDepTime = from?.local_time || startTime
|
||||
const bookingArrTime = to?.local_time || endTime
|
||||
@@ -151,6 +152,12 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
const arrTime = leg ? leg.arr_time || '' : bookingArrTime
|
||||
const depLabel = (leg ? leg.from : from?.name) || t('reservations.time')
|
||||
const arrLabel = (leg ? leg.to : to?.name) || t('reservations.time')
|
||||
// The calendar date each time falls on (#3122): a time alone cannot be placed
|
||||
// when the sheet is opened from a compact list that shows nothing else.
|
||||
const legDate = (dayId?: number | null) => (dayId != null ? planner.days.find(d => d.id === dayId)?.date : null) || null
|
||||
const dates = leg ? { start: legDate(leg.dep_day_id), end: legDate(leg.arr_day_id) } : bookingDates(res, planner.days)
|
||||
const depDate = dates.start ? bookingDayLabel(dates.start, locale) : null
|
||||
const arrDate = dates.end ? bookingDayLabel(dates.end, locale) : null
|
||||
|
||||
const subParts: string[] = []
|
||||
const airline = leg ? legDetail.airline : meta.airline
|
||||
@@ -161,7 +168,6 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
if (trainNumber) subParts.push(trainNumber)
|
||||
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]))
|
||||
else if (date) subParts.push(bookingDayLabel(date, locale))
|
||||
|
||||
// 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
|
||||
@@ -170,6 +176,11 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
|
||||
// Opened from one leg's row, only that leg's live card; from the booking, every followed leg.
|
||||
const shownLive = leg ? liveLegs.filter(l => l.leg_index === payload.legIndex) : liveLegs
|
||||
const showTimes = shownLive.length === 0
|
||||
// A shown time box carries its own date. Without one (no time entered yet, or the
|
||||
// live card in its place) the subline names the day, route and airline or not.
|
||||
const datedTime = showTimes && ((depTime && depDate) || (arrTime && arrDate))
|
||||
if (depDate && !datedTime) subParts.push(depDate)
|
||||
|
||||
const resFiles = filesFor(res, planner.files || [])
|
||||
|
||||
@@ -263,13 +274,13 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
))}
|
||||
|
||||
{/* ── Times / seat stats (the live card already shows the times) ── */}
|
||||
{hotelStats.length === 0 && ((shownLive.length === 0 && (depTime || arrTime)) || seat || platform) && (
|
||||
{hotelStats.length === 0 && ((showTimes && (depTime || arrTime)) || seat || platform) && (
|
||||
<div className="mt-[14px] flex gap-[6px]">
|
||||
{shownLive.length === 0 && depTime && (
|
||||
<StatBox value={displayTime(depTime, locale, timeFormat)} label={depLabel} />
|
||||
{showTimes && depTime && (
|
||||
<StatBox caption={depDate} value={displayTime(depTime, locale, timeFormat)} label={depLabel} />
|
||||
)}
|
||||
{shownLive.length === 0 && arrTime && (
|
||||
<StatBox value={displayTime(arrTime, locale, timeFormat)} label={arrLabel} />
|
||||
{showTimes && arrTime && (
|
||||
<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')} />}
|
||||
|
||||
@@ -121,6 +121,8 @@ export function TileHeader({ icon, title, sub, subWrap = false, onClose, closeLa
|
||||
interface StatBoxProps {
|
||||
value: ReactNode
|
||||
label: ReactNode
|
||||
/** A line above the value, such as the calendar date a time falls on. */
|
||||
caption?: ReactNode
|
||||
blurred?: boolean
|
||||
onClick?: () => void
|
||||
/** Colours the label, so a check-in or check-out time carries its own state. */
|
||||
@@ -133,10 +135,11 @@ const LABEL_TONE: Record<NonNullable<StatBoxProps['labelTone']>, string> = {
|
||||
}
|
||||
|
||||
/** Small stat box (check-in / times / code): value 700 tabular over a faint Geist label. */
|
||||
export function StatBox({ value, label, blurred = false, onClick, labelTone }: StatBoxProps) {
|
||||
export function StatBox({ value, label, caption, blurred = false, onClick, labelTone }: StatBoxProps) {
|
||||
const box = 'min-w-0 flex-1 rounded-[10px] bg-[color:var(--m-ic)] px-[9px] py-[7px] text-center'
|
||||
const inner = (
|
||||
<>
|
||||
{caption && <div className="truncate font-geist text-caption leading-tight text-m-muted">{caption}</div>}
|
||||
<div
|
||||
className={`truncate text-[0.8125rem] font-bold tabular-nums leading-tight ${blurred ? 'blur-[4px] select-none' : ''}`}
|
||||
>
|
||||
|
||||
@@ -9,7 +9,7 @@ import { buildPlanner, buildShell } from '../../../helpers/mobileTrip'
|
||||
import { resetAllStores, seedStore } from '../../../helpers/store'
|
||||
import { fireEvent, render, screen } from '../../../helpers/render'
|
||||
|
||||
// FE-MOB-TRSH-001 to FE-MOB-TRSH-036
|
||||
// FE-MOB-TRSH-001 to FE-MOB-TRSH-044
|
||||
|
||||
vi.mock('../../../../src/utils/fileDownload', () => ({
|
||||
openFile: vi.fn(() => Promise.resolve()),
|
||||
@@ -504,4 +504,108 @@ describe('MTransportSheet', () => {
|
||||
expect(screen.getByText('10:20')).toBeInTheDocument()
|
||||
expect(screen.getByText('06:45')).toBeInTheDocument()
|
||||
})
|
||||
// #3122: opened from the compact Transports list, the sheet showed the times
|
||||
// but not the day they fall on.
|
||||
describe('calendar dates beside the times (#3122)', () => {
|
||||
const DAYS = [
|
||||
{ id: 3, trip_id: 1, day_number: 1, date: '2026-05-01' },
|
||||
{ id: 4, trip_id: 1, day_number: 2, date: '2026-05-02' },
|
||||
]
|
||||
|
||||
it('FE-MOB-TRSH-037: a flight with a route shows the departure and the arrival date beside their times', () => {
|
||||
render(<MTransportSheet planner={makePlanner({ days: DAYS })} shell={makeShell()} />)
|
||||
const dep = screen.getByText('10:20').parentElement as HTMLElement
|
||||
const arr = screen.getByText('06:45').parentElement as HTMLElement
|
||||
expect(dep).toHaveTextContent('Fri, May 1')
|
||||
expect(arr).toHaveTextContent('Sat, May 2')
|
||||
})
|
||||
|
||||
it('FE-MOB-TRSH-038: a transport holding only times reads its date off the linked day, not "Day 1"', () => {
|
||||
const res = {
|
||||
...FLIGHT, type: 'ferry', title: 'Ferry to Naxos', day_id: 4, end_day_id: null,
|
||||
reservation_time: '08:15', reservation_end_time: '13:40', metadata: null,
|
||||
endpoints: [
|
||||
{ id: 1, reservation_id: 7, role: 'from', sequence: 0, name: 'Piraeus', lat: 37.94, lng: 23.64, local_date: null, local_time: null },
|
||||
{ id: 2, reservation_id: 7, role: 'to', sequence: 1, name: 'Naxos', lat: 37.1, lng: 25.37, local_date: null, local_time: null },
|
||||
],
|
||||
} as unknown as Reservation
|
||||
render(<MTransportSheet planner={makePlanner({ days: DAYS, reservations: [res] })} shell={makeShell()} />)
|
||||
expect(screen.getByText('08:15').parentElement).toHaveTextContent('Sat, May 2')
|
||||
expect(screen.queryByText(/Day 1/)).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it("FE-MOB-TRSH-039: a leg opened from its row shows that leg's own dates", () => {
|
||||
const res = {
|
||||
...FLIGHT, type: 'train', title: 'Night train', endpoints: [], reservation_time: null, reservation_end_time: null,
|
||||
metadata: JSON.stringify({
|
||||
legs: [
|
||||
{ from: 'Vienna', to: 'Munich', dep_day_id: 3, dep_time: '22:10', arr_day_id: 3, arr_time: '23:50' },
|
||||
{ from: 'Munich', to: 'Paris', dep_day_id: 3, dep_time: '23:58', arr_day_id: 4, arr_time: '09:30' },
|
||||
],
|
||||
}),
|
||||
} as unknown as Reservation
|
||||
render(<MTransportSheet planner={makePlanner({ days: DAYS, reservations: [res] })} shell={makeShell({ sheet: { id: 'transport', payload: { reservationId: 7, legIndex: 1 } } })} />)
|
||||
expect(screen.getByText('23:58').parentElement).toHaveTextContent('Fri, May 1')
|
||||
expect(screen.getByText('09:30').parentElement).toHaveTextContent('Sat, May 2')
|
||||
})
|
||||
|
||||
it('FE-MOB-TRSH-040: names a date once, beside the time, and not again in the subline', () => {
|
||||
const res = { ...FLIGHT, endpoints: [], metadata: null } as unknown as Reservation
|
||||
render(<MTransportSheet planner={makePlanner({ days: DAYS, reservations: [res] })} shell={makeShell()} />)
|
||||
expect(screen.getAllByText('Fri, May 1')).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('FE-MOB-TRSH-041: a flight with an airline but no route and no time names its date in the subline', () => {
|
||||
const res = { ...FLIGHT, endpoints: [], reservation_time: '2026-05-01', reservation_end_time: null } as unknown as Reservation
|
||||
render(<MTransportSheet planner={makePlanner({ days: DAYS, reservations: [res] })} shell={makeShell()} />)
|
||||
expect(screen.getByText('Lufthansa · LH 716 · Fri, May 1')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-TRSH-042: a transport with a route but no times yet names the date of its linked day', () => {
|
||||
const res = {
|
||||
...FLIGHT, type: 'ferry', title: 'Ferry to Naxos', day_id: 4, end_day_id: null,
|
||||
reservation_time: null, reservation_end_time: null, metadata: null,
|
||||
endpoints: [
|
||||
{ id: 1, reservation_id: 7, role: 'from', sequence: 0, name: 'Piraeus', lat: 37.94, lng: 23.64, local_date: null, local_time: null },
|
||||
{ id: 2, reservation_id: 7, role: 'to', sequence: 1, name: 'Naxos', lat: 37.1, lng: 25.37, local_date: null, local_time: null },
|
||||
],
|
||||
} as unknown as Reservation
|
||||
render(<MTransportSheet planner={makePlanner({ days: DAYS, reservations: [res] })} shell={makeShell()} />)
|
||||
expect(screen.getByText('Piraeus → Naxos · Sat, May 2')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-MOB-TRSH-043: with the live card in place of the time boxes, the subline names the date', () => {
|
||||
const now = Date.now()
|
||||
const soon: FlightLiveLeg = {
|
||||
reservation_id: 7, leg_index: 0, callsign: 'DLH716', flight_number: 'LH 716', service_date: '2026-05-01',
|
||||
origin: { code: 'FRA', name: 'Frankfurt', lat: 50.03, lng: 8.57, timezone: 'Europe/Berlin' },
|
||||
destination: { code: 'HND', name: 'Tokyo Haneda', lat: 35.55, lng: 139.78, timezone: 'Asia/Tokyo' },
|
||||
phase: 'scheduled', scheduled_departure: new Date(now + 3_600_000).toISOString(), scheduled_arrival: new Date(now + 7_200_000).toISOString(),
|
||||
departed_at: null, landed_at: null, estimated_arrival: null, departure_delay_min: null, arrival_delay_min: null,
|
||||
progress: null, distance_total_km: null, distance_remaining_km: null, position: null, aircraft: null,
|
||||
last_seen_at: null, fetched_at: new Date(now).toISOString(), stale: false, source: 'adsb.lol',
|
||||
}
|
||||
useFlightLiveStore.setState({ trips: { 1: { enabled: true, attribution: null, legs: { [legKey(7, 0)]: soon } } } })
|
||||
render(<MTransportSheet planner={makePlanner({ days: DAYS })} shell={makeShell()} />)
|
||||
expect(screen.queryByText('10:20')).not.toBeInTheDocument()
|
||||
expect(screen.getByText(/Frankfurt \(FRA\) → Tokyo \(HND\) · Fri, May 1/)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
// Each box stands on its own in the row, so a same-day trip keeps the date on both
|
||||
// rather than leaving one box a line shorter than the other.
|
||||
it('FE-MOB-TRSH-044: a same-day trip shows its date on both time boxes', () => {
|
||||
const res = {
|
||||
...FLIGHT, type: 'train', title: 'ICE to Munich', metadata: null,
|
||||
reservation_time: '2026-05-01T10:20', reservation_end_time: '2026-05-01T12:05',
|
||||
endpoints: [
|
||||
{ id: 1, reservation_id: 7, role: 'from', sequence: 0, name: 'Frankfurt Hbf', lat: 50.1, lng: 8.66, local_date: '2026-05-01', local_time: '10:20' },
|
||||
{ id: 2, reservation_id: 7, role: 'to', sequence: 1, name: 'München Hbf', lat: 48.14, lng: 11.56, local_date: '2026-05-01', local_time: '12:05' },
|
||||
],
|
||||
} as unknown as Reservation
|
||||
render(<MTransportSheet planner={makePlanner({ days: DAYS, reservations: [res] })} shell={makeShell()} />)
|
||||
expect(screen.getByText('10:20').parentElement).toHaveTextContent('Fri, May 1')
|
||||
expect(screen.getByText('12:05').parentElement).toHaveTextContent('Fri, May 1')
|
||||
expect(screen.getAllByText('Fri, May 1')).toHaveLength(2)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user