Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

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

michael-bohr55aef8d55c8a
diff --git a/server/tests/helpers/factories.ts b/server/tests/helpers/factories.ts
index a2f3704f8..5ef3d0346 100644
--- a/server/tests/helpers/factories.ts
+++ b/server/tests/helpers/factories.ts
@@ -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);
}