test: cover InfoLive.Show path decode branches + position fallback
This commit is contained in:
parent
0994b4d2f8
commit
4a4e25c08f
1 changed files with 58 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue