From 630f9809065fcea630dfee12d21fa54d558a6e38 Mon Sep 17 00:00:00 2001 From: sascha Date: Wed, 29 Jul 2026 15:38:36 +0200 Subject: [PATCH] Redesign Sentinel UI: test_frontend_contract.py --- .../tests/test_frontend_contract.py | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 backup-monitor/tests/test_frontend_contract.py diff --git a/backup-monitor/tests/test_frontend_contract.py b/backup-monitor/tests/test_frontend_contract.py new file mode 100644 index 0000000..72b9c5c --- /dev/null +++ b/backup-monitor/tests/test_frontend_contract.py @@ -0,0 +1,77 @@ +import re +import subprocess +import unittest +from pathlib import Path + + +ROOT = Path(__file__).resolve().parents[1] +HTML = (ROOT / "templates" / "index.html").read_text(encoding="utf-8") +JS = (ROOT / "static" / "js" / "app.js").read_text(encoding="utf-8") +CSS = (ROOT / "static" / "css" / "style.css").read_text(encoding="utf-8") + + +class FrontendContractTests(unittest.TestCase): + def test_stable_dom_ids_exist_once(self): + required = { + "nav-dashboard", "nav-alerts", "nav-hosts", "nav-config", + "sysStatus", "lastScan", "mOk", "mSize", "mLatest", + "mLatestHost", "mWarn", "mWarnCard", "clusterList", + "liveStream", "chartSvg", "hostGrid", "alertList", + "drawer", "drawerBg", "drawerTitle", "drawerBody", + "modal", "modalBg", "hostForm", "formMode", "formName", + "formKumaUrl", "formEnabled", "toasts", + } + for element_id in required: + count = len(re.findall(rf'id=["\']{re.escape(element_id)}["\']', HTML)) + self.assertEqual(count, 1, f"#{element_id} must exist exactly once") + + def test_uses_local_styles_without_runtime_css_framework(self): + self.assertIn('/static/css/style.css', HTML) + self.assertNotIn('cdn.tailwindcss.com', HTML) + self.assertNotIn('Material+Symbols', HTML) + self.assertNotIn('backdrop-blur', HTML) + self.assertNotIn('pulse-', HTML) + + def test_monitor_surface_has_semantic_landmarks_and_accessible_actions(self): + self.assertRegex(HTML, r']+aria-label="Hauptnavigation"') + self.assertIn('