Adds ~600 new test cases (2013 → 2613 tests; 170 properties; 0
failures) across 12 new test files plus expansions of eight existing
files. Big lifts per module:
ContactLive.Mechanism 33 → 100%
MetricsPlug 54 → ~100%
Microwaveprop.Release 15.8 → 70%+
Telemetry 38 → 76%
HrrrNativeGridWorker 27.7 → 76%
ContactLive.Show 34 → 48% (handler + render branches)
Admin.ContactEditLive 49.7 → 70%+
GefsFetchWorker 35.8 → ~55%
IonosphereFetchWorker 56.3 → 75%
PathLive 58.9 → 67%
WeatherMapLive 66.9 → 80.2%
RoverLive 0 → 70.3%
ContactMapLive 59.2 → 89.8%
ContactMapController 0 → 100%
Mix tasks (Rust.Golden, Notebook, Backtest, HrrrBackfill,
HrrrClimatology, HrrrNativeBackfill, NexradBackfill,
RadarBackfill, ImportContestLogs, PropagationGrid,
ResetEnrichment, Hrrr.PurgeGridPoints) 0 → ~60-100%
Two incidental fixes made while adding tests:
- ContactLive.Show.handle_event("toggle_flag", ...) was passing
socket.assigns.current_scope to admin?/1 instead of socket.assigns,
so admins never matched the pattern and every toggle ran the
"Admins only." flash branch. Flag now toggles for admins again.
- Commercial.PollWorker.fetch_weather/1 promoted from private to
@doc'd public so the IEM-fetch + ASOS-upsert path can be tested
directly without driving perform/1 through live SNMP (which was
timing out for ~50 s per test in the earlier attempt).
Stable property-test additions cover the dewpoint-from-RH monotonicity,
nearest_run/1 idempotence, and the ionosphere station envelope.
91 lines
2.8 KiB
Elixir
91 lines
2.8 KiB
Elixir
defmodule MicrowavepropWeb.ContactMapLiveTest do
|
|
use MicrowavepropWeb.ConnCase, async: true
|
|
|
|
import Phoenix.LiveViewTest
|
|
|
|
alias Microwaveprop.Radio.Contact
|
|
alias Microwaveprop.Repo
|
|
|
|
defp create_contact(attrs \\ %{}) do
|
|
default = %{
|
|
station1: "W5XD",
|
|
station2: "K5TR",
|
|
qso_timestamp: ~U[2026-03-28 18:00:00Z],
|
|
mode: "CW",
|
|
band: Decimal.new("1296"),
|
|
grid1: "EM12",
|
|
grid2: "EM00",
|
|
pos1: %{"lat" => 32.9, "lon" => -97.0},
|
|
pos2: %{"lat" => 30.3, "lon" => -97.7},
|
|
distance_km: Decimal.new("295")
|
|
}
|
|
|
|
{:ok, contact} =
|
|
%Contact{}
|
|
|> Contact.changeset(Map.merge(default, attrs))
|
|
|> Repo.insert()
|
|
|
|
contact
|
|
end
|
|
|
|
describe "GET /contacts/map" do
|
|
test "renders the shell with the Contact Map heading + JS hook container", %{conn: conn} do
|
|
{:ok, _lv, html} = live(conn, ~p"/contacts/map")
|
|
|
|
assert html =~ "Contact Map"
|
|
assert html =~ ~s(id="contacts-map")
|
|
assert html =~ ~s(phx-hook="ContactsMap")
|
|
# Client fetches the JSON blob from the controller endpoint.
|
|
assert html =~ ~s(data-fetch-url="/api/contacts/map")
|
|
end
|
|
|
|
test "shows the contact count and the populated band list", %{conn: conn} do
|
|
_c1 = create_contact(%{band: Decimal.new("1296")})
|
|
_c2 = create_contact(%{band: Decimal.new("10000"), station1: "W5OTHR"})
|
|
|
|
{:ok, _lv, html} = live(conn, ~p"/contacts/map")
|
|
|
|
assert html =~ "2 contacts"
|
|
# band_label/1 converts bands ≥ 1000 MHz into GHz — integer values
|
|
# stay whole ("10 GHz"), non-integer ratios round to 1 decimal ("1.3 GHz").
|
|
assert html =~ "1.3 GHz"
|
|
assert html =~ "10 GHz"
|
|
end
|
|
|
|
test "empty DB renders '0 contacts' and no band checkboxes", %{conn: conn} do
|
|
{:ok, _lv, html} = live(conn, ~p"/contacts/map")
|
|
assert html =~ "0 contacts"
|
|
end
|
|
end
|
|
|
|
describe "filter_callsign event" do
|
|
test "stores the trimmed filter and pushes apply_filter to the hook", %{conn: conn} do
|
|
{:ok, lv, _html} = live(conn, ~p"/contacts/map")
|
|
|
|
html =
|
|
render_change(
|
|
# There's a mobile and a desktop filter — just grab the desktop one.
|
|
element(lv, ~s(input.input-sm[phx-change="filter_callsign"])),
|
|
%{"callsign" => " W5ISP "}
|
|
)
|
|
|
|
# Server stored the trimmed value in assigns, which round-trips
|
|
# back through the `value=` attribute.
|
|
assert html =~ ~s(value="W5ISP")
|
|
end
|
|
|
|
test "blank input round-trips as an empty value", %{conn: conn} do
|
|
{:ok, lv, _html} = live(conn, ~p"/contacts/map")
|
|
|
|
html =
|
|
render_change(
|
|
# There's a mobile and a desktop filter — just grab the desktop one.
|
|
element(lv, ~s(input.input-sm[phx-change="filter_callsign"])),
|
|
%{"callsign" => " "}
|
|
)
|
|
|
|
refute html =~ ~s(value=" ")
|
|
assert html =~ ~s(value="")
|
|
end
|
|
end
|
|
end
|