"""UniFi's overview reads in the shared shapes: WAN health as stat tiles graded by Settings → Thresholds, devices with status dots, categories as badges (#5126).""" from datetime import datetime, timezone from types import SimpleNamespace as NS from tests._templates import render_plugin_template from tests.test_style_tokens import hex_colours async def test_wan_health_and_devices_use_the_shared_shapes(app): wan = NS(is_up=False, wan_ip="203.0.113.7", latency_ms=250.0, rx_bytes_rate=2_000_000.0, tx_bytes_rate=500_000.0, uptime_seconds=7200) devices = [NS(name="switch", mac="aa", model="USW", device_type="usw", ip="10.0.0.2", state=1, uptime_seconds=3600), NS(name="ap-attic", mac="bb", model="U6", device_type="uap", ip="10.0.0.3", state=0, uptime_seconds=None)] async with app.test_request_context("/plugins/unifi/rows"): page = await render_plugin_template(app, "unifi", "unifi/rows.html", latest_wan=wan, devices=devices, sparkline_latency="", sparkline_rx="", sparkline_tx="") assert 'WAN' in page and "stat-crit" in page assert '250 ms' in page assert 'class="dot dot-ok"' in page and 'class="dot dot-crit"' in page assert "font-weight:600" not in page and "font-weight:700" not in page assert not hex_colours(page), hex_colours(page) async def test_event_categories_are_badges(app): events = [NS(event_time=datetime(2026, 10, 6, 12, 0, tzinfo=timezone.utc), category="ids", event_key="EVT_IPS_Alert", message="blocked", subsystem="ids")] async with app.test_request_context("/plugins/unifi/events"): page = await render_plugin_template(app, "unifi", "unifi/events.html", events=events) assert 'ids' in page assert "rgba(" not in page