faster tests
This commit is contained in:
parent
a05ec4b32c
commit
81a9263b9f
5 changed files with 19 additions and 15 deletions
|
|
@ -27,6 +27,9 @@ config :aprs, AprsWeb.Endpoint,
|
||||||
# Disable Oban during tests to prevent background job execution
|
# Disable Oban during tests to prevent background job execution
|
||||||
config :aprs, Oban, testing: :inline
|
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
|
# Configure the packets module to use the mock in tests
|
||||||
config :aprs, :packets_module, Aprs.PacketsMock
|
config :aprs, :packets_module, Aprs.PacketsMock
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ defmodule AprsWeb.MapLive.Index do
|
||||||
@default_center %{lat: 39.8283, lng: -98.5795}
|
@default_center %{lat: 39.8283, lng: -98.5795}
|
||||||
@default_zoom 5
|
@default_zoom 5
|
||||||
@finch_name Aprs.Finch
|
@finch_name Aprs.Finch
|
||||||
|
@initialize_replay_delay Application.compile_env(:aprs, :initialize_replay_delay, 500)
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def mount(_params, _session, socket) do
|
def mount(_params, _session, socket) do
|
||||||
|
|
@ -214,7 +215,7 @@ defmodule AprsWeb.MapLive.Index do
|
||||||
socket = assign(socket, map_ready: true)
|
socket = assign(socket, map_ready: true)
|
||||||
|
|
||||||
# Start historical replay
|
# 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
|
# If we have pending geolocation, zoom to it now
|
||||||
socket =
|
socket =
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ defmodule AprsWeb.Integration.AprsStatusTest do
|
||||||
Endpoint.broadcast("aprs_messages", "packet", test_packet)
|
Endpoint.broadcast("aprs_messages", "packet", test_packet)
|
||||||
|
|
||||||
# Give a moment for any potential updates
|
# Give a moment for any potential updates
|
||||||
Process.sleep(100)
|
Process.sleep(5)
|
||||||
|
|
||||||
# View should remain stable (no crashes from missing APRS connection)
|
# View should remain stable (no crashes from missing APRS connection)
|
||||||
assert has_element?(view, "#aprs-map")
|
assert has_element?(view, "#aprs-map")
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ defmodule AprsWeb.MapLive.IndexTest do
|
||||||
assert render_hook(view, "map_ready", %{})
|
assert render_hook(view, "map_ready", %{})
|
||||||
|
|
||||||
# Wait for the initialize_replay message to be processed
|
# 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
|
# The view should still be rendering without errors after loading historical packets
|
||||||
assert render(view) =~ "aprs-map"
|
assert render(view) =~ "aprs-map"
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ defmodule Aprs.Integration.HistoricalPacketsTest do
|
||||||
|
|
||||||
# Set historical_hours assign
|
# Set historical_hours assign
|
||||||
render_hook(view, "update_historical_hours", %{"historical_hours" => "1"})
|
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
|
# Set bounds and wait for map_bounds to be set in assigns
|
||||||
render_hook(view, "bounds_changed", bounds_params)
|
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
|
# Now trigger map_ready
|
||||||
render_hook(view, "map_ready", %{})
|
render_hook(view, "map_ready", %{})
|
||||||
Process.sleep(1200)
|
Process.sleep(20)
|
||||||
|
|
||||||
# The LiveView should have pushed an event with historical packets
|
# The LiveView should have pushed an event with historical packets
|
||||||
# Note: In real implementation, we'd need to verify the push_event was called
|
# 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
|
# Set historical_hours assign
|
||||||
render_hook(view, "update_historical_hours", %{"historical_hours" => "1"})
|
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
|
# Set bounds and wait for map_bounds to be set in assigns
|
||||||
render_hook(view, "bounds_changed", bounds_params)
|
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
|
# Now trigger map_ready
|
||||||
render_hook(view, "map_ready", %{})
|
render_hook(view, "map_ready", %{})
|
||||||
Process.sleep(1200)
|
Process.sleep(20)
|
||||||
|
|
||||||
verify!()
|
verify!()
|
||||||
end
|
end
|
||||||
|
|
@ -222,7 +222,7 @@ defmodule Aprs.Integration.HistoricalPacketsTest do
|
||||||
|
|
||||||
# First load historical packets
|
# First load historical packets
|
||||||
render_hook(view, "map_ready", %{})
|
render_hook(view, "map_ready", %{})
|
||||||
Process.sleep(700)
|
Process.sleep(20)
|
||||||
|
|
||||||
# Clear and reload markers
|
# Clear and reload markers
|
||||||
render_hook(view, "clear_and_reload_markers", %{})
|
render_hook(view, "clear_and_reload_markers", %{})
|
||||||
|
|
@ -240,7 +240,7 @@ defmodule Aprs.Integration.HistoricalPacketsTest do
|
||||||
|
|
||||||
# Load historical packets first
|
# Load historical packets first
|
||||||
render_hook(view, "map_ready", %{})
|
render_hook(view, "map_ready", %{})
|
||||||
Process.sleep(700)
|
Process.sleep(20)
|
||||||
|
|
||||||
# Request location
|
# Request location
|
||||||
render_hook(view, "locate_me", %{})
|
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", %{})
|
render_hook(view, "map_ready", %{})
|
||||||
Process.sleep(700)
|
Process.sleep(20)
|
||||||
|
|
||||||
# Set historical_hours assign
|
# Set historical_hours assign
|
||||||
render_hook(view, "update_historical_hours", %{"historical_hours" => "1"})
|
render_hook(view, "update_historical_hours", %{"historical_hours" => "1"})
|
||||||
Process.sleep(100)
|
Process.sleep(5)
|
||||||
|
|
||||||
# Simulate a new live packet for the same callsign
|
# Simulate a new live packet for the same callsign
|
||||||
new_packet = %{
|
new_packet = %{
|
||||||
|
|
@ -341,7 +341,7 @@ defmodule Aprs.Integration.HistoricalPacketsTest do
|
||||||
})
|
})
|
||||||
|
|
||||||
# Give the LiveView time to process the message
|
# Give the LiveView time to process the message
|
||||||
Process.sleep(100)
|
Process.sleep(5)
|
||||||
|
|
||||||
verify!()
|
verify!()
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue