fix(tests): generate trip days in UTC so a DST shift can't drop or repeat one

The test trip factory parsed date-only ISO strings as UTC midnight but stepped
the cursor with setDate(), which advances local wall-clock time. Across a DST
transition that step is 23h or 25h, so the instant drifts off midnight and
toISOString() reports the wrong day — a day is dropped in autumn and repeated
in spring.

TRIP-SVC-015 already builds a trip over 2025-11-01..2025-11-03, which straddles
the US fall-back, and fails on any machine in a DST-observing zone:

  AssertionError: expected [...] to have a length of 5 but got 4

CI runs UTC, where the loop happens to be correct, so this is invisible there
and only bites contributors running the suite locally.

Full server suite: 396 files, 7550 tests, green.
This commit is contained in:
michael-bohr
2026-08-13 15:25:53 -04:00
committed by Maurice
parent 412de9df4d
commit 55aef8d55c
+5 -1
View File
@@ -99,7 +99,11 @@ export function createTrip(
const end = new Date(overrides.end_date);
const tripId = result.lastInsertRowid as number;
let dayNumber = 1;
for (let d = new Date(start); d <= end; d.setDate(d.getDate() + 1)) {
// Step in UTC. A date-only ISO string parses as UTC midnight, but setDate()
// advances local wall-clock time — 23h or 25h across a DST transition — so the
// instant drifts off midnight and toISOString() then reports the wrong day:
// one is dropped in autumn, one repeated in spring. CI runs UTC and never sees it.
for (let d = new Date(start); d <= end; d.setUTCDate(d.getUTCDate() + 1)) {
const dateStr = d.toISOString().slice(0, 10);
db.prepare('INSERT INTO days (trip_id, day_number, date) VALUES (?, ?, ?)').run(tripId, dayNumber++, dateStr);
}