From 8451ecfcbc198e3969725e8316ce7a1677f2094f Mon Sep 17 00:00:00 2001 From: Myroslav Date: Sun, 23 Aug 2026 22:45:18 +0300 Subject: [PATCH] fix: build schedule-fallback fixtures in Kyiv time, not the runner's The three schedule-fallback cases wrote their departure maps with the process clock, but stopScheduleService reads those maps as Europe/Kyiv since 93b4beb. On a Kyiv laptop the two agreed and the suite passed; on the UTC CI runner the fixture landed three hours off, no departure matched, and the fallback assertions failed. --- tests/services/stopArrivalService.test.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/services/stopArrivalService.test.js b/tests/services/stopArrivalService.test.js index b0a1d78..42fea1e 100644 --- a/tests/services/stopArrivalService.test.js +++ b/tests/services/stopArrivalService.test.js @@ -253,18 +253,23 @@ describe("stopArrivalService.getTimetableForStop", () => { }); describe("stopArrivalService.getTimetableForStop — schedule fallback", () => { - // 10 minutes from now, as "HH:MM" in the same local timezone the departure - // maps are written in. - function localHHMM(offsetMinutes) { + // "HH:MM" in Europe/Kyiv, the zone the departure maps are written in and the + // one stopScheduleService reads them back in. Building these off the process + // clock passed on a Kyiv laptop and returned nothing on a UTC CI runner. + function kyivHHMM(offsetMinutes) { const at = new Date(Date.now() + offsetMinutes * 60 * 1000); - return `${String(at.getHours()).padStart(2, "0")}:${String(at.getMinutes()).padStart(2, "0")}`; + return at.toLocaleTimeString("en-GB", { + timeZone: "Europe/Kyiv", + hour: "2-digit", + minute: "2-digit", + }); } const scheduledRoute = { ...mockRoute, - stop_departure_time_map: { MG1001: [localHHMM(10)] }, - stop_departure_time_map_workday: { MG1001: [localHHMM(10)] }, - stop_departure_time_map_weekend: { MG1001: [localHHMM(10)] }, + stop_departure_time_map: { MG1001: [kyivHHMM(10)] }, + stop_departure_time_map_workday: { MG1001: [kyivHHMM(10)] }, + stop_departure_time_map_weekend: { MG1001: [kyivHHMM(10)] }, }; const stopWithSchedule = {