test: add MapLive.Index zoom threshold and tracking tests
This commit is contained in:
parent
b4d0093a8f
commit
3eec54439b
1 changed files with 83 additions and 0 deletions
|
|
@ -445,4 +445,87 @@ defmodule AprsmeWeb.MapLive.IndexTest do
|
||||||
assert html =~ "K5ABC" or html =~ "aprs-map"
|
assert html =~ "K5ABC" or html =~ "aprs-map"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "MapLive.Index zoom and map state changes" do
|
||||||
|
test "update_map_state crossing heat map threshold (high → low zoom)", %{conn: conn} do
|
||||||
|
{:ok, view, _html} = live(conn, "/?lat=40.5&lng=-98.5&z=10", on_error: :warn)
|
||||||
|
|
||||||
|
# Drop from zoom 10 → 6 — crosses the zoom-8 heat-map threshold.
|
||||||
|
assert render_hook(view, "update_map_state", %{
|
||||||
|
"center" => %{"lat" => 40.5, "lng" => -98.5},
|
||||||
|
"zoom" => 6
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
test "update_map_state crossing heat map threshold (low → high zoom)", %{conn: conn} do
|
||||||
|
{:ok, view, _html} = live(conn, "/?lat=40.5&lng=-98.5&z=5", on_error: :warn)
|
||||||
|
|
||||||
|
# Jump from zoom 5 → 12 — crosses the threshold in the other direction.
|
||||||
|
assert render_hook(view, "update_map_state", %{
|
||||||
|
"center" => %{"lat" => 40.5, "lng" => -98.5},
|
||||||
|
"zoom" => 12
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
test "update_map_state with string zoom value", %{conn: conn} do
|
||||||
|
{:ok, view, _html} = live(conn, "/", on_error: :warn)
|
||||||
|
|
||||||
|
assert render_hook(view, "update_map_state", %{
|
||||||
|
"center" => %{"lat" => "40.5", "lng" => "-98.5"},
|
||||||
|
"zoom" => "10"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
test "update_map_state clamps extreme zoom values", %{conn: conn} do
|
||||||
|
{:ok, view, _html} = live(conn, "/", on_error: :warn)
|
||||||
|
|
||||||
|
assert render_hook(view, "update_map_state", %{
|
||||||
|
"center" => %{"lat" => 0.0, "lng" => 0.0},
|
||||||
|
"zoom" => 99
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
test "bounds_changed with very zoomed-in bounds", %{conn: conn} do
|
||||||
|
{:ok, view, _html} = live(conn, "/", on_error: :warn)
|
||||||
|
|
||||||
|
assert render_hook(view, "bounds_changed", %{
|
||||||
|
"bounds" => %{
|
||||||
|
"north" => 40.75,
|
||||||
|
"south" => 40.74,
|
||||||
|
"east" => -73.98,
|
||||||
|
"west" => -73.99
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "MapLive.Index tracking flow" do
|
||||||
|
test "track_callsign with whitespace trims and uppercases", %{conn: conn} do
|
||||||
|
{:ok, view, _html} = live(conn, "/", on_error: :warn)
|
||||||
|
# Mixed case + whitespace — should be normalized.
|
||||||
|
assert render_hook(view, "track_callsign", %{"callsign" => " k5abc "})
|
||||||
|
end
|
||||||
|
|
||||||
|
test "clear_tracking works after starting tracking", %{conn: conn} do
|
||||||
|
{:ok, view, _html} = live(conn, "/", on_error: :warn)
|
||||||
|
render_hook(view, "track_callsign", %{"callsign" => "W1XYZ"})
|
||||||
|
assert render_hook(view, "clear_tracking", %{})
|
||||||
|
end
|
||||||
|
|
||||||
|
test "update_trail_duration with various values", %{conn: conn} do
|
||||||
|
{:ok, view, _html} = live(conn, "/", on_error: :warn)
|
||||||
|
|
||||||
|
for dur <- ["1", "2", "6", "12", "24"] do
|
||||||
|
assert render_hook(view, "update_trail_duration", %{"trail_duration" => dur})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "update_historical_hours with various values", %{conn: conn} do
|
||||||
|
{:ok, view, _html} = live(conn, "/", on_error: :warn)
|
||||||
|
|
||||||
|
for hrs <- ["1", "2", "6", "12", "24"] do
|
||||||
|
assert render_hook(view, "update_historical_hours", %{"historical_hours" => hrs})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue