Files
webmanager-mvp/webui/backend/tests/golden/test_ui_smoke_golden.py
T
2026-03-11 09:53:36 +01:00

52 lines
1.8 KiB
Python

from __future__ import annotations
import sys
import unittest
from pathlib import Path
from fastapi.staticfiles import StaticFiles
from starlette.routing import Mount
sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
from backend.app.main import app
class UiSmokeGoldenTest(unittest.TestCase):
def _ui_mount(self) -> Mount:
for route in app.routes:
if isinstance(route, Mount) and route.path == "/ui":
return route
self.fail("Expected /ui mount to be registered")
def test_ui_mount_and_index_contains_expected_panels(self) -> None:
mount = self._ui_mount()
self.assertIsInstance(mount.app, StaticFiles)
index_path = Path(mount.app.directory) / "index.html"
self.assertTrue(index_path.exists())
body = index_path.read_text(encoding="utf-8")
self.assertIn('id="workspace"', body)
self.assertIn('id="footer-bar"', body)
self.assertIn('id="left-pane"', body)
self.assertIn('id="right-pane"', body)
self.assertIn('id="left-breadcrumbs"', body)
self.assertIn('id="right-breadcrumbs"', body)
self.assertNotIn('id="bookmarks-panel"', body)
self.assertNotIn('id="tasks-panel"', body)
def test_ui_static_assets_are_present_and_mapped(self) -> None:
mount = self._ui_mount()
static_root = Path(mount.app.directory)
self.assertTrue((static_root / "app.js").exists())
self.assertTrue((static_root / "style.css").exists())
app_js_url = app.url_path_for("ui", path="/app.js")
style_css_url = app.url_path_for("ui", path="/style.css")
self.assertEqual(app_js_url, "/ui/app.js")
self.assertEqual(style_css_url, "/ui/style.css")
if __name__ == "__main__":
unittest.main()