Traefik: routers are graded from their latest scrape (router_state: crit on any real 5xx share, warn on p95 past the latency critical cutoff or a high 4xx share). Failing and slow routers lead as cards that say why; healthy ones fold into one table that stays open or shut across polls. Proxy counts are stat tiles; certificates are graded by Settings -> Thresholds (tls_days). UniFi: WAN health is a stat strip (latency graded by the thresholds), devices carry status dots, event categories and firewall actions are badges, the alarm count reuses .count-badge (renamed from .nav-count). SNMP: each device wears a status badge and its readings are stat tiles. Agent fleet: the table comes first, with a Status column (Reporting / Silent / Never reported, by the host page's stale_after_seconds), silent agents first, hosts linked, last seen as |ago. Audit: entries name their entity (one query per type, steward/audit/ service.py) and link it; something deleted since keeps the name its entry recorded and says "(deleted)". Tokens: charts read colours through chart-colors.js (stewardColor resolves a token to the rgb the browser computed; Chart.js defaults take the page's text and border colours), so host, history, Traefik and SNMP charts drop their hex. Template hex colours reach 0 (HEX_CEILING = 0), the last rgba pills go, and heavy weights (600/700/bold, 60 of them) become 500, the house pair being 400/500; a guard keeps templates there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23 lines
1.2 KiB
Python
23 lines
1.2 KiB
Python
"""The SNMP list says each device's state with the shared badge and shows its
|
|
readings as stat tiles (#5126)."""
|
|
from tests._templates import render_plugin_template
|
|
from tests.test_style_tokens import hex_colours
|
|
|
|
|
|
async def test_devices_wear_a_status_badge_and_readings_are_tiles(app):
|
|
devices = [
|
|
{"name": "ups", "host": "10.0.0.9", "oids": [{"oid": "1.3.6", "label": "battery_charge_pct"},
|
|
{"oid": "1.3.7", "label": "in_octets"}],
|
|
"readings": {"battery_charge_pct": 97.0, "in_octets": 2_500_000.0}},
|
|
{"name": "printer", "host": "10.0.0.10", "oids": [], "readings": {}},
|
|
]
|
|
async with app.test_request_context("/plugins/snmp/"):
|
|
page = await render_plugin_template(app, "snmp", "snmp/index.html", devices=devices, poll_interval=60)
|
|
|
|
assert '<span class="badge badge-ok">Reachable</span>' in page
|
|
assert '<span class="badge badge-warn">No data yet</span>' in page
|
|
assert '<span class="stat-tile-value">97</span>' in page and '<span class="stat-tile-value">2.50M</span>' in page
|
|
assert 'href="/plugins/snmp/device/ups"' in page
|
|
main = page[page.index("<main"):]
|
|
assert "font-weight:600" not in main and not hex_colours(main), hex_colours(main)
|