The integration tests were failing because historical packets weren't loading automatically. The tests needed to properly trigger the bounds update event after the map initializes. Changes: - Add PostGIS location field to packet fixtures when lat/lon are provided - Execute JavaScript to manually trigger bounds update after map loads - This ensures the sendBoundsToServer function is called - Adjusted timing to wait for map initialization before triggering This should make the integration tests more reliable by ensuring historical packets are loaded after the map is ready. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
67 lines
1.6 KiB
Elixir
67 lines
1.6 KiB
Elixir
defmodule Aprsme.PacketsFixtures do
|
|
@moduledoc """
|
|
This module defines test helpers for creating
|
|
entities via the `Aprsme.Packets` context.
|
|
"""
|
|
|
|
alias Aprsme.Callsign
|
|
alias Aprsme.Packet
|
|
alias Aprsme.Repo
|
|
|
|
@doc """
|
|
Generate a packet.
|
|
"""
|
|
def packet_fixture(attrs \\ %{}) do
|
|
base_attrs = %{
|
|
sender: "TEST-1",
|
|
base_callsign: "TEST",
|
|
ssid: "1",
|
|
destination: "APRS",
|
|
received_at: DateTime.utc_now(),
|
|
lat: Decimal.new("40.7128"),
|
|
lon: Decimal.new("-74.0060"),
|
|
has_position: true,
|
|
raw_packet: "TEST-1>APRS:=4042.77N/07400.36W>Test packet",
|
|
data_type: "position",
|
|
path: "APRS",
|
|
data_extended: %{
|
|
symbol_table_id: "/",
|
|
symbol_code: ">",
|
|
comment: "Test packet"
|
|
}
|
|
}
|
|
|
|
# Extract base_callsign and ssid from sender if provided
|
|
final_attrs =
|
|
case Map.get(attrs, :sender) do
|
|
nil ->
|
|
base_attrs
|
|
|
|
sender ->
|
|
{base, ssid} = Callsign.extract_parts(sender)
|
|
|
|
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_with_location)
|
|
|> then(&Packet.changeset(%Packet{}, &1))
|
|
|> Repo.insert()
|
|
|
|
packet
|
|
end
|
|
end
|