test_skills_search.py
2.18 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
#!/usr/bin/env python3
"""Test: Skills page search/filter/sort functionality"""
import subprocess, sys, json
BASE = "http://127.0.0.1:5001"
FAIL = 0
def check(label, condition):
global FAIL
if condition:
print(f" ✅ {label}")
else:
print(f" ❌ {label}")
FAIL += 1
# 1. Page returns 200
r = subprocess.run(["curl", "-so", "/dev/null", "-w", "%{http_code}", f"{BASE}/skills"],
capture_output=True, text=True, timeout=10)
check("GET /skills → 200", r.stdout.strip() == "200")
# 2. Get page HTML
r = subprocess.run(["curl", "-s", f"{BASE}/skills"],
capture_output=True, text=True, timeout=10)
html = r.stdout
# 3. Search input exists
check("Search input #skill-search exists", 'id="skill-search"' in html)
# 4. Filter select exists
check("Filter select #skill-filter exists", 'id="skill-filter"' in html)
# 5. Sort function exists
check("Sort function in JS", 'sort' in html.lower() and ('sortCol' in html or 'sortKey' in html or 'sortColumn' in html or 'sortBy' in html))
# 6. Filter function exists
check("Filter function in JS", 'filter' in html.lower() and ('filterSkills' in html or 'renderTable' in html))
# 7. Search handler exists
check("Search input handler", 'oninput' in html or 'addEventListener' in html or 'onkeyup' in html)
# 8. JS no escape bugs
check("No style backslash bug", "style=\\\\\\" not in html)
check("No onclick escaped quotes bug", 'onclick=\\\\"event' not in html)
check("No triple escape bug", '\\\\\\\\\\\\\\"' not in html)
# 9. Skills data rendered (count element)
check("Skills count displayed", '共' in html and ('skills' in html.lower() or 'Skills' in html))
# 10. Table headers are interactive (clickable)
check("Table headers clickable", 'onclick' in html or 'addEventListener' in html)
# 11. Responsive CSS for mobile
check("Mobile responsive controls", '@media' in html or 'max-width' in html or 'flex-wrap' in html)
# 12. Sort indicator (▲/▼) logic
check("Sort direction indicators", '▲' in html or '▼' in html or 'asc' in html.lower())
print(f"\n{'='*40}")
if FAIL == 0:
print(f"ALL 12 CHECKS PASSED ✅")
sys.exit(0)
else:
print(f"FAILED: {FAIL}/12 checks ❌")
sys.exit(1)