fix: Update tests and normalize callsigns for new URL structure

- Update callsign view tests to use LiveView instead of redirect assertions
- Normalize callsigns to uppercase when extracting from path params
- Handle empty/nil callsigns gracefully in mount function
- Tests now verify map display rather than redirect behavior

All tests now pass with the new direct station URL implementation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Graham McIntire 2025-07-30 13:09:24 -05:00
parent 24382f5993
commit 2584fdf87b
No known key found for this signature in database
2 changed files with 25 additions and 15 deletions

View file

@ -63,7 +63,12 @@ defmodule AprsmeWeb.MapLive.Index do
socket = setup_additional_subscriptions(socket) socket = setup_additional_subscriptions(socket)
# Handle callsign tracking - check path params first, then query params # Handle callsign tracking - check path params first, then query params
tracked_callsign = Map.get(params, "callsign", Map.get(params, "call", "")) tracked_callsign =
case Map.get(params, "callsign", Map.get(params, "call", "")) do
"" -> ""
nil -> ""
callsign -> callsign |> String.trim() |> String.upcase()
end
{final_map_center, final_map_zoom} = {final_map_center, final_map_zoom} =
Navigation.handle_callsign_tracking( Navigation.handle_callsign_tracking(

View file

@ -1,27 +1,32 @@
defmodule AprsmeWeb.MapLive.CallsignViewTest do defmodule AprsmeWeb.MapLive.CallsignViewTest do
use AprsmeWeb.ConnCase use AprsmeWeb.ConnCase
import Phoenix.ConnTest import Phoenix.LiveViewTest
describe "CallsignView redirects" do describe "CallsignView displays map for callsign" do
test "redirects to main map with call parameter", %{conn: conn} do test "displays map with callsign in path", %{conn: conn} do
conn = get(conn, "/W5ISP-9") {:ok, view, _html} = live(conn, "/W5ISP-9")
assert redirected_to(conn) == "/?call=W5ISP-9" assert has_element?(view, "#aprs-map")
assert render(view) =~ "W5ISP-9"
end end
test "redirects lowercase callsigns", %{conn: conn} do test "handles lowercase callsigns", %{conn: conn} do
conn = get(conn, "/w5isp-9") {:ok, view, _html} = live(conn, "/w5isp-9")
assert redirected_to(conn) == "/?call=w5isp-9" assert has_element?(view, "#aprs-map")
# Callsigns are normalized to uppercase
assert render(view) =~ "W5ISP-9"
end end
test "redirects callsign without SSID", %{conn: conn} do test "handles callsign without SSID", %{conn: conn} do
conn = get(conn, "/W5ISP") {:ok, view, _html} = live(conn, "/W5ISP")
assert redirected_to(conn) == "/?call=W5ISP" assert has_element?(view, "#aprs-map")
assert render(view) =~ "W5ISP"
end end
test "redirects special characters in callsign", %{conn: conn} do test "handles special characters in callsign", %{conn: conn} do
conn = get(conn, "/TEST-123") {:ok, view, _html} = live(conn, "/TEST-123")
assert redirected_to(conn) == "/?call=TEST-123" assert has_element?(view, "#aprs-map")
assert render(view) =~ "TEST-123"
end end
end end
end end