117 lines
3.3 KiB
Elixir
117 lines
3.3 KiB
Elixir
defmodule ToweropsWeb.HelpLive.IndexTest do
|
|
use ToweropsWeb.ConnCase, async: true
|
|
|
|
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")
|
|
|
|
assert html =~ "Help"
|
|
assert html =~ "About Towerops"
|
|
end
|
|
|
|
test "defaults to the about section", %{conn: conn} do
|
|
{:ok, _view, html} = live(conn, ~p"/help")
|
|
|
|
assert html =~ "About Towerops"
|
|
assert html =~ "network monitoring"
|
|
end
|
|
|
|
test "navigates to getting-started section", %{conn: conn} do
|
|
{:ok, view, _html} = live(conn, ~p"/help")
|
|
|
|
html =
|
|
view
|
|
|> element("nav a[href='/help?section=getting-started']")
|
|
|> render_click()
|
|
|
|
assert html =~ "Getting Started"
|
|
assert html =~ "Quick Start Guide"
|
|
end
|
|
|
|
test "navigates to sites section via params", %{conn: conn} do
|
|
{:ok, _view, html} = live(conn, ~p"/help?section=sites")
|
|
|
|
assert html =~ "Sites"
|
|
assert html =~ "When to Enable Sites"
|
|
end
|
|
|
|
test "navigates to cloud-pollers section via params", %{conn: conn} do
|
|
{:ok, _view, html} = live(conn, ~p"/help?section=cloud-pollers")
|
|
|
|
assert html =~ "Cloud Pollers"
|
|
end
|
|
|
|
test "navigates to agents section via params", %{conn: conn} do
|
|
{:ok, _view, html} = live(conn, ~p"/help?section=agents")
|
|
|
|
assert html =~ "Remote Pollers"
|
|
end
|
|
|
|
test "navigates to graphs section via params", %{conn: conn} do
|
|
{:ok, _view, html} = live(conn, ~p"/help?section=graphs")
|
|
|
|
assert html =~ "Graphs"
|
|
assert html =~ "Live Polling"
|
|
end
|
|
|
|
test "navigates to mikrotik section via params", %{conn: conn} do
|
|
{:ok, _view, html} = live(conn, ~p"/help?section=mikrotik")
|
|
|
|
assert html =~ "MikroTik"
|
|
end
|
|
|
|
test "shows section not found for unknown section", %{conn: conn} do
|
|
{:ok, _view, html} = live(conn, ~p"/help?section=nonexistent")
|
|
|
|
assert html =~ "Section Not Found"
|
|
end
|
|
end
|
|
|
|
describe "authenticated access" do
|
|
setup :register_and_log_in_user
|
|
|
|
test "mounts with authentication and shows help content", %{conn: conn} do
|
|
{:ok, _view, html} = live(conn, ~p"/help")
|
|
|
|
assert html =~ "Help"
|
|
assert html =~ "About Towerops"
|
|
end
|
|
|
|
test "navigates between sections via patch", %{conn: conn} do
|
|
{:ok, view, _html} = live(conn, ~p"/help")
|
|
|
|
# Navigate to getting-started section via sidebar nav
|
|
html =
|
|
view
|
|
|> element("nav a[href='/help?section=getting-started']")
|
|
|> render_click()
|
|
|
|
assert html =~ "Getting Started"
|
|
|
|
# Navigate to agents section via sidebar nav
|
|
html =
|
|
view
|
|
|> element("nav a[href='/help?section=agents']")
|
|
|> render_click()
|
|
|
|
assert html =~ "Remote Pollers"
|
|
end
|
|
end
|
|
end
|