#!/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)