test: MapLive tracked callsign render + deployment_events broadcast

This commit is contained in:
Graham McIntire 2026-04-24 08:12:53 -05:00
parent 1d22e6e59b
commit 5bb9b05e31
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -681,6 +681,57 @@ defmodule AprsmeWeb.MapLive.IndexTest do
assert render_hook(view, "update_callsign", %{"callsign" => "N0CALL"})
end
test "tracked callsign with a latest packet renders other_ssids list", %{conn: conn} do
import Aprsme.PacketsFixtures
now = DateTime.utc_now()
_p =
packet_fixture(%{
sender: "TRACKME-7",
base_callsign: "TRACKME",
ssid: "7",
received_at: now,
lat: Decimal.new("33.0"),
lon: Decimal.new("-96.5"),
has_position: true
})
_p2 =
packet_fixture(%{
sender: "TRACKME-9",
base_callsign: "TRACKME",
ssid: "9",
received_at: DateTime.add(now, -60, :second),
lat: Decimal.new("33.1"),
lon: Decimal.new("-96.6"),
has_position: true
})
{:ok, _view, html} = live(conn, "/TRACKME-7", on_error: :warn)
assert html =~ "TRACKME"
end
test "deployment_events broadcast updates deployed_at", %{conn: conn} do
{:ok, view, _html} = live(conn, "/", on_error: :warn)
deploy_time = DateTime.utc_now()
# Send the deployment broadcast as a Phoenix.Socket.Broadcast (what the
# PubSub subscriber receives in the real system).
send(
view.pid,
%Phoenix.Socket.Broadcast{
topic: "deployment_events",
event: "new_deployment",
payload: {:new_deployment, %{deployed_at: deploy_time}}
}
)
Process.sleep(20)
assert Process.alive?(view.pid)
end
test "handles drain_connections with small to_drain value", %{conn: conn} do
{:ok, view, _html} = live(conn, "/", on_error: :warn)