#!/usr/bin/env python3 """ Playwright E2E Test — WEVIA Orchestrator Tests: page load, stats, agents, tools, sidebar, execute, API """ import subprocess, json, sys, time results = [] def test(name, cmd, check): try: r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=20) out = r.stdout.strip() ok = check(out) results.append({"name": name, "status": "PASS" if ok else "FAIL", "detail": out[:60]}) print(f" {'PASS' if ok else 'FAIL'}: {name}") return ok except Exception as e: results.append({"name": name, "status": "FAIL", "detail": str(e)[:60]}) print(f" FAIL: {name} -> {e}") return False print("WEVIA ORCHESTRATOR — PLAYWRIGHT E2E TEST") print("=" * 50) # --- SECTION 1: PAGE LOAD --- print("\n[1] PAGE LOAD") test("page_status_200", "curl -sf -o /dev/null -w '%{http_code}' 'https://weval-consulting.com/wevia-orchestrator.html'", lambda o: o == "200") test("page_has_godmode", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c 'GODMODE'", lambda o: int(o) >= 1) test("page_has_orchestrator_title", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c 'WEVIA ORCHESTRATOR'", lambda o: int(o) >= 1) # --- SECTION 2: STATS HEADER --- print("\n[2] STATS HEADER") test("stat_agents_present", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c 'st-agents'", lambda o: int(o) >= 1) test("stat_tools_present", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c 'st-tools'", lambda o: int(o) >= 1) test("stat_hcps_141K", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c '141K'", lambda o: int(o) >= 1) test("stat_nonreg_152", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c '152'", lambda o: int(o) >= 1) test("stat_fastpath_31", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c '31/31'", lambda o: int(o) >= 1) # --- SECTION 3: API ORCHESTRATOR --- print("\n[3] API ORCHESTRATOR") test("api_returns_json", "curl -sf 'https://weval-consulting.com/api/orchestrator-agents.php'", lambda o: '"ok":true' in o or '"ok": true' in o) test("api_24_realtime_agents", "curl -sf 'https://weval-consulting.com/api/orchestrator-agents.php'", lambda o: '"realtime":24' in o.replace(' ','')) test("api_407_tools", "curl -sf 'https://weval-consulting.com/api/orchestrator-agents.php'", lambda o: any(str(n) in o for n in range(400, 500))) test("api_blade_agent_exists", "curl -sf 'https://weval-consulting.com/api/orchestrator-agents.php'", lambda o: 'blade_agent' in o.lower() or 'Blade' in o) test("api_141K_hcps", "curl -sf 'https://weval-consulting.com/api/orchestrator-agents.php'", lambda o: '141K' in o) # --- SECTION 4: SIDEBAR SERVICES --- print("\n[4] SIDEBAR SERVICES") test("sidebar_searxng", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c 'SearXNG'", lambda o: int(o) >= 1) test("sidebar_qdrant", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c 'Qdrant'", lambda o: int(o) >= 1) test("sidebar_gitea", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c 'Gitea'", lambda o: int(o) >= 1) test("sidebar_dynamic_resolver", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c 'Dynamic Resolver'", lambda o: int(o) >= 1) test("sidebar_sentinel_s95", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c 'Sentinel'", lambda o: int(o) >= 1) test("sidebar_ethica_hcp", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c 'Ethica HCP'", lambda o: int(o) >= 1) test("sidebar_email_pipeline", "curl -sf 'https://weval-consulting.com/wevia-orchestrator.html' | grep -c 'Email Pipeline'", lambda o: int(o) >= 1) # --- SECTION 5: AGENTS LIST --- print("\n[5] AGENTS LIST") for agent in ["Infra", "Sovereign", "NonReg", "Ethica", "Git", "Docker", "Blade", "DeerFlow", "Paperclip", "L99"]: test(f"agent_{agent.lower()}_present", f"curl -sf 'https://weval-consulting.com/api/orchestrator-agents.php' | grep -c '{agent}'", lambda o: int(o) >= 1) # --- SECTION 6: MULTIAGENT EXECUTION --- print("\n[6] MULTIAGENT EXECUTION") test("execute_ping", "curl -sf -X POST 'https://weval-consulting.com/api/wevia-master-api.php' -H 'Content-Type: application/json' -d '{\"message\":\"ping\"}'", lambda o: 'S95' in o or 'Groq' in o) test("execute_nonreg", "curl -sf -X POST 'https://weval-consulting.com/api/wevia-master-api.php' -H 'Content-Type: application/json' -d '{\"message\":\"nonreg\"}'", lambda o: '152' in o) test("execute_ethica", "curl -sf -X POST 'https://weval-consulting.com/api/wevia-master-api.php' -H 'Content-Type: application/json' -d '{\"message\":\"ethica\"}'", lambda o: '141' in o) test("execute_docker", "curl -sf -X POST 'https://weval-consulting.com/api/wevia-master-api.php' -H 'Content-Type: application/json' -d '{\"message\":\"docker\"}'", lambda o: 'redis' in o.lower() or 'langfuse' in o.lower()) test("execute_send_status", "curl -sf -X POST 'https://weval-consulting.com/api/wevia-master-api.php' -H 'Content-Type: application/json' -d '{\"message\":\"send status\"}'", lambda o: 'PMTA' in o or 'brain' in o.lower()) # --- SECTION 7: CAPABILITIES --- print("\n[7] CAPABILITIES") test("capability_cx_endpoint", "curl -sf -X POST 'https://weval-consulting.com/api/cx' -d 'k=WEVADS2026&c=ZWNobyBPSw==' | head -1", lambda o: 'OK' in o) test("capability_consent_api", "curl -sf 'https://consent.wevup.app/api/ethica-consent-api.php?action=stats'", lambda o: 'optin' in o) test("capability_feed_api", "curl -sf 'https://weval-consulting.com/api/ethica-feed-api.php'", lambda o: '"feed"' in o and '"msg"' in o) # --- SUMMARY --- passed = sum(1 for r in results if r["status"] == "PASS") total = len(results) pct = round(passed/total*100) if total else 0 print(f"\n{'='*50}") print(f"ORCHESTRATOR E2E: {passed}/{total} ({pct}%)") print(f"{'='*50}") json.dump({"ts": __import__("datetime").datetime.now().isoformat(), "tests": results, "pass": passed, "total": total, "pct": pct}, open("/opt/weval-l99/orchestrator-e2e-results.json", "w"), indent=2)