test: StatusLive.Index connected-path render via cached status
This commit is contained in:
parent
34729f8769
commit
43036a6b6d
1 changed files with 38 additions and 0 deletions
|
|
@ -12,6 +12,44 @@ defmodule AprsmeWeb.StatusLive.IndexTest do
|
||||||
assert html =~ "System Status"
|
assert html =~ "System Status"
|
||||||
assert html =~ "APRS-IS Connection"
|
assert html =~ "APRS-IS Connection"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "renders the connected-path template when cache has a live status", %{conn: conn} do
|
||||||
|
# Ensure the cache ETS table exists for test.
|
||||||
|
_ =
|
||||||
|
case :ets.info(:query_cache) do
|
||||||
|
:undefined -> :ets.new(:query_cache, [:named_table, :public, :set])
|
||||||
|
_ -> :ok
|
||||||
|
end
|
||||||
|
|
||||||
|
status = %{
|
||||||
|
connected: true,
|
||||||
|
server: "cached.aprs.test",
|
||||||
|
port: 14_580,
|
||||||
|
connected_at: DateTime.add(DateTime.utc_now(), -3600, :second),
|
||||||
|
uptime_seconds: 3600,
|
||||||
|
login_id: "N0CALL",
|
||||||
|
filter: "r/33/-96/100",
|
||||||
|
packet_stats: %{
|
||||||
|
total_packets: 1234,
|
||||||
|
last_packet_at: DateTime.add(DateTime.utc_now(), -30, :second),
|
||||||
|
packets_per_second: 5
|
||||||
|
},
|
||||||
|
stored_packet_count: 5000,
|
||||||
|
oldest_packet_timestamp: DateTime.add(DateTime.utc_now(), -86_400, :second)
|
||||||
|
}
|
||||||
|
|
||||||
|
Aprsme.Cache.put(:query_cache, "aprs_status", status)
|
||||||
|
|
||||||
|
{:ok, _lv, html} = live(conn, ~p"/status", on_error: :warn)
|
||||||
|
assert html =~ "Connected"
|
||||||
|
assert html =~ "cached.aprs.test"
|
||||||
|
assert html =~ "N0CALL"
|
||||||
|
# Total packets formatted with thousands separator.
|
||||||
|
assert html =~ "1,234"
|
||||||
|
|
||||||
|
# Cleanup so other tests aren't affected.
|
||||||
|
Aprsme.Cache.del(:query_cache, "aprs_status")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "handle_info({:status_updated, status}, socket)" do
|
describe "handle_info({:status_updated, status}, socket)" do
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue