fix(native): a leg without an arrival day lands on the day it leaves in the Live Activity

This commit is contained in:
Maurice
2026-11-10 09:50:30 +01:00
parent 7506eaa4aa
commit 19956f2742
2 changed files with 26 additions and 1 deletions
+24
View File
@@ -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'),
+2 -1
View File
@@ -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,
},