From 2768fc68c0630a08a98deda0102fc7d3be3c21a3 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 29 Apr 2026 16:58:56 -0500 Subject: [PATCH] fix(test): weather_map_live one-hour-cutoff test flake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test computed recent_t = (truncated_to_top_of_hour now) - 30min, which is 30-90 min before real utc_now() depending on what minute the test runs at. The LiveView's `cutoff = utc_now() - 1h` then dropped recent_t whenever the real-time minute exceeded ~30, so the test failed half the time. Anchor recent_t at the top of the current hour — that's always within the 1-hour window regardless of minute. The test still exercises the "keep within last hour" path; just stops being clock-flaky. --- test/microwaveprop_web/live/weather_map_live_test.exs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/microwaveprop_web/live/weather_map_live_test.exs b/test/microwaveprop_web/live/weather_map_live_test.exs index 37c68e2d..6d510ad2 100644 --- a/test/microwaveprop_web/live/weather_map_live_test.exs +++ b/test/microwaveprop_web/live/weather_map_live_test.exs @@ -83,7 +83,12 @@ defmodule MicrowavepropWeb.WeatherMapLiveTest do |> Map.put(:second, 0) stale_t = DateTime.add(now, -2 * 3600, :second) - recent_t = DateTime.add(now, -30 * 60, :second) + # `now` is truncated to the top of the hour; real `utc_now()` is up to + # 60 min ahead of that, so a `now - 30 min` recent_t is 30-90 min old + # of real time and the LiveView's `utc_now() - 1h` cutoff filters it + # out 50% of the time. Anchor recent_t at the top of the current hour + # — that's always within the 1-hour window regardless of minute. + recent_t = now future_t = DateTime.add(now, 3 * 3600, :second) Enum.each([stale_t, recent_t, future_t], &write_profile(&1, 33.0, -97.0))