test_verify_skills.py
1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/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)