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:
parent
2a310c6685
commit
f211559d93
1 changed files with 8 additions and 2 deletions
|
|
@ -225,11 +225,17 @@ defmodule AprsmeWeb.MapLive.Index do
|
||||||
pending_batch_tasks: [],
|
pending_batch_tasks: [],
|
||||||
# Add missing assigns for components
|
# Add missing assigns for components
|
||||||
loading: false,
|
loading: false,
|
||||||
connection_status: "connected",
|
connection_status: get_initial_connection_status(),
|
||||||
show_all_packets: true
|
show_all_packets: true
|
||||||
)
|
)
|
||||||
end
|
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()
|
@spec assign_defaults(Socket.t(), DateTime.t()) :: Socket.t()
|
||||||
defp assign_defaults(socket, one_hour_ago) do
|
defp assign_defaults(socket, one_hour_ago) do
|
||||||
assign(socket,
|
assign(socket,
|
||||||
|
|
@ -267,7 +273,7 @@ defmodule AprsmeWeb.MapLive.Index do
|
||||||
last_update_at: DateTime.utc_now(),
|
last_update_at: DateTime.utc_now(),
|
||||||
# Add missing assigns for components
|
# Add missing assigns for components
|
||||||
loading: false,
|
loading: false,
|
||||||
connection_status: "connected",
|
connection_status: get_initial_connection_status(),
|
||||||
show_all_packets: true
|
show_all_packets: true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue