From da0b65ca1e64b0f5506af449a74634640cc55373 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 3 Aug 2025 09:33:26 -0500 Subject: [PATCH] fix: Add missing database sandbox setup to historical loading integration tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The integration tests were failing in CI with DBConnection.OwnershipError because they were missing the required Ecto.Adapters.SQL.Sandbox setup. Changes: - Added proper sandbox checkout and shared mode configuration - Fixed incorrect CSS selector (#map -> #aprs-map) - Configured tests to use real Packets module instead of mocks - Ensured database connections are properly managed in Wallaby tests This matches the setup pattern used in other integration tests and resolves the CI failures. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../historical_loading_integration_test.exs | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/test/integration/historical_loading_integration_test.exs b/test/integration/historical_loading_integration_test.exs index 0fa0fc3..249ea3d 100644 --- a/test/integration/historical_loading_integration_test.exs +++ b/test/integration/historical_loading_integration_test.exs @@ -10,6 +10,25 @@ defmodule AprsmeWeb.HistoricalLoadingIntegrationTest do import Wallaby.Browser import Wallaby.Query + alias Aprsme.Repo + alias Ecto.Adapters.SQL.Sandbox + + setup do + :ok = Sandbox.checkout(Repo) + # Use shared mode for Wallaby tests + Sandbox.mode(Repo, {:shared, self()}) + + # Use real Packets module for integration tests + Application.put_env(:aprsme, :packets_module, Aprsme.Packets) + + on_exit(fn -> + # Restore mock for other tests + Application.put_env(:aprsme, :packets_module, Aprsme.PacketsMock) + end) + + {:ok, %{}} + end + describe "historical packet loading on page load" do @describetag :integration feature "displays historical packets immediately after map loads", %{session: session} do @@ -45,7 +64,7 @@ defmodule AprsmeWeb.HistoricalLoadingIntegrationTest do # Navigate to the map session |> visit("/") - |> assert_has(css("#map", text: "")) + |> assert_has(css("#aprs-map")) # Wait for map to initialize and markers to appear # The map should automatically load historical packets @@ -104,7 +123,7 @@ defmodule AprsmeWeb.HistoricalLoadingIntegrationTest do # Navigate to map with 1 hour historical range (default) session |> visit("/?hist=1") - |> assert_has(css("#map")) + |> assert_has(css("#aprs-map")) # Wait for historical loading Process.sleep(3000) @@ -121,7 +140,7 @@ defmodule AprsmeWeb.HistoricalLoadingIntegrationTest do session # 6 hours |> visit("/?hist=6") - |> assert_has(css("#map")) + |> assert_has(css("#aprs-map")) Process.sleep(3000) @@ -163,7 +182,7 @@ defmodule AprsmeWeb.HistoricalLoadingIntegrationTest do # Start focused on NYC session |> visit("/?lat=40.7128&lng=-74.0060&z=10") - |> assert_has(css("#map")) + |> assert_has(css("#aprs-map")) Process.sleep(3000) @@ -231,7 +250,7 @@ defmodule AprsmeWeb.HistoricalLoadingIntegrationTest do # Navigate to tracked callsign URL session |> visit("/TRACK1-9") - |> assert_has(css("#map")) + |> assert_has(css("#aprs-map")) # Wait for map to load and center on latest position Process.sleep(3000)