Promoted pure presentation and utility helpers from `defp` to `def @doc false` across ~20 LiveViews, Oban workers, and sync modules so they're reachable from unit tests. Refactored several `cond` blocks into idiomatic function heads with guards. Added ~250 new test cases in new files under test/towerops and test/towerops_web, including DB-backed tests for CnMaestro.Sync and AlertNotificationWorker, and removed dead LiveView tab components and CapacityLive (no callers anywhere in lib/test). Configured mix.exs test_coverage.ignore_modules to exclude vendored third-party code (SnmpKit, protobuf-generated Towerops.Agent.*, Absinthe GraphQL types, Phoenix HTML modules, Inspect protocol impls) from coverage calculations — these are not our project code. Coverage: 66.93% → 70.09%. Full suite: 10,127 tests, 0 failures.
223 lines
6.5 KiB
Elixir
223 lines
6.5 KiB
Elixir
defmodule ToweropsWeb.LiveViewSmokeTest do
|
|
@moduledoc """
|
|
Smoke tests for LiveView pages.
|
|
|
|
For each routed LiveView, verify that it mounts successfully and renders
|
|
without raising. These tests exist primarily for coverage of happy-path
|
|
mount/render code.
|
|
"""
|
|
use ToweropsWeb.ConnCase, async: true
|
|
|
|
import Phoenix.LiveViewTest
|
|
|
|
setup :register_and_log_in_user
|
|
|
|
setup %{user: user} do
|
|
{:ok, organization} = Towerops.Organizations.create_organization(%{name: "Smoke Org"}, user.id)
|
|
%{organization: organization}
|
|
end
|
|
|
|
describe "smoke: informational pages" do
|
|
test "GET /changelog", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/changelog")
|
|
end
|
|
|
|
test "GET /activity", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/activity")
|
|
end
|
|
|
|
test "GET /insights", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/insights")
|
|
end
|
|
|
|
test "GET /rf-links", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/rf-links")
|
|
end
|
|
|
|
test "GET /reports", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/reports")
|
|
end
|
|
|
|
test "GET /weathermap", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/weathermap")
|
|
end
|
|
|
|
test "GET /sites-map", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/sites-map")
|
|
end
|
|
|
|
test "GET /network-map", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/network-map")
|
|
end
|
|
end
|
|
|
|
describe "smoke: maintenance pages" do
|
|
test "GET /maintenance", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/maintenance")
|
|
end
|
|
|
|
test "GET /maintenance/new", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/maintenance/new")
|
|
end
|
|
end
|
|
|
|
describe "smoke: on-call pages" do
|
|
test "GET /schedules", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/schedules")
|
|
end
|
|
|
|
test "GET /schedules/escalation-policies", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/schedules/escalation-policies")
|
|
end
|
|
end
|
|
|
|
describe "smoke: devices/sites" do
|
|
test "GET /sites", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/sites")
|
|
end
|
|
|
|
test "GET /devices", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/devices")
|
|
end
|
|
end
|
|
|
|
describe "smoke: trace/help" do
|
|
test "GET /trace", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/trace")
|
|
end
|
|
|
|
test "GET /help", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/help")
|
|
end
|
|
end
|
|
|
|
describe "smoke: account pages" do
|
|
test "GET /mobile/qr-login", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/mobile/qr-login")
|
|
end
|
|
end
|
|
|
|
describe "smoke: other top-level" do
|
|
test "GET /alerts", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/alerts")
|
|
end
|
|
|
|
test "GET /dashboard", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/dashboard")
|
|
end
|
|
end
|
|
|
|
describe "smoke: schedule new forms" do
|
|
test "GET /schedules/new", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/schedules/new")
|
|
end
|
|
|
|
test "GET /schedules/escalation-policies/new", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/schedules/escalation-policies/new")
|
|
end
|
|
end
|
|
|
|
describe "smoke: sites/devices new forms" do
|
|
test "GET /sites/new", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/sites/new")
|
|
end
|
|
|
|
test "GET /devices/new", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/devices/new")
|
|
end
|
|
end
|
|
|
|
describe "smoke: orgs page" do
|
|
test "GET /orgs", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/orgs")
|
|
end
|
|
|
|
test "GET /orgs/new", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/orgs/new")
|
|
end
|
|
end
|
|
|
|
describe "smoke: specific-resource paths" do
|
|
defp assert_mount_or_redirect(result) do
|
|
assert match?({:ok, _, _}, result) or
|
|
match?({:error, {:redirect, _}}, result) or
|
|
match?({:error, {:live_redirect, _}}, result)
|
|
end
|
|
|
|
test "GET /sites/:id", %{conn: conn, organization: org} do
|
|
{:ok, site} =
|
|
Towerops.Sites.create_site(%{
|
|
name: "S-#{System.unique_integer([:positive])}",
|
|
organization_id: org.id
|
|
})
|
|
|
|
assert_mount_or_redirect(live(conn, ~p"/sites/#{site.id}"))
|
|
end
|
|
|
|
test "GET /sites/:id/edit", %{conn: conn, organization: org} do
|
|
{:ok, site} =
|
|
Towerops.Sites.create_site(%{
|
|
name: "S-#{System.unique_integer([:positive])}",
|
|
organization_id: org.id
|
|
})
|
|
|
|
assert_mount_or_redirect(live(conn, ~p"/sites/#{site.id}/edit"))
|
|
end
|
|
|
|
test "GET /orgs/:id/settings", %{conn: conn, organization: org} do
|
|
assert_mount_or_redirect(live(conn, ~p"/orgs/#{org.id}/settings"))
|
|
end
|
|
end
|
|
|
|
describe "smoke: alert-specific paths" do
|
|
test "GET /alerts with query filter", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/alerts?severity=critical")
|
|
end
|
|
|
|
test "GET /dashboard with tab param", %{conn: conn} do
|
|
assert {:ok, _view, _html} = live(conn, ~p"/dashboard")
|
|
end
|
|
end
|
|
|
|
describe "smoke: extra pages" do
|
|
test "GET /trace", %{conn: conn} do
|
|
assert_mount_or_redirect(live(conn, ~p"/trace"))
|
|
end
|
|
|
|
test "GET /alerts?status=resolved", %{conn: conn} do
|
|
assert_mount_or_redirect(live(conn, ~p"/alerts?status=resolved"))
|
|
end
|
|
|
|
test "GET /devices?tab=monitored", %{conn: conn} do
|
|
assert_mount_or_redirect(live(conn, ~p"/devices?tab=monitored"))
|
|
end
|
|
|
|
test "GET /devices?search=foo", %{conn: conn} do
|
|
assert_mount_or_redirect(live(conn, ~p"/devices?search=foo"))
|
|
end
|
|
|
|
test "GET /activity?filter=all", %{conn: conn} do
|
|
assert_mount_or_redirect(live(conn, ~p"/activity?filter=all"))
|
|
end
|
|
|
|
test "GET /reports?page=1", %{conn: conn} do
|
|
assert_mount_or_redirect(live(conn, ~p"/reports?page=1"))
|
|
end
|
|
|
|
test "GET /rf-links?health=warning", %{conn: conn} do
|
|
assert_mount_or_redirect(live(conn, ~p"/rf-links?health=warning"))
|
|
end
|
|
|
|
test "GET /insights?filter=unresolved", %{conn: conn} do
|
|
assert_mount_or_redirect(live(conn, ~p"/insights?filter=unresolved"))
|
|
end
|
|
|
|
test "GET /maintenance?filter=active", %{conn: conn} do
|
|
assert_mount_or_redirect(live(conn, ~p"/maintenance?filter=active"))
|
|
end
|
|
|
|
test "GET /maintenance?filter=upcoming", %{conn: conn} do
|
|
assert_mount_or_redirect(live(conn, ~p"/maintenance?filter=upcoming"))
|
|
end
|
|
end
|
|
end
|