osint-dashboard/tests/test_frontend_reliability.py

50 lines
1.7 KiB
Python
Raw Permalink Normal View History

"""HUD load-time: no market 404 poll, deferred overlays, WS backoff, nginx snippet."""
from __future__ import annotations
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
HTML = (ROOT / "app/static/index.html").read_text()
def test_summarizer_dockerfile_copies_intel_modules():
df = (ROOT / "news/summerizer/Dockerfile").read_text()
assert "intel.py" in df
assert "nous_client.py" in df
def test_news_panel_pins_daily_recap():
assert "kind=daily_recap" in HTML
assert "DAILY RECAP" in HTML
def test_nginx_ws_snippet_has_upgrade_headers():
conf = (ROOT / "deploy/osint-ws.nginx.conf").read_text()
assert "proxy_http_version 1.1" in conf
assert "Upgrade" in conf
assert "Connection" in conf
assert "/ws/" in conf
def test_market_ticker_does_not_poll_unwired_endpoint():
assert "setInterval(probeMarket" not in HTML
assert "initMarketTicker()" not in HTML or "probeMarket();" not in HTML.split("function initMarketTicker")[1][:400]
def test_startup_defers_nonessential_overlays():
init = HTML.split("function initMap")[1].split("function readMapPrefs")[0]
# Must not fire all four DB loads + live overlays in the same tick.
assert "setTimeout" in init or "requestAnimationFrame" in init
def test_ws_reconnect_uses_backoff():
assert "setTimeout(connectLiveWs, 4000)" not in HTML
ws = HTML.split("function connectLiveWs")[1][:1200]
assert "backoff" in ws.lower() or "wsRetry" in ws or "wsDelay" in ws
def test_check_health_treats_degraded_status():
fn = HTML.split("async function checkHealth")[1].split("/* ═══════════════ NAV")[0]
assert "degraded" in fn.lower() or "d.status" in fn