Add LiveView for real-time job monitoring dashboard: - Subscribe to job:lifecycle PubSub topic for live updates - Display health metrics (completed, failed, avg duration, active jobs) - Show active operations with real-time updates - Display problems section (stuck/failed job counts) - Add router entry under /admin/monitoring Tests verify PubSub subscription and basic rendering. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
38 lines
1.1 KiB
Elixir
38 lines
1.1 KiB
Elixir
defmodule ToweropsWeb.Admin.MonitoringLiveTest do
|
|
use ToweropsWeb.ConnCase
|
|
|
|
import Phoenix.LiveViewTest
|
|
|
|
describe "MonitoringLive" do
|
|
setup [:register_and_log_in_superuser]
|
|
|
|
test "renders monitoring dashboard", %{conn: conn} do
|
|
{:ok, _view, html} = live(conn, ~p"/admin/monitoring")
|
|
|
|
assert html =~ "Job Monitoring Dashboard"
|
|
assert html =~ "Active Operations"
|
|
assert html =~ "Problems"
|
|
assert html =~ "Health Metrics"
|
|
end
|
|
|
|
test "subscribes to job lifecycle events", %{conn: conn} do
|
|
{:ok, view, _html} = live(conn, ~p"/admin/monitoring")
|
|
|
|
# Verify PubSub subscription by checking it's alive
|
|
assert view.pid |> Process.alive?()
|
|
end
|
|
|
|
test "displays active operations section", %{conn: conn} do
|
|
{:ok, _view, html} = live(conn, ~p"/admin/monitoring")
|
|
|
|
assert html =~ "Active Operations"
|
|
assert html =~ "No active jobs"
|
|
end
|
|
end
|
|
|
|
defp register_and_log_in_superuser(%{conn: conn}) do
|
|
user = Towerops.AccountsFixtures.user_fixture()
|
|
user = Towerops.Repo.update!(Ecto.Changeset.change(user, is_superuser: true))
|
|
%{conn: log_in_user(conn, user), user: user}
|
|
end
|
|
end
|