#!/usr/bin/env python3 """VERIFY: Skills page smoketest + JS cleanliness + key elements""" import subprocess, sys BASE = "http://127.0.0.1:5001" FAIL = 0 # === Smoketest === print("=== Smoketest ===") for page in ["/", "/articles", "/learn", "/reports", "/skills"]: r = subprocess.run(["curl", "-so", "/dev/null", "-w", "%{http_code}", f"{BASE}{page}"], capture_output=True, text=True, timeout=10) ok = r.stdout.strip() == "200" print(f" {'✅' if ok else '❌'} {page} → {r.stdout.strip()}") if not ok: FAIL += 1 # === JS Cleanliness === print("\n=== JS Cleanliness ===") r = subprocess.run(["curl", "-s", f"{BASE}/skills"], capture_output=True, text=True, timeout=10) html = r.stdout bugs = [ ("STYLE BACKSLASH BUG", "style=\\\\\\"), ("ONCLICK ESCAPED", 'onclick=\\"event'), ("TRIPLE ESCAPE BUG", '\\\\\\\\\\\\\\"'), ] ok = True for name, pat in bugs: if pat in html: print(f" ❌ {name}") ok = False FAIL += 1 if 'data-action=' not in html: print(" ❌ MISSING data-action") ok = False FAIL += 1 if ok: print(" ✅ JS CLEAN") # === Key Elements === print("\n=== Key Elements ===") checks = [ ("search input", 'id="skill-search"'), ("filter select", 'id="skill-filter"'), ("sortBy function", "function sortBy"), ("renderTable function", "function renderTable"), ("getFilteredSkills function", "function getFilteredSkills"), ("sortSkill function", "function sortSkill"), ("allSkills variable", "var allSkills"), ("sort arrows ▲", "▲"), ("sort arrows ▼", "▼"), ("mobile responsive", "@media"), ("skills count", "共"), ] all_ok = True for label, pat in checks: ok = pat in html print(f" {'✅' if ok else '❌'} {label}") if not ok: all_ok = False FAIL += 1 print(f"\n{'='*40}") if FAIL == 0: print("VERIFY COMPLETE: All checks passed ✅") sys.exit(0) else: print(f"VERIFY FAILED: {FAIL} checks ❌") sys.exit(1)