test: InfoLive.Show broadcast paths with position change

This commit is contained in:
Graham McIntire 2026-04-23 18:18:25 -05:00
parent f102c24bca
commit bdcba9b18e
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -146,6 +146,91 @@ defmodule AprsmeWeb.InfoLive.ShowFullRenderTest do
assert html =~ "NOPATH"
end
test "posts a broadcast that triggers a position change", %{conn: conn} do
_packet =
packet_fixture(%{
sender: "MOVED",
base_callsign: "MOVED",
ssid: "0",
received_at: DateTime.utc_now(),
lat: Decimal.new("33.0"),
lon: Decimal.new("-96.0"),
has_position: true,
path: ""
})
{:ok, lv, _html} = live(conn, ~p"/info/MOVED", on_error: :warn)
# Insert a newer packet with a significantly different position.
_new_packet =
packet_fixture(%{
sender: "MOVED",
base_callsign: "MOVED",
ssid: "0",
received_at: DateTime.add(DateTime.utc_now(), 1, :second),
lat: Decimal.new("34.0"),
lon: Decimal.new("-95.0"),
has_position: true,
path: ""
})
send(lv.pid, {:postgres_packet, %{sender: "MOVED"}})
Process.sleep(30)
assert render(lv) =~ "MOVED"
end
test "posts a broadcast without position change keeps neighbors intact", %{conn: conn} do
_packet =
packet_fixture(%{
sender: "STILL",
base_callsign: "STILL",
ssid: "0",
received_at: DateTime.utc_now(),
lat: Decimal.new("33.0"),
lon: Decimal.new("-96.0"),
has_position: true,
path: ""
})
{:ok, lv, _html} = live(conn, ~p"/info/STILL", on_error: :warn)
# Another packet with the SAME position — position_changed? returns false.
_new_packet =
packet_fixture(%{
sender: "STILL",
base_callsign: "STILL",
ssid: "0",
received_at: DateTime.add(DateTime.utc_now(), 1, :second),
lat: Decimal.new("33.0"),
lon: Decimal.new("-96.0"),
has_position: true,
path: ""
})
send(lv.pid, {:postgres_packet, %{sender: "STILL"}})
Process.sleep(30)
assert render(lv) =~ "STILL"
end
test "ignores unknown messages without crashing", %{conn: conn} do
_packet =
packet_fixture(%{
sender: "UNK",
base_callsign: "UNK",
ssid: "0",
received_at: DateTime.utc_now(),
lat: Decimal.new("33.0"),
lon: Decimal.new("-96.0"),
has_position: true
})
{:ok, lv, _html} = live(conn, ~p"/info/UNK", on_error: :warn)
send(lv.pid, :some_arbitrary_message)
Process.sleep(20)
assert Process.alive?(lv.pid)
end
test "posts a postgres_packet broadcast to InfoLive.Show without crashing", %{conn: conn} do
_packet =
packet_fixture(%{