test: MapLive tracked-callsign filtering + trail duration cleanup
This commit is contained in:
parent
247c77a177
commit
e3a6a8268d
1 changed files with 62 additions and 0 deletions
|
|
@ -788,6 +788,68 @@ defmodule AprsmeWeb.MapLive.IndexTest do
|
|||
assert Process.alive?(view.pid)
|
||||
end
|
||||
|
||||
test "tracking a callsign then postgres_packet for the same callsign is processed", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, "/TRACKED1", on_error: :warn)
|
||||
|
||||
render_hook(view, "map_ready", %{})
|
||||
Process.sleep(30)
|
||||
|
||||
# Packet matching the tracked callsign — should process.
|
||||
packet = %{
|
||||
id: "pk-track",
|
||||
sender: "TRACKED1",
|
||||
base_callsign: "TRACKED1",
|
||||
ssid: "0",
|
||||
lat: 33.0,
|
||||
lon: -96.0,
|
||||
has_position: true,
|
||||
symbol_table_id: "/",
|
||||
symbol_code: ">",
|
||||
received_at: DateTime.utc_now(),
|
||||
path: ""
|
||||
}
|
||||
|
||||
send(view.pid, {:postgres_packet, packet})
|
||||
Process.sleep(30)
|
||||
assert Process.alive?(view.pid)
|
||||
end
|
||||
|
||||
test "tracking a callsign then postgres_packet for DIFFERENT callsign is dropped", %{
|
||||
conn: conn
|
||||
} do
|
||||
{:ok, view, _html} = live(conn, "/TRACKED2", on_error: :warn)
|
||||
|
||||
render_hook(view, "map_ready", %{})
|
||||
Process.sleep(30)
|
||||
|
||||
# Packet from a different sender — dropped.
|
||||
packet = %{
|
||||
id: "pk-other",
|
||||
sender: "NOTTRACKED",
|
||||
base_callsign: "NOT",
|
||||
ssid: "1",
|
||||
lat: 34.0,
|
||||
lon: -95.0,
|
||||
has_position: true,
|
||||
symbol_table_id: "/",
|
||||
symbol_code: ">",
|
||||
received_at: DateTime.utc_now(),
|
||||
path: ""
|
||||
}
|
||||
|
||||
send(view.pid, {:postgres_packet, packet})
|
||||
Process.sleep(30)
|
||||
assert Process.alive?(view.pid)
|
||||
end
|
||||
|
||||
test "update_trail_duration triggers cleanup_old_packets", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, "/", on_error: :warn)
|
||||
|
||||
render_hook(view, "update_trail_duration", %{"trail_duration" => "6"})
|
||||
Process.sleep(30)
|
||||
assert Process.alive?(view.pid)
|
||||
end
|
||||
|
||||
test "invalid bounds (north <= south) is rejected silently", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, "/", on_error: :warn)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue