test_frontend_s1.py 903 Bytes
#!/usr/bin/env python3
"""Frontend verify: /messages page JS sanity."""
import subprocess, sys

r = subprocess.run(
    ["curl", "-s", "http://127.0.0.1:5000/messages", "--connect-timeout", "5", "--max-time", "10"],
    capture_output=True, text=True, timeout=15
)
html = r.stdout

checks = [
    ("STYLE BACKSLASH BUG", "style=\\\\\\'" not in html),
    ("JINJA2 ESCAPED QUOTES", 'data-action=\\"' not in html),
    ("INLINE ONCLICK ESCAPED", 'onclick=\\"event' not in html),
    ("Has 消息浏览", "消息浏览" in html),
    ("Has toggleDrawer", "toggleDrawer" in html),
    ("Has menu-btn", "menu-btn" in html),
]

all_ok = True
for name, ok in checks:
    status = "✅" if ok else "❌"
    if not ok:
        all_ok = False
    print(f"  {status} {name}")

if all_ok:
    print("\nFRONTEND VERIFY: ALL CLEAN")
    sys.exit(0)
else:
    print("\nFRONTEND VERIFY: ISSUES FOUND")
    sys.exit(1)