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.
71 lines
2.4 KiB
Elixir
71 lines
2.4 KiB
Elixir
defmodule MicrowavepropWeb.ContactLive.MechanismTest do
|
||
use ExUnit.Case, async: true
|
||
|
||
alias MicrowavepropWeb.ContactLive.Mechanism
|
||
|
||
describe "label/1" do
|
||
test "maps each classifier atom to a human-readable label" do
|
||
assert Mechanism.label(:likely_rainscatter) == "Likely Rain Scatter"
|
||
assert Mechanism.label(:rainscatter_possible) == "Rain Scatter Possible"
|
||
assert Mechanism.label(:tropo_duct) == "Tropospheric Duct"
|
||
assert Mechanism.label(:troposcatter) == "Troposcatter"
|
||
assert Mechanism.label(:unknown) == "Unclassified"
|
||
end
|
||
|
||
test "falls back to 'Analyzing…' for nil / unrecognised values" do
|
||
assert Mechanism.label(nil) == "Analyzing…"
|
||
assert Mechanism.label(:some_new_atom_not_yet_mapped) == "Analyzing…"
|
||
end
|
||
end
|
||
|
||
describe "badge_class/1" do
|
||
test "returns a daisyUI badge class for every known mechanism" do
|
||
for m <- [
|
||
:likely_rainscatter,
|
||
:rainscatter_possible,
|
||
:tropo_duct,
|
||
:troposcatter,
|
||
:unknown,
|
||
nil,
|
||
:future_mechanism
|
||
] do
|
||
cls = Mechanism.badge_class(m)
|
||
assert is_binary(cls)
|
||
assert String.starts_with?(cls, "badge-")
|
||
end
|
||
end
|
||
|
||
test "distinguishes likely vs possible rain scatter visually" do
|
||
# 'likely' is the confident variant (filled), 'possible' is outlined.
|
||
assert Mechanism.badge_class(:likely_rainscatter) == "badge-info"
|
||
assert Mechanism.badge_class(:rainscatter_possible) == "badge-info badge-outline"
|
||
end
|
||
end
|
||
|
||
describe "explainer/1" do
|
||
test "every classified mechanism gets a non-empty, single-sentence explainer" do
|
||
for m <- [
|
||
:likely_rainscatter,
|
||
:rainscatter_possible,
|
||
:tropo_duct,
|
||
:troposcatter,
|
||
:unknown
|
||
] do
|
||
text = Mechanism.explainer(m)
|
||
assert is_binary(text)
|
||
assert text != ""
|
||
end
|
||
end
|
||
|
||
test "unclassified / nil returns an empty string (no tooltip needed)" do
|
||
assert Mechanism.explainer(nil) == ""
|
||
assert Mechanism.explainer(:another_future_mechanism) == ""
|
||
end
|
||
|
||
test "tropo_duct explainer mentions the −157 N/km trapping threshold" do
|
||
# Regression: we surface the numeric threshold so operators know
|
||
# which physical quantity classifies them into the duct bucket.
|
||
assert Mechanism.explainer(:tropo_duct) =~ "−157"
|
||
end
|
||
end
|
||
end
|