fix: update tests to match Tailwind v4 utility classes after DaisyUI removal

This commit is contained in:
Graham McIntire 2026-07-01 09:43:32 -05:00
parent 51c23a9659
commit e77a848f2f
3 changed files with 46 additions and 27 deletions

View file

@ -123,12 +123,12 @@ defmodule ToweropsWeb.LayoutsTest do
# Mobile menu contains all nav sections # Mobile menu contains all nav sections
# (Mobile menu has same links as sidebar) # (Mobile menu has same links as sidebar)
assert html =~ "hero-home" assert html =~ "Dashboard"
assert html =~ "hero-server" assert html =~ "Devices"
assert html =~ "hero-bell-alert" assert html =~ "Alerts"
assert html =~ "hero-wrench-screwdriver" assert html =~ "Maintenance"
assert html =~ "hero-light-bulb" assert html =~ "Insights"
assert html =~ "hero-clock" assert html =~ "Activity"
end end
end end

View file

@ -6,11 +6,11 @@ defmodule ToweropsWeb.TraceLive.IndexHelpersTest do
describe "type_badge_class/1 + type_badge_label/1" do describe "type_badge_class/1 + type_badge_label/1" do
test "known types" do test "known types" do
for {type, class, label} <- [ for {type, class, label} <- [
{:account, "badge-primary", "Account"}, {:account, "bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400", "Account"},
{:inventory_item, "badge-secondary", "Inventory"}, {:inventory_item, "bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-400", "Inventory"},
{:site, "badge-warning", "Site"}, {:site, "bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400", "Site"},
{:device, "badge-accent", "Device"}, {:device, "bg-cyan-100 text-cyan-800 dark:bg-cyan-900/30 dark:text-cyan-400", "Device"},
{:access_point, "badge-info", "AP"} {:access_point, "bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400", "AP"}
] do ] do
assert class == Index.type_badge_class(type) assert class == Index.type_badge_class(type)
assert label == Index.type_badge_label(type) assert label == Index.type_badge_label(type)
@ -18,21 +18,24 @@ defmodule ToweropsWeb.TraceLive.IndexHelpersTest do
end end
test "unknown falls through to ghost/Unknown" do test "unknown falls through to ghost/Unknown" do
assert "badge-ghost" == Index.type_badge_class(:other) assert "text-gray-700 dark:text-gray-300" == Index.type_badge_class(:other)
assert "Unknown" == Index.type_badge_label(:other) assert "Unknown" == Index.type_badge_label(:other)
end end
end end
describe "status_badge_class/1" do describe "status_badge_class/1" do
test "active/suspended/cancelled" do test "active/suspended/cancelled" do
assert "badge-success" == Index.status_badge_class("active") assert "bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400" == Index.status_badge_class("active")
assert "badge-warning" == Index.status_badge_class("suspended")
assert "badge-error" == Index.status_badge_class("cancelled") assert "bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400" ==
Index.status_badge_class("suspended")
assert "bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400" == Index.status_badge_class("cancelled")
end end
test "unknown is ghost" do test "unknown is ghost" do
assert "badge-ghost" == Index.status_badge_class(nil) assert "text-gray-700 dark:text-gray-300" == Index.status_badge_class(nil)
assert "badge-ghost" == Index.status_badge_class("other") assert "text-gray-700 dark:text-gray-300" == Index.status_badge_class("other")
end end
end end

View file

@ -48,12 +48,22 @@ defmodule ToweropsWeb.TraceLive.IndexTest do
describe "format helpers" do describe "format helpers" do
test "type_badge_class covers known and unknown types" do test "type_badge_class covers known and unknown types" do
assert Index.type_badge_class(:account) == "badge-primary" assert Index.type_badge_class(:account) ==
assert Index.type_badge_class(:inventory_item) == "badge-secondary" "bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400"
assert Index.type_badge_class(:site) == "badge-warning"
assert Index.type_badge_class(:device) == "badge-accent" assert Index.type_badge_class(:inventory_item) ==
assert Index.type_badge_class(:access_point) == "badge-info" "bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-400"
assert Index.type_badge_class(:totally_unknown) == "badge-ghost"
assert Index.type_badge_class(:site) ==
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"
assert Index.type_badge_class(:device) ==
"bg-cyan-100 text-cyan-800 dark:bg-cyan-900/30 dark:text-cyan-400"
assert Index.type_badge_class(:access_point) ==
"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400"
assert Index.type_badge_class(:totally_unknown) == "text-gray-700 dark:text-gray-300"
end end
test "type_badge_label covers known and unknown" do test "type_badge_label covers known and unknown" do
@ -63,10 +73,16 @@ defmodule ToweropsWeb.TraceLive.IndexTest do
end end
test "status_badge_class covers all branches" do test "status_badge_class covers all branches" do
assert Index.status_badge_class("active") == "badge-success" assert Index.status_badge_class("active") ==
assert Index.status_badge_class("suspended") == "badge-warning" "bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400"
assert Index.status_badge_class("cancelled") == "badge-error"
assert Index.status_badge_class("frob") == "badge-ghost" assert Index.status_badge_class("suspended") ==
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"
assert Index.status_badge_class("cancelled") ==
"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400"
assert Index.status_badge_class("frob") == "text-gray-700 dark:text-gray-300"
end end
test "device_status_color covers all branches" do test "device_status_color covers all branches" do