test: integration tests for spatial_packet and packet_batch paths

This commit is contained in:
Graham McIntire 2026-04-23 17:39:36 -05:00
parent b085c8fcdb
commit 001303d17c
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -79,5 +79,83 @@ defmodule AprsmeWeb.MapLive.IntegrationTest do
{:ok, _view, html} = live(conn, "/PATH1", on_error: :warn)
assert html =~ "aprs-map"
end
test "spatial_packet arriving for an in-bounds callsign triggers display", %{conn: conn} do
{:ok, view, _html} = live(conn, "/?lat=33.0&lng=-96.0&z=12", on_error: :warn)
render_hook(view, "bounds_changed", %{
"bounds" => %{
"north" => 34.0,
"south" => 32.0,
"east" => -95.0,
"west" => -97.0
}
})
packet = %{
id: "sp-1",
sender: "SP-1",
base_callsign: "SP",
ssid: "1",
lat: 33.0,
lon: -96.0,
has_position: true,
symbol_table_id: "/",
symbol_code: ">",
received_at: DateTime.utc_now(),
path: "WIDE1-1",
comment: "in bounds"
}
send(view.pid, {:spatial_packet, packet})
Process.sleep(50)
assert render(view) =~ "aprs-map"
end
test "handles a batch of packets including out-of-bounds ones", %{conn: conn} do
{:ok, view, _html} = live(conn, "/?lat=33.0&lng=-96.0&z=12", on_error: :warn)
render_hook(view, "bounds_changed", %{
"bounds" => %{
"north" => 34.0,
"south" => 32.0,
"east" => -95.0,
"west" => -97.0
}
})
packets = [
%{
id: "b-1",
sender: "IN-1",
base_callsign: "IN",
ssid: "1",
lat: 33.5,
lon: -96.0,
has_position: true,
symbol_table_id: "/",
symbol_code: ">",
received_at: DateTime.utc_now(),
path: ""
},
%{
id: "b-2",
sender: "OUT-1",
base_callsign: "OUT",
ssid: "1",
lat: 50.0,
lon: -80.0,
has_position: true,
symbol_table_id: "/",
symbol_code: ">",
received_at: DateTime.utc_now(),
path: ""
}
]
send(view.pid, {:packet_batch, packets})
Process.sleep(50)
assert render(view) =~ "aprs-map"
end
end
end