test: InfoLive.Show broadcast paths with position change
This commit is contained in:
parent
f102c24bca
commit
bdcba9b18e
1 changed files with 85 additions and 0 deletions
|
|
@ -146,6 +146,91 @@ defmodule AprsmeWeb.InfoLive.ShowFullRenderTest do
|
||||||
assert html =~ "NOPATH"
|
assert html =~ "NOPATH"
|
||||||
end
|
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
|
test "posts a postgres_packet broadcast to InfoLive.Show without crashing", %{conn: conn} do
|
||||||
_packet =
|
_packet =
|
||||||
packet_fixture(%{
|
packet_fixture(%{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue