Fix connection status display in tests

When APRS connection is disabled (in test environment), the LiveView should
show 'disconnected' status instead of hardcoded 'connected'. This fixes the
failing aprs_status_test.

Add get_initial_connection_status/0 helper that checks the
disable_aprs_connection config to set the appropriate initial status.
This commit is contained in:
Graham McIntire 2025-10-25 17:45:17 -05:00
parent 2a310c6685
commit f211559d93
No known key found for this signature in database

View file

@ -225,11 +225,17 @@ defmodule AprsmeWeb.MapLive.Index do
pending_batch_tasks: [],
# Add missing assigns for components
loading: false,
connection_status: "connected",
connection_status: get_initial_connection_status(),
show_all_packets: true
)
end
defp get_initial_connection_status do
# Check if APRS connection is disabled
connection_disabled = Application.get_env(:aprsme, :disable_aprs_connection, false)
if connection_disabled, do: "disconnected", else: "connected"
end
@spec assign_defaults(Socket.t(), DateTime.t()) :: Socket.t()
defp assign_defaults(socket, one_hour_ago) do
assign(socket,
@ -267,7 +273,7 @@ defmodule AprsmeWeb.MapLive.Index do
last_update_at: DateTime.utc_now(),
# Add missing assigns for components
loading: false,
connection_status: "connected",
connection_status: get_initial_connection_status(),
show_all_packets: true
)
end