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)
This commit is contained in:
Graham McIntire 2026-03-05 14:19:36 -06:00
parent 8f52d87854
commit 9a12de7526
No known key found for this signature in database
2 changed files with 7 additions and 38 deletions

View file

@ -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

View file

@ -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,