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.
47 lines
1.4 KiB
Elixir
47 lines
1.4 KiB
Elixir
defmodule ToweropsWeb.ConfigTimelineLiveHelpersTest do
|
|
use ExUnit.Case, async: true
|
|
|
|
alias ToweropsWeb.ConfigTimelineLive
|
|
|
|
describe "change_size_class/1" do
|
|
test "> 50 returns error" do
|
|
assert "badge-error" == ConfigTimelineLive.change_size_class(51)
|
|
assert "badge-error" == ConfigTimelineLive.change_size_class(1_000)
|
|
end
|
|
|
|
test "21..50 returns warning" do
|
|
assert "badge-warning" == ConfigTimelineLive.change_size_class(21)
|
|
assert "badge-warning" == ConfigTimelineLive.change_size_class(50)
|
|
end
|
|
|
|
test "<= 20 returns info" do
|
|
assert "badge-info" == ConfigTimelineLive.change_size_class(0)
|
|
assert "badge-info" == ConfigTimelineLive.change_size_class(20)
|
|
end
|
|
|
|
test "non-integer returns info" do
|
|
assert "badge-info" == ConfigTimelineLive.change_size_class(nil)
|
|
assert "badge-info" == ConfigTimelineLive.change_size_class("foo")
|
|
end
|
|
end
|
|
|
|
describe "timeline_event/1" do
|
|
test "serializes to ISO timestamp map" do
|
|
changed_at = ~U[2026-01-15 12:00:00Z]
|
|
|
|
event = %{
|
|
id: "evt-1",
|
|
changed_at: changed_at,
|
|
sections_changed: ["dhcp", "ospf"],
|
|
change_size: 42
|
|
}
|
|
|
|
assert %{
|
|
id: "evt-1",
|
|
t: "2026-01-15T12:00:00Z",
|
|
sections: ["dhcp", "ospf"],
|
|
size: 42
|
|
} == ConfigTimelineLive.timeline_event(event)
|
|
end
|
|
end
|
|
end
|