From 038f546eba59ffd1296e0bea91b68955afe863e7 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sat, 18 Jul 2026 10:48:14 +0300 Subject: [PATCH] Fix E2E tests failing first hour after UTC midnight --- app/features/api-private/routes/seed.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/features/api-private/routes/seed.ts b/app/features/api-private/routes/seed.ts index db7d3ad00..5281309b2 100644 --- a/app/features/api-private/routes/seed.ts +++ b/app/features/api-private/routes/seed.ts @@ -1,5 +1,6 @@ import fs from "node:fs"; import path from "node:path"; +import { startOfToday, subHours } from "date-fns"; import type { ActionFunction } from "react-router"; import { z } from "zod"; import { sql } from "~/db/sql"; @@ -67,7 +68,12 @@ const SEED_REFERENCE_TIMESTAMP = 1767440151; // TODO: do this cleaner function adjustSeedDatesToCurrent(variation: SeedVariation) { const halfAnHourFromNow = Math.floor((Date.now() + 1000 * 60 * 30) / 1000); - const oneHourAgo = Math.floor((Date.now() - 1000 * 60 * 60) / 1000); + // clamped to the start of today so that within the first hour after midnight + // the event does not fall onto the previous calendar day (calendar renders today onward) + const oneHourAgo = Math.floor( + Math.max(subHours(new Date(), 1).getTime(), startOfToday().getTime()) / + 1000, + ); const now = Math.floor(Date.now() / 1000); const tournamentEventIds = sql