faster tests

This commit is contained in:
Graham McIntire 2025-06-22 10:58:30 -05:00
parent a05ec4b32c
commit 81a9263b9f
No known key found for this signature in database
5 changed files with 19 additions and 15 deletions

View file

@ -27,6 +27,9 @@ config :aprs, AprsWeb.Endpoint,
# Disable Oban during tests to prevent background job execution
config :aprs, Oban, testing: :inline
# Disable initialize replay delay in test environment
config :aprs, :initialize_replay_delay, 0
# Configure the packets module to use the mock in tests
config :aprs, :packets_module, Aprs.PacketsMock

View file

@ -12,6 +12,7 @@ defmodule AprsWeb.MapLive.Index do
@default_center %{lat: 39.8283, lng: -98.5795}
@default_zoom 5
@finch_name Aprs.Finch
@initialize_replay_delay Application.compile_env(:aprs, :initialize_replay_delay, 500)
@impl true
def mount(_params, _session, socket) do
@ -214,7 +215,7 @@ defmodule AprsWeb.MapLive.Index do
socket = assign(socket, map_ready: true)
# Start historical replay
Process.send_after(self(), :initialize_replay, 500)
Process.send_after(self(), :initialize_replay, @initialize_replay_delay)
# If we have pending geolocation, zoom to it now
socket =

View file

@ -134,7 +134,7 @@ defmodule AprsWeb.Integration.AprsStatusTest do
Endpoint.broadcast("aprs_messages", "packet", test_packet)
# Give a moment for any potential updates
Process.sleep(100)
Process.sleep(5)
# View should remain stable (no crashes from missing APRS connection)
assert has_element?(view, "#aprs-map")

View file

@ -71,7 +71,7 @@ defmodule AprsWeb.MapLive.IndexTest do
assert render_hook(view, "map_ready", %{})
# Wait for the initialize_replay message to be processed
Process.sleep(600)
Process.sleep(20)
# The view should still be rendering without errors after loading historical packets
assert render(view) =~ "aprs-map"

View file

@ -105,7 +105,7 @@ defmodule Aprs.Integration.HistoricalPacketsTest do
# Set historical_hours assign
render_hook(view, "update_historical_hours", %{"historical_hours" => "1"})
Process.sleep(100)
Process.sleep(10)
# Set bounds and wait for map_bounds to be set in assigns
render_hook(view, "bounds_changed", bounds_params)
@ -121,11 +121,11 @@ defmodule Aprs.Integration.HistoricalPacketsTest do
}}
)
Process.sleep(100)
Process.sleep(10)
# Now trigger map_ready
render_hook(view, "map_ready", %{})
Process.sleep(1200)
Process.sleep(20)
# The LiveView should have pushed an event with historical packets
# Note: In real implementation, we'd need to verify the push_event was called
@ -153,7 +153,7 @@ defmodule Aprs.Integration.HistoricalPacketsTest do
# Set historical_hours assign
render_hook(view, "update_historical_hours", %{"historical_hours" => "1"})
Process.sleep(100)
Process.sleep(10)
# Set bounds and wait for map_bounds to be set in assigns
render_hook(view, "bounds_changed", bounds_params)
@ -169,11 +169,11 @@ defmodule Aprs.Integration.HistoricalPacketsTest do
}}
)
Process.sleep(100)
Process.sleep(10)
# Now trigger map_ready
render_hook(view, "map_ready", %{})
Process.sleep(1200)
Process.sleep(20)
verify!()
end
@ -222,7 +222,7 @@ defmodule Aprs.Integration.HistoricalPacketsTest do
# First load historical packets
render_hook(view, "map_ready", %{})
Process.sleep(700)
Process.sleep(20)
# Clear and reload markers
render_hook(view, "clear_and_reload_markers", %{})
@ -240,7 +240,7 @@ defmodule Aprs.Integration.HistoricalPacketsTest do
# Load historical packets first
render_hook(view, "map_ready", %{})
Process.sleep(700)
Process.sleep(20)
# Request location
render_hook(view, "locate_me", %{})
@ -304,13 +304,13 @@ defmodule Aprs.Integration.HistoricalPacketsTest do
}}
)
Process.sleep(100)
Process.sleep(10)
render_hook(view, "map_ready", %{})
Process.sleep(700)
Process.sleep(20)
# Set historical_hours assign
render_hook(view, "update_historical_hours", %{"historical_hours" => "1"})
Process.sleep(100)
Process.sleep(5)
# Simulate a new live packet for the same callsign
new_packet = %{
@ -341,7 +341,7 @@ defmodule Aprs.Integration.HistoricalPacketsTest do
})
# Give the LiveView time to process the message
Process.sleep(100)
Process.sleep(5)
verify!()
end