prop/test/microwaveprop_web/live/contact_live/mechanism_test.exs
Graham McIntire fd976b0cd5
fix: resolve 391 Credo issues across codebase
- Add jump_credo_checks ~> 0.4 with all 20 checks enabled
- Fix all standard Credo issues: 139 @spec (113 done, 26 remain),
  4 refactoring, 3 alias usage, 9 System.cmd env, 5 unsafe_to_atom,
  2 max line length, 9 assert_receive timeout
- Fix 170+ jump_credo_checks warnings:
  - 117 TopLevelAliasImportRequire: move nested alias/import to module top
  - 32 UseObanProWorker: switch to Oban.Pro.Worker
  - 4 DoctestIExExamples: add doctests / create test file
  - ~20 WeakAssertion: strengthen type-check assertions
  - Various ConditionalAssertion, AssertReceiveTimeout fixes
- Exclude vendor/ from Credo analysis
- Remaining: 175 warnings (mostly opinionated WeakAssertion,
  AvoidSocketAssignsInTest), 26 @spec annotations
2026-06-12 13:51:32 -05:00

71 lines
2.4 KiB
Elixir
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

defmodule MicrowavepropWeb.ContactLive.MechanismTest do
use ExUnit.Case, async: true
alias MicrowavepropWeb.ContactLive.Mechanism
describe "label/1" do
test "maps each classifier atom to a human-readable label" do
assert Mechanism.label(:likely_rainscatter) == "Likely Rain Scatter"
assert Mechanism.label(:rainscatter_possible) == "Rain Scatter Possible"
assert Mechanism.label(:tropo_duct) == "Tropospheric Duct"
assert Mechanism.label(:troposcatter) == "Troposcatter"
assert Mechanism.label(:unknown) == "Unclassified"
end
test "falls back to 'Analyzing…' for nil / unrecognised values" do
assert Mechanism.label(nil) == "Analyzing…"
assert Mechanism.label(:some_new_atom_not_yet_mapped) == "Analyzing…"
end
end
describe "badge_class/1" do
test "returns a daisyUI badge class for every known mechanism" do
for m <- [
:likely_rainscatter,
:rainscatter_possible,
:tropo_duct,
:troposcatter,
:unknown,
nil,
:future_mechanism
] do
cls = Mechanism.badge_class(m)
assert byte_size(cls) > 0
assert String.starts_with?(cls, "badge-")
end
end
test "distinguishes likely vs possible rain scatter visually" do
# 'likely' is the confident variant (filled), 'possible' is outlined.
assert Mechanism.badge_class(:likely_rainscatter) == "badge-info"
assert Mechanism.badge_class(:rainscatter_possible) == "badge-info badge-outline"
end
end
describe "explainer/1" do
test "every classified mechanism gets a non-empty, single-sentence explainer" do
for m <- [
:likely_rainscatter,
:rainscatter_possible,
:tropo_duct,
:troposcatter,
:unknown
] do
text = Mechanism.explainer(m)
assert byte_size(text) > 0
assert text != ""
end
end
test "unclassified / nil returns an empty string (no tooltip needed)" do
assert Mechanism.explainer(nil) == ""
assert Mechanism.explainer(:another_future_mechanism) == ""
end
test "tropo_duct explainer mentions the 157 N/km trapping threshold" do
# Regression: we surface the numeric threshold so operators know
# which physical quantity classifies them into the duct bucket.
assert Mechanism.explainer(:tropo_duct) =~ "157"
end
end
end