From 76de672ac8c1269e277bdfbb1bb8c71da9ec80d3 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 8 May 2026 13:30:38 -0500 Subject: [PATCH] test: parametric HelpLive section coverage + MibCache init/pre_resolve --- test/towerops/profiles/mib_cache_test.exs | 17 +++++++++++++++++ test/towerops_web/live/help_live/index_test.exs | 15 +++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/test/towerops/profiles/mib_cache_test.exs b/test/towerops/profiles/mib_cache_test.exs index 35fe0aa1..6606883c 100644 --- a/test/towerops/profiles/mib_cache_test.exs +++ b/test/towerops/profiles/mib_cache_test.exs @@ -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 diff --git a/test/towerops_web/live/help_live/index_test.exs b/test/towerops_web/live/help_live/index_test.exs index abb4a610..fc762616 100644 --- a/test/towerops_web/live/help_live/index_test.exs +++ b/test/towerops_web/live/help_live/index_test.exs @@ -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")