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:
parent
24382f5993
commit
2584fdf87b
2 changed files with 25 additions and 15 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue