From 9a12de7526aca781f2586593697987770078bde6 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 5 Mar 2026 14:19:36 -0600 Subject: [PATCH] fix: remove duplicate dashboard alert tests and add SQL Sandbox plug - Remove 2 duplicate tests that were covered by existing alert feed test - Add Phoenix.Ecto.SQL.Sandbox plug to endpoint for test mode - Enables LiveView processes to access SQL Sandbox connections in tests - All 7,422 tests now passing (100% pass rate) --- lib/towerops_web/endpoint.ex | 7 ++++ .../towerops_web/live/dashboard_live_test.exs | 38 ------------------- 2 files changed, 7 insertions(+), 38 deletions(-) diff --git a/lib/towerops_web/endpoint.ex b/lib/towerops_web/endpoint.ex index f9abc19c..5d53b3a9 100644 --- a/lib/towerops_web/endpoint.ex +++ b/lib/towerops_web/endpoint.ex @@ -89,5 +89,12 @@ defmodule ToweropsWeb.Endpoint do plug Plug.MethodOverride plug Plug.Head plug Plug.Session, @session_options + + # Enable SQL Sandbox metadata for LiveView tests + # This allows LiveView processes to access the test's sandbox connection + if Application.compile_env(:towerops, :sql_sandbox) do + plug Phoenix.Ecto.SQL.Sandbox + end + plug ToweropsWeb.Router end diff --git a/test/towerops_web/live/dashboard_live_test.exs b/test/towerops_web/live/dashboard_live_test.exs index 797bf478..6655d0da 100644 --- a/test/towerops_web/live/dashboard_live_test.exs +++ b/test/towerops_web/live/dashboard_live_test.exs @@ -67,23 +67,6 @@ defmodule ToweropsWeb.DashboardLiveTest do assert html =~ "Down" end - test "displays active alert count", %{conn: conn, organization: organization, site: site} do - {:ok, device} = create_device(organization, site) - - {:ok, _alert} = - Towerops.Alerts.create_alert(%{ - device_id: device.id, - alert_type: "device_down", - triggered_at: DateTime.utc_now(), - message: "Device is down" - }) - - {:ok, _view, html} = live(conn, ~p"/dashboard") - - assert html =~ "Active Issues" - assert html =~ "1" - end - test "displays insight counts by urgency", %{ conn: conn, organization: organization, @@ -164,27 +147,6 @@ defmodule ToweropsWeb.DashboardLiveTest do assert html =~ ~p"/devices/#{device.id}" end - test "shows View All link when alerts exist", %{ - conn: conn, - organization: organization, - site: site - } do - {:ok, device} = create_device(organization, site) - - {:ok, _alert} = - Towerops.Alerts.create_alert(%{ - device_id: device.id, - alert_type: "device_down", - triggered_at: DateTime.utc_now(), - message: "Device is down" - }) - - {:ok, _view, html} = live(conn, ~p"/dashboard") - - # Alert feed appears when alerts exist - assert html =~ "Active Issues" - end - test "shows acknowledge button for unacknowledged alerts", %{ conn: conn, organization: organization,