diff --git a/client/src/native/widgets.test.ts b/client/src/native/widgets.test.ts index 5cc6d61e8..18be985eb 100644 --- a/client/src/native/widgets.test.ts +++ b/client/src/native/widgets.test.ts @@ -248,6 +248,30 @@ describe('the richer snapshot', () => { expect(tripDayState(today, 23 * 60 + 30, 'done')).toMatchObject({ nextName: 'ATL → ORF', done: 2 }); }); + it('lands a leg without an arrival day on the day it leaves', () => { + const plain = todayOf( + trip(1, '2026-11-09', '2026-11-09'), + [day(5, 1, '2026-11-09', [])], + '2026-11-09', + () => 'D', + (t) => t + ); + if (!plain) throw new Error('the trip runs today'); + const legs = [ + { from: 'SNA', to: 'ATL', dep_day_id: 5, dep_time: '08:00', arr_time: '10:00' }, + { from: 'ATL', to: 'ORF', dep_day_id: 5, dep_time: '12:00', arr_time: '14:00' }, + ]; + const today = withBookings( + plain, + [ + { id: 2, trip_id: 1, title: 'Hop', type: 'flight', status: 'confirmed', metadata: JSON.stringify({ legs }) }, + ] as never, + '2026-11-09', + (t) => t + ); + expect(tripDayState(today, 15 * 60, 'done')).toMatchObject({ nextName: 'done', done: 2 }); + }); + it('counts a booking with an end time as under way until it ends', () => { const plain = todayOf( trip(1, '2026-11-09', '2026-11-09'), diff --git a/client/src/native/widgets.ts b/client/src/native/widgets.ts index 93318b598..aebe46c82 100644 --- a/client/src/native/widgets.ts +++ b/client/src/native/widgets.ts @@ -243,7 +243,8 @@ export function withBookings( name: leg.from && leg.to ? `${leg.from} → ${leg.to}` : r.title, time: formatTime(leg.dep_time), minutes: minutesOf(leg.dep_time), - endMinutes: leg.arr_day_id === day.dayId ? minutesOf(leg.arr_time) : 24 * 60, + // A leg without an arrival day lands on the day it leaves, as the planner reads it. + endMinutes: (leg.arr_day_id ?? leg.dep_day_id) === day.dayId ? minutesOf(leg.arr_time) : 24 * 60, color: null, symbol, },