diff --git a/backend/handlers/today/today_test.go b/backend/handlers/today/today_test.go index 6cb52d5..ca46b68 100644 --- a/backend/handlers/today/today_test.go +++ b/backend/handlers/today/today_test.go @@ -680,7 +680,14 @@ func TestGetCurrentNext_WithData(t *testing.T) { func TestGetCurrentNext_WithMultipleDataPoints(t *testing.T) { ctx, tx := testutils.SetupTestTx(t) - now := clock.Now() + londonNow := clock.Now().In(clock.London) + // Use fixed times within today's London business hours so the handler's + // London-midnight date range always includes both bookings regardless of + // when the test runs (runs near midnight UTC could push one booking + // outside the London "today" window). + todayAt := func(h, m int) time.Time { + return time.Date(londonNow.Year(), londonNow.Month(), londonNow.Day(), h, m, 0, 0, clock.London).UTC() + } svcID := createTodayService(t, ctx, tx) user1ID, err := fixtures.CreateTestUser(tx) @@ -693,7 +700,7 @@ func TestGetCurrentNext_WithMultipleDataPoints(t *testing.T) { INSERT INTO bookings (user_id, start_time, status) VALUES ($1, $2, 'completed') RETURNING id - `, user1ID, now.Add(-30*time.Minute)).Scan(&booking1ID) + `, user1ID, todayAt(10, 0)).Scan(&booking1ID) if err != nil { t.Fatalf("failed to create booking 1: %v", err) } @@ -725,7 +732,7 @@ func TestGetCurrentNext_WithMultipleDataPoints(t *testing.T) { INSERT INTO bookings (user_id, start_time, status) VALUES ($1, $2, 'completed') RETURNING id - `, user2ID, now.Add(-15*time.Minute)).Scan(&booking2ID) + `, user2ID, todayAt(11, 0)).Scan(&booking2ID) if err != nil { t.Fatalf("failed to create booking 2: %v", err) }