"""Barre commune v0.5.0 (HUB-18, fusion #132) — re-vendange 0.46.1. - JS vendangé VERBATIM depuis dracodev-commons, branche hub18-theme-commun (PR commons #12), ui/barre-apps/. Le CSS est inchangé en v0.5.0 : il garde l'empreinte v0.4.1 (verrouillée par tests/test_barre_v041.py). - Thème commun : la barre apprend la préférence du Hub (GET /api/profil/theme) et l'applique à l'ouverture ; l'initialisation propre à Kanbante vit dans static/js/nav.js (écouteur draco:theme → data-theme + resynchronisation du bouton de bascule, sans écraser le choix local kanbante-theme). """ import hashlib from pathlib import Path R = Path(__file__).resolve().parents[1] SHA256_JS_V050 = "384e2b0248a7c84d77fbb6eae6c25366828554162556a6b5b19c96e188ce11c7" def _sha256(chemin): return hashlib.sha256((R / chemin).read_bytes()).hexdigest() def test_barre_js_verbatim_commons_v050(): assert _sha256("static/js/draco-barre.js") == SHA256_JS_V050 def test_js_theme_commun_hub18(): js = (R / "static/js/draco-barre.js").read_text(encoding="utf-8") assert "api/profil/theme" in js assert 'credentials: "include"' in js assert "draco-theme-hub" in js assert 'CustomEvent("draco:theme"' in js assert "themePref" in js and "themeMode" in js assert "resolvedUrls.hub" in js # Comportements conservés (v0.4.1) : icônes en espace de noms SVG. assert 'createElementNS(SVG_NS, "svg")' in js def test_nav_js_init_theme_hub(): nav = (R / "static/js/nav.js").read_text(encoding="utf-8") assert 'addEventListener(\'draco:theme\'' in nav or 'addEventListener("draco:theme"' in nav assert "appliquerThemeCommun" in nav assert "syncThemeBtn(mode)" in nav assert "DRACO_BAR" in nav and "themeMode" in nav