33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
from pathlib import Path
|
|
import re
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
STATIC_DIR = ROOT / "static"
|
|
|
|
|
|
def test_base_template_owns_sidebar_and_user_shell():
|
|
forbidden_patterns = [
|
|
(r'id=["\']sidebar["\']', "sidebar element"),
|
|
(r'class=["\']sidebar["\']', "sidebar class"),
|
|
(r"\bsidebar-user\b", "sidebar user trigger"),
|
|
(r"\buserDropdown\b", "user dropdown"),
|
|
(r"\buserInitial\b", "user initial"),
|
|
(r"\buserEmailShort\b", "user email"),
|
|
(r"\bddEmail\b", "dropdown email"),
|
|
(r"\bfunction\s+toggleUserMenu\s*\(", "toggleUserMenu"),
|
|
(r"\basync\s+function\s+loadUser\s*\(", "loadUser"),
|
|
(r"\bfunction\s+showChangePwd\s*\(", "showChangePwd"),
|
|
(r"\bfunction\s+closePwdModal\s*\(", "closePwdModal"),
|
|
(r"\basync\s+function\s+changePwd\s*\(", "changePwd"),
|
|
(r"\basync\s+function\s+doLogout\s*\(", "doLogout"),
|
|
]
|
|
for path in STATIC_DIR.glob("*.html"):
|
|
if path.name in {"base.html", "index.html"}:
|
|
continue
|
|
text = path.read_text(encoding="utf-8")
|
|
if "extends \"base.html\"" not in text and "extends 'base.html'" not in text:
|
|
continue
|
|
for pattern, label in forbidden_patterns:
|
|
assert not re.search(pattern, text), f"{path.name} should inherit shell behavior from base.html, found {label}"
|