diff --git a/test/integration/historical_loading_integration_test.exs b/test/integration/historical_loading_integration_test.exs index 63e4006..6b3256d 100644 --- a/test/integration/historical_loading_integration_test.exs +++ b/test/integration/historical_loading_integration_test.exs @@ -68,8 +68,21 @@ defmodule AprsmeWeb.HistoricalLoadingIntegrationTest do |> visit("/?lat=40.735&lon=-73.996&zoom=11") |> assert_has(css("#aprs-map")) - # Wait for map to initialize and markers to appear - # The map should automatically load historical packets + # Wait for map to initialize + Process.sleep(2000) + + # Ensure map has initialized and trigger bounds update + execute_script(session, """ + if (window.aprsMap && window.aprsMap.map) { + // Trigger bounds_changed event to load historical packets + const bounds = window.aprsMap.map.getBounds(); + if (bounds && window.APRSMap && window.APRSMap.prototype.sendBoundsToServer) { + window.APRSMap.prototype.sendBoundsToServer.call(window.aprsMap); + } + } + """) + + # Wait for historical packets to load Process.sleep(3000) # Check that markers are present on the map diff --git a/test/support/fixtures/packets_fixtures.ex b/test/support/fixtures/packets_fixtures.ex index 1f88dbc..521d1e6 100644 --- a/test/support/fixtures/packets_fixtures.ex +++ b/test/support/fixtures/packets_fixtures.ex @@ -43,9 +43,22 @@ defmodule Aprsme.PacketsFixtures do Map.merge(base_attrs, %{base_callsign: base, ssid: ssid}) end + # Ensure location is set if lat/lon are provided + final_attrs_with_location = + if final_attrs[:lat] && final_attrs[:lon] do + location = %Geo.Point{ + coordinates: {Decimal.to_float(final_attrs[:lon]), Decimal.to_float(final_attrs[:lat])}, + srid: 4326 + } + + Map.put(final_attrs, :location, location) + else + final_attrs + end + {:ok, packet} = attrs - |> Enum.into(final_attrs) + |> Enum.into(final_attrs_with_location) |> then(&Packet.changeset(%Packet{}, &1)) |> Repo.insert()