From 2584fdf87bd85ec6f1589212f27254050e8ecd66 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 30 Jul 2025 13:09:24 -0500 Subject: [PATCH] fix: Update tests and normalize callsigns for new URL structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- lib/aprsme_web/live/map_live/index.ex | 7 +++- .../live/map_live/callsign_view_test.exs | 33 +++++++++++-------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/lib/aprsme_web/live/map_live/index.ex b/lib/aprsme_web/live/map_live/index.ex index ddfb8c0..f9fb069 100644 --- a/lib/aprsme_web/live/map_live/index.ex +++ b/lib/aprsme_web/live/map_live/index.ex @@ -63,7 +63,12 @@ defmodule AprsmeWeb.MapLive.Index do socket = setup_additional_subscriptions(socket) # 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} = Navigation.handle_callsign_tracking( diff --git a/test/aprsme_web/live/map_live/callsign_view_test.exs b/test/aprsme_web/live/map_live/callsign_view_test.exs index 9933c62..9d2806b 100644 --- a/test/aprsme_web/live/map_live/callsign_view_test.exs +++ b/test/aprsme_web/live/map_live/callsign_view_test.exs @@ -1,27 +1,32 @@ defmodule AprsmeWeb.MapLive.CallsignViewTest do use AprsmeWeb.ConnCase - import Phoenix.ConnTest + import Phoenix.LiveViewTest - describe "CallsignView redirects" do - test "redirects to main map with call parameter", %{conn: conn} do - conn = get(conn, "/W5ISP-9") - assert redirected_to(conn) == "/?call=W5ISP-9" + describe "CallsignView displays map for callsign" do + test "displays map with callsign in path", %{conn: conn} do + {:ok, view, _html} = live(conn, "/W5ISP-9") + assert has_element?(view, "#aprs-map") + assert render(view) =~ "W5ISP-9" end - test "redirects lowercase callsigns", %{conn: conn} do - conn = get(conn, "/w5isp-9") - assert redirected_to(conn) == "/?call=w5isp-9" + test "handles lowercase callsigns", %{conn: conn} do + {:ok, view, _html} = live(conn, "/w5isp-9") + assert has_element?(view, "#aprs-map") + # Callsigns are normalized to uppercase + assert render(view) =~ "W5ISP-9" end - test "redirects callsign without SSID", %{conn: conn} do - conn = get(conn, "/W5ISP") - assert redirected_to(conn) == "/?call=W5ISP" + test "handles callsign without SSID", %{conn: conn} do + {:ok, view, _html} = live(conn, "/W5ISP") + assert has_element?(view, "#aprs-map") + assert render(view) =~ "W5ISP" end - test "redirects special characters in callsign", %{conn: conn} do - conn = get(conn, "/TEST-123") - assert redirected_to(conn) == "/?call=TEST-123" + test "handles special characters in callsign", %{conn: conn} do + {:ok, view, _html} = live(conn, "/TEST-123") + assert has_element?(view, "#aprs-map") + assert render(view) =~ "TEST-123" end end end