test: CoverageLive.Map probe_point malformed input + coverage_status broadcast

This commit is contained in:
Graham McIntire 2026-05-09 12:41:15 -05:00
parent 08cf3a67ff
commit 29c4bf5582

View file

@ -129,4 +129,38 @@ defmodule ToweropsWeb.CoverageLive.MapTest do
assert payload == []
end
end
describe "probe_point with non-numeric inputs" do
test "probe_point with malformed lat/lon strings clamps to 0.0", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/coverage")
# Should hit the to_float :error branch
assert render_click(view, "probe_point", %{"lat" => "foo", "lon" => "bar"})
end
end
describe "coverage_status PubSub broadcast" do
test "rebuilds coverage list and pushes event on broadcast", %{conn: conn, org: org, site: site} do
cov = coverage_fixture(org.id, site.id, %{name: "PubSubCov"})
{:ok, _ready} =
Coverages.mark_status(cov, "ready", %{
png_path: "/coverage/#{org.id}/#{cov.id}/rssi.png",
raster_path: "/coverage/#{org.id}/#{cov.id}/rssi.tif",
bbox_min_lat: 30.0,
bbox_min_lon: -98.0,
bbox_max_lat: 30.5,
bbox_max_lon: -97.5
})
{:ok, view, _html} = live(conn, ~p"/coverage")
# Send the broadcast manually
send(view.pid, {:coverage_status, "ready", cov.id})
# Force re-render — handle_info ran
html = render(view)
assert html =~ "PubSubCov"
end
end
end