test: add MapLive.Index integration tests with real DB packets
This commit is contained in:
parent
33cc390e65
commit
dac0198825
1 changed files with 83 additions and 0 deletions
83
test/aprsme_web/live/map_live/integration_test.exs
Normal file
83
test/aprsme_web/live/map_live/integration_test.exs
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
defmodule AprsmeWeb.MapLive.IntegrationTest do
|
||||||
|
use AprsmeWeb.ConnCase
|
||||||
|
|
||||||
|
import Aprsme.PacketsFixtures
|
||||||
|
import Phoenix.LiveViewTest
|
||||||
|
|
||||||
|
describe "MapLive.Index with real packet data" do
|
||||||
|
test "renders a map with pre-existing packets and simulates bounds_changed", %{conn: conn} do
|
||||||
|
# Seed some packets in the bounds we'll scroll to.
|
||||||
|
now = DateTime.utc_now()
|
||||||
|
|
||||||
|
for i <- 1..3 do
|
||||||
|
packet_fixture(%{
|
||||||
|
sender: "INT#{i}",
|
||||||
|
base_callsign: "INT#{i}",
|
||||||
|
ssid: "0",
|
||||||
|
received_at: DateTime.add(now, -i * 60, :second),
|
||||||
|
lat: Decimal.new("#{40 + i * 0.01}"),
|
||||||
|
lon: Decimal.new("#{-74 - i * 0.01}"),
|
||||||
|
has_position: true,
|
||||||
|
path: "WIDE1-1"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
{:ok, view, _html} = live(conn, "/?lat=40.0&lng=-74.0&z=11", on_error: :warn)
|
||||||
|
|
||||||
|
# Fire a bounds_changed event covering the seeded region.
|
||||||
|
bounds = %{
|
||||||
|
"bounds" => %{
|
||||||
|
"north" => 41.0,
|
||||||
|
"south" => 39.5,
|
||||||
|
"east" => -73.0,
|
||||||
|
"west" => -74.5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert render_hook(view, "bounds_changed", bounds)
|
||||||
|
assert render_hook(view, "map_ready", %{})
|
||||||
|
|
||||||
|
# Allow async historical loading to run.
|
||||||
|
Process.sleep(100)
|
||||||
|
html = render(view)
|
||||||
|
assert html =~ "aprs-map"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "tracks a callsign that has a real packet", %{conn: conn} do
|
||||||
|
_packet =
|
||||||
|
packet_fixture(%{
|
||||||
|
sender: "TRACKME",
|
||||||
|
base_callsign: "TRACKME",
|
||||||
|
ssid: "0",
|
||||||
|
received_at: DateTime.utc_now(),
|
||||||
|
lat: Decimal.new("33.0"),
|
||||||
|
lon: Decimal.new("-96.5"),
|
||||||
|
has_position: true,
|
||||||
|
path: "WIDE1-1"
|
||||||
|
})
|
||||||
|
|
||||||
|
{:ok, view, _html} = live(conn, "/?call=TRACKME", on_error: :warn)
|
||||||
|
assert render_hook(view, "map_ready", %{})
|
||||||
|
Process.sleep(100)
|
||||||
|
html = render(view)
|
||||||
|
assert html =~ "TRACKME" or html =~ "aprs-map"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "callsign path route loads the tracked callsign", %{conn: conn} do
|
||||||
|
_packet =
|
||||||
|
packet_fixture(%{
|
||||||
|
sender: "PATH1",
|
||||||
|
base_callsign: "PATH1",
|
||||||
|
ssid: "0",
|
||||||
|
received_at: DateTime.utc_now(),
|
||||||
|
lat: Decimal.new("35.0"),
|
||||||
|
lon: Decimal.new("-90.0"),
|
||||||
|
has_position: true,
|
||||||
|
path: "WIDE1-1"
|
||||||
|
})
|
||||||
|
|
||||||
|
{:ok, _view, html} = live(conn, "/PATH1", on_error: :warn)
|
||||||
|
assert html =~ "aprs-map"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Reference in a new issue