From 4a4e25c08fb640f24e42cba83f031d01295eddc6 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 24 Apr 2026 09:51:06 -0500 Subject: [PATCH] test: cover InfoLive.Show path decode branches + position fallback --- .../live/info_live/show_full_render_test.exs | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/test/aprsme_web/live/info_live/show_full_render_test.exs b/test/aprsme_web/live/info_live/show_full_render_test.exs index be0ec47..559e42d 100644 --- a/test/aprsme_web/live/info_live/show_full_render_test.exs +++ b/test/aprsme_web/live/info_live/show_full_render_test.exs @@ -479,5 +479,63 @@ defmodule AprsmeWeb.InfoLive.ShowFullRenderTest do Process.sleep(50) assert render(lv) =~ "BC1" end + + test "fills in position from an earlier position-bearing packet when the latest has no lat/lon", + %{conn: conn} do + # Older packet with a position — this is what get_latest_position_packet + # should return. + _pos_packet = + packet_fixture(%{ + sender: "POSFILL", + base_callsign: "POSFILL", + ssid: "0", + received_at: DateTime.add(DateTime.utc_now(), -60, :second), + lat: Decimal.new("33.0"), + lon: Decimal.new("-96.0"), + has_position: true, + path: "WIDE1-1" + }) + + # A newer, non-position packet — for example a status packet. + # Set lat/lon to nil so the latest packet lacks coordinates, forcing + # get_latest_packet to fall back via get_latest_position_packet. + _status_packet = + packet_fixture(%{ + sender: "POSFILL", + base_callsign: "POSFILL", + ssid: "0", + received_at: DateTime.utc_now(), + lat: nil, + lon: nil, + has_position: false, + path: "WIDE1-1", + data_type: "status" + }) + + {:ok, _lv, html} = live(conn, ~p"/info/POSFILL", on_error: :warn) + assert html =~ "POSFILL" + end + + test "renders a packet with an extended path exercising decode_wide/trace/relay/tcpip branches", + %{conn: conn} do + # Covers the rare-variant decode clauses: WIDE3-1, WIDE4-1, WIDE1-2, + # TRACE2-1 through TRACE7-1, RELAY-1, RELAY-2, TCPIP, TCPIP*, and a + # generic TRACE8-8 fallthrough that exercises the catch-all clauses. + _packet = + packet_fixture(%{ + sender: "PATHZ", + base_callsign: "PATHZ", + ssid: "0", + received_at: DateTime.utc_now(), + lat: Decimal.new("33.0"), + lon: Decimal.new("-96.0"), + has_position: true, + path: + "WIDE3-1,WIDE4-1,WIDE5-1,WIDE6-1,WIDE7-1,WIDE1-2,WIDE2-2,TRACE2-1,TRACE3-1,TRACE4-1,TRACE5-1,TRACE6-1,TRACE7-1,TRACE8-8,RELAY-1,RELAY-2,RELAYX,TCPIP,TCPIP*,TCPIPX,qAC,T2TEXAS" + }) + + {:ok, _lv, html} = live(conn, ~p"/info/PATHZ", on_error: :warn) + assert html =~ "PATHZ" + end end end