"""libredesk — UI probe: the served root HTML is the real LibreDesk app, not a fallback page. /health passing only proves the process is up. This asserts the front-end SPA is actually bound and serving its own shell — a wedged backend or a misrouted proxy would 200 with generic/empty content. """ from __future__ import annotations import os import ssl import sys import urllib.request sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "runner")) from harness import http as harness_http # noqa: E402 _CTX = ssl.create_default_context() _CTX.check_hostname = False _CTX.verify_mode = ssl.CERT_NONE def _get_body(url: str) -> tuple[int, str]: req = urllib.request.Request(url, method="GET") with urllib.request.urlopen(req, timeout=15, context=_CTX) as r: return r.status, r.read().decode(errors="replace") def test_libredesk_serves_app_shell(live_app): """GET /; assert LibreDesk-specific brand or SPA-asset markers in the served HTML.""" url = f"https://{live_app}/" def _ready(): try: status, body = _get_body(url) except Exception: # noqa: BLE001 return None return body if status in (200, 301, 302) else None body = harness_http.assert_converges(_ready, f"GET {url}", max_wait=120, interval=5) lower = body.lower() # Brand markers: the app title / meta / bundle references carry "libredesk". brand = [m for m in ("libredesk", "libre desk") if m in lower] # SPA asset markers: the built front-end serves hashed JS/CSS bundles + a favicon. assets = [m for m in ("/assets/", "favicon", ".js", ".css", "