test: parametric HelpLive section coverage + MibCache init/pre_resolve

This commit is contained in:
Graham McIntire 2026-05-08 13:30:38 -05:00
parent 5af987035f
commit 76de672ac8
2 changed files with 32 additions and 0 deletions

View file

@ -50,5 +50,22 @@ defmodule Towerops.Profiles.MibCacheTest do
test "returns :ok (fire-and-forget)" do
assert :ok == MibCache.pre_resolve(["ifName", "sysDescr"])
end
test "actually drains the GenServer mailbox by calling size/0", %{} do
:ok = MibCache.pre_resolve(["pre1", "pre2"])
# size/0 acts as a sync barrier through ETS
assert is_integer(MibCache.size())
end
end
describe "init/1" do
test "creates the ETS table when it does not yet exist" do
# Drop and re-init to exercise the create branch.
_ = if pid = Process.whereis(MibCache), do: GenServer.stop(pid, :normal)
_ = :ets.info(:mib_cache) != :undefined && :ets.delete(:mib_cache)
assert {:ok, _state} = MibCache.init([])
assert :ets.info(:mib_cache) != :undefined
end
end
end

View file

@ -3,6 +3,21 @@ defmodule ToweropsWeb.HelpLive.IndexTest do
import Phoenix.LiveViewTest
describe "every section renders without crashing" do
for section <- ~w(
about getting-started settings sites cloud-pollers agents
integrations mikrotik graphs insights network-map
api-tokens rest-api graphql-api
) do
test "section=#{section} renders content", %{conn: conn} do
section = unquote(section)
{:ok, _view, html} = live(conn, ~p"/help?section=#{section}")
# Page renders and contains the help shell
assert html =~ "Help"
end
end
end
describe "unauthenticated access" do
test "mounts without authentication and shows help content", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/help")