From 1e8dd7036d5a979ef631d63c15a084dce5247287 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 24 Apr 2026 09:28:52 -0500 Subject: [PATCH] test: fix async-hydration timeout flake + type warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Bump render_async/2 timeout to 2_000ms across contact_live_test. Default 100ms races when the suite runs on a loaded box — ContactLive. Show fans out 8 hydration tasks at mount and sporadically missed the window even on a quiet DB. - Telemetry metrics-shape assertion uses Enum.any?/1 instead of the `metrics != []` comparison Elixir 1.19's type system flags as a distinct-type comparison (the function's non-empty return type). --- .../live/contact_live_test.exs | 18 +++++++++--------- test/microwaveprop_web/telemetry_test.exs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/microwaveprop_web/live/contact_live_test.exs b/test/microwaveprop_web/live/contact_live_test.exs index e701b1cc..bee3d0f2 100644 --- a/test/microwaveprop_web/live/contact_live_test.exs +++ b/test/microwaveprop_web/live/contact_live_test.exs @@ -383,7 +383,7 @@ defmodule MicrowavepropWeb.ContactLiveTest do {:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}") - html = render_async(lv) + html = render_async(lv, 2_000) assert html =~ "Atmospheric Profile" assert html =~ "NARR" # Collapsed summary shows HPBL / PWAT / lat,lon from the injected NARR row. @@ -441,7 +441,7 @@ defmodule MicrowavepropWeb.ContactLiveTest do |> Repo.insert() {:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}") - html = render_async(lv) + html = render_async(lv, 2_000) assert html =~ "HRRR native" # 300 mb comes from the native profile — pressure-level data capped at 700. @@ -719,7 +719,7 @@ defmodule MicrowavepropWeb.ContactLiveTest do {:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}") - html = render_async(lv) + html = render_async(lv, 2_000) # Surface Observations section is present; actual rows may or may # not render depending on internal proximity/time filters. The # render pass itself exercises the with-data code path either way. @@ -758,7 +758,7 @@ defmodule MicrowavepropWeb.ContactLiveTest do {:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}") - html = render_async(lv) + html = render_async(lv, 2_000) assert html =~ "KFWD" end @@ -915,7 +915,7 @@ defmodule MicrowavepropWeb.ContactLiveTest do contact = seed_fully_hydrated() {:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}") - html = render_async(lv) + html = render_async(lv, 2_000) # Headers / enrichment labels visible when data is present. assert html =~ contact.station1 @@ -932,7 +932,7 @@ defmodule MicrowavepropWeb.ContactLiveTest do contact = seed_fully_hydrated() {:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}") - _ = render_async(lv) + _ = render_async(lv, 2_000) # Simulate the TerrainProfileWorker broadcast — the listener # recomputes elevation_profile and propagation_analysis and @@ -946,7 +946,7 @@ defmodule MicrowavepropWeb.ContactLiveTest do contact = seed_fully_hydrated() {:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}") - _ = render_async(lv) + _ = render_async(lv, 2_000) send(lv.pid, {:terrain_ready, Ecto.UUID.generate()}) assert Process.alive?(lv.pid) @@ -956,7 +956,7 @@ defmodule MicrowavepropWeb.ContactLiveTest do contact = seed_fully_hydrated() {:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}") - _ = render_async(lv) + _ = render_async(lv, 2_000) send(lv.pid, {:sounding_fetched, %{contact_id: contact.id}}) html = render(lv) @@ -967,7 +967,7 @@ defmodule MicrowavepropWeb.ContactLiveTest do contact = seed_fully_hydrated() {:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}") - _ = render_async(lv) + _ = render_async(lv, 2_000) send(lv.pid, {:sounding_fetched, %{contact_id: Ecto.UUID.generate()}}) assert Process.alive?(lv.pid) diff --git a/test/microwaveprop_web/telemetry_test.exs b/test/microwaveprop_web/telemetry_test.exs index 00c72a10..7036c49d 100644 --- a/test/microwaveprop_web/telemetry_test.exs +++ b/test/microwaveprop_web/telemetry_test.exs @@ -9,7 +9,7 @@ defmodule MicrowavepropWeb.TelemetryTest do metrics = Telemetry.metrics() assert is_list(metrics) - assert metrics != [] + assert Enum.any?(metrics) for m <- metrics do assert is_struct(m)