test: HistoricalLoader RF path + low-zoom heat map paths

This commit is contained in:
Graham McIntire 2026-04-24 08:32:28 -05:00
parent c8a182a3b9
commit c264a9bc3d
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -312,6 +312,83 @@ defmodule AprsmeWeb.MapLive.HistoricalLoaderTest do
end
end
describe "tracking a callsign drives maybe_include_latest_packet and RF path loading" do
test "first batch with a tracked callsign + packets triggers RF path scheduling" do
now = DateTime.utc_now()
Mox.stub(Aprsme.PacketsMock, :get_recent_packets, fn _opts ->
[
%{
id: "rf-1",
sender: "RFME-1",
base_callsign: "RFME",
ssid: "1",
lat: 33.5,
lon: -96.5,
has_position: true,
symbol_table_id: "/",
symbol_code: ">",
received_at: now,
path: "K5ABC-1*,WIDE1-1"
}
]
end)
socket =
build_socket(%{
map_bounds: %{north: 34.0, south: 32.0, east: -95.0, west: -97.0},
map_zoom: 10,
tracked_callsign: "RFME-1",
historical_loading: true,
loading_generation: 1
})
_ = HistoricalLoader.load_historical_batch(socket, 0, nil)
# RF path scheduling sends a :load_rf_path_station_packets after 100ms.
# Wait a bit, then check the mailbox.
Process.sleep(120)
assert_received {:load_rf_path_station_packets, _stations}
end
end
describe "low zoom with packets path" do
test "low zoom accumulates historical_packets without pushing markers" do
now = DateTime.utc_now()
Mox.stub(Aprsme.PacketsMock, :get_recent_packets, fn _opts ->
[
%{
id: "lz-1",
sender: "LZ1",
base_callsign: "LZ",
ssid: "1",
lat: 33.5,
lon: -96.5,
has_position: true,
symbol_table_id: "/",
symbol_code: ">",
received_at: now,
path: ""
}
]
end)
socket =
build_socket(%{
map_bounds: %{north: 34.0, south: 32.0, east: -95.0, west: -97.0},
# zoom <= 8 uses heat map path.
map_zoom: 5,
historical_loading: true,
loading_generation: 1,
total_batches: 3
})
result = HistoricalLoader.load_historical_batch(socket, 0, nil)
# Packet should be merged into historical_packets map.
assert map_size(result.assigns.historical_packets) >= 1
end
end
describe "max packets-for-zoom limit" do
test "finishes loading when batch_offset * batch_size exceeds zoom limit" do
# At zoom 10, limit=1500, batch_size=500. A batch_offset of 3 exceeds