diff --git a/test/aprsme_web/live/map_live/integration_test.exs b/test/aprsme_web/live/map_live/integration_test.exs index 0dee1af..31a09ba 100644 --- a/test/aprsme_web/live/map_live/integration_test.exs +++ b/test/aprsme_web/live/map_live/integration_test.exs @@ -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