Changes under lib/ (source):
- iemre_fetch_worker: replace `if transient_failure?/1` boolean predicate
+ `if/else` with a classifier that pattern-matches the error reason
directly, returning `:transient | :permanent`, and dispatch via
`case`. Three-clause head is clearer than the boolean predicate.
- scores_file.extract_points and nexrad_client.extract_box: force `//1`
step on the row/col comprehensions so an image box whose centre
lands outside the raster collapses to an empty iteration instead
of firing Elixir 1.19's ambiguous-range warning. Adds a regression
test for the right-edge box.
Test coverage added:
- Feature wrappers in Backtest.Features (theta_e_jump, shear_at_top,
duct_thickness, best_duct_freq, duct_usable_for_band,
distance_to_front / parallel_to_front stubs, all_features/0).
- NotifyListener handle_info tolerance for malformed payloads +
unknown messages, plus the PubSub broadcast side effect.
- Viewshed.effective_reach_km across every verdict / diffraction
tier / ducting-score tier combination.
- SnmpClient parse_af60_output unit conversions + unknown-column
handling; parse_snmpget_output OID normalisation and junk-line
tolerance.
- HrrrNativeClient native_level_count, native_variables,
native_messages shape, duct_messages / duct_byte_ranges.
- Changeset coverage for GeomagneticObservation, SolarFluxObservation,
SolarXrayObservation, Ionosphere.Observation, HrrrClimatology, and
Metar5minObservation — lifted each from ~50% / 0% to 100%.
- Property tests: GefsClient.dewpoint_from_rh invariants (Td ≤ T,
monotonic in RH, finite across the operating envelope) + idempotent
nearest_run. NexradClient.pixel_to_dbz monotonicity + bounded
output; latlon_to_pixel round-trip for every grid cell.
Also cleared several unrelated compiler/linter warnings:
- Three private test helpers (create_contact, insert_contact,
current_hour) had `\\ %{}` / `\\ 0` defaults that no caller used.
- profiles_file_test bound `dir` in a pattern match without using it.
Suite: 2,359 tests + 146 properties pass (was 2,300 / 139); coverage
70.38% → 70.89%; credo strict clean.
74 lines
2.3 KiB
Elixir
74 lines
2.3 KiB
Elixir
defmodule MicrowavepropWeb.Admin.ContactEditLiveTest do
|
|
use MicrowavepropWeb.ConnCase, async: false
|
|
|
|
import Microwaveprop.AccountsFixtures
|
|
import Phoenix.LiveViewTest
|
|
|
|
alias Microwaveprop.Accounts
|
|
alias Microwaveprop.Radio.Contact
|
|
alias Microwaveprop.Repo
|
|
|
|
defp admin_fixture do
|
|
user = user_fixture()
|
|
{:ok, user} = Accounts.admin_update_user(user, %{is_admin: true})
|
|
user
|
|
end
|
|
|
|
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")
|
|
}
|
|
|
|
merged = Map.merge(default, attrs)
|
|
# `flagged_invalid` isn't a user-facing submission field, so the
|
|
# changeset's cast drops it. Set it directly via change/2.
|
|
{direct_attrs, castable} = Map.split(merged, [:flagged_invalid])
|
|
|
|
{:ok, contact} =
|
|
%Contact{}
|
|
|> Contact.changeset(castable)
|
|
|> Ecto.Changeset.change(direct_attrs)
|
|
|> Repo.insert()
|
|
|
|
contact
|
|
end
|
|
|
|
describe "flagged contacts section" do
|
|
test "hidden when no contacts are flagged", %{conn: conn} do
|
|
_ok = create_contact(%{station1: "W5OK"})
|
|
conn = log_in_user(conn, admin_fixture())
|
|
|
|
{:ok, _lv, html} = live(conn, ~p"/admin/contact-edits")
|
|
refute html =~ "Flagged contacts"
|
|
end
|
|
|
|
test "lists flagged contacts with station callsigns for admins", %{conn: conn} do
|
|
_ok = create_contact(%{station1: "W5OK"})
|
|
_flagged = create_contact(%{station1: "W5BAD", flagged_invalid: true})
|
|
conn = log_in_user(conn, admin_fixture())
|
|
|
|
{:ok, _lv, html} = live(conn, ~p"/admin/contact-edits")
|
|
assert html =~ "Flagged contacts"
|
|
assert html =~ "W5BAD"
|
|
end
|
|
|
|
test "does not leak flagged contacts into the pending-edits table", %{conn: conn} do
|
|
_flagged = create_contact(%{station1: "W5BAD", flagged_invalid: true})
|
|
conn = log_in_user(conn, admin_fixture())
|
|
|
|
{:ok, _lv, html} = live(conn, ~p"/admin/contact-edits")
|
|
# The flagged list mentions W5BAD, but only inside the flagged
|
|
# section — the pending-edits table above should stay empty.
|
|
assert html =~ "0 pending"
|
|
end
|
|
end
|
|
end
|