137 lines
6.8 KiB
Python
137 lines
6.8 KiB
Python
"""
|
|
WTP Playwright E2E FINAL session 19avr · all additions proved
|
|
- WTP home state
|
|
- V80 drawer 105 items
|
|
- V81 Orphans rescue section (new autre Opus)
|
|
- Infrastructure Live Widget (mon apport)
|
|
- Multi-agent chat SSE test
|
|
- Orphans-rescue.html page premium dark (V82)
|
|
"""
|
|
import time, json
|
|
from pathlib import Path
|
|
from playwright.sync_api import sync_playwright
|
|
|
|
TS = time.strftime("%Y%m%d-%H%M%S")
|
|
OUT = Path(f"/var/www/html/test-report/e2e-final-{TS}")
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
results = {"ts": TS, "tests": [], "summary": {}}
|
|
|
|
try:
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True, args=["--no-sandbox"])
|
|
ctx = browser.new_context(
|
|
viewport={"width":1700,"height":1100},
|
|
ignore_https_errors=True,
|
|
record_video_dir=str(OUT),
|
|
record_video_size={"width":1700,"height":1100}
|
|
)
|
|
page = ctx.new_page()
|
|
|
|
# === TEST 1: WTP home ===
|
|
page.goto(f"https://weval-consulting.com/weval-technology-platform.html?e2e={TS}", wait_until="networkidle", timeout=25000)
|
|
time.sleep(8)
|
|
page.screenshot(path=str(OUT/"01-wtp-home.png"), full_page=False)
|
|
home_kpis = page.evaluate("""() => ({
|
|
agents: document.getElementById('vm-gauge-agents')?.textContent?.replace(/\\s+/g,' ').trim(),
|
|
cov: document.getElementById('vm-gauge-cov')?.textContent?.replace(/\\s+/g,' ').trim(),
|
|
ethica: document.getElementById('vm-gauge-ethica')?.textContent?.replace(/\\s+/g,' ').trim(),
|
|
sovereign: document.getElementById('vm-gauge-sovereign')?.textContent?.replace(/\\s+/g,' ').trim(),
|
|
title: document.title
|
|
})""")
|
|
results["tests"].append({"test":"wtp_home", "data":home_kpis, "ok": "906" in (home_kpis.get("agents") or "")})
|
|
print(f" ✓ T1 WTP home: {home_kpis}")
|
|
|
|
# === TEST 2: V80 drawer + V81 orphans section ===
|
|
try:
|
|
page.click("#v80-toggle", timeout=3000)
|
|
time.sleep(4)
|
|
page.screenshot(path=str(OUT/"02-drawer-with-v81.png"), full_page=False)
|
|
drawer_data = page.evaluate("""() => ({
|
|
total_links: [...document.querySelectorAll('#v80-drawer a, #v80-drawer details')].length,
|
|
has_v81_section: !!document.querySelector('#v80-drawer details summary, [id*=v81], [class*=v81]'),
|
|
summary_text: [...document.querySelectorAll('#v80-drawer details summary')].map(s => s.textContent.trim().slice(0,60)).slice(0,5)
|
|
})""")
|
|
results["tests"].append({"test":"v80_drawer_v81", "data":drawer_data})
|
|
print(f" ✓ T2 Drawer + V81: {drawer_data}")
|
|
except Exception as e:
|
|
results["tests"].append({"test":"v80_drawer_v81", "err":str(e)[:100]})
|
|
|
|
# === TEST 3: Infrastructure Widget ===
|
|
page.keyboard.press("Escape")
|
|
time.sleep(2)
|
|
page.evaluate("document.getElementById('wtp-infra-live')?.scrollIntoView({behavior:'instant'})")
|
|
time.sleep(6) # widget fetch
|
|
page.screenshot(path=str(OUT/"03-infra-live.png"), full_page=False)
|
|
infra = page.evaluate("""() => ({
|
|
servers: document.getElementById('infra-servers')?.textContent,
|
|
blade: document.getElementById('infra-blade')?.textContent,
|
|
docker: document.getElementById('infra-docker')?.textContent,
|
|
subdomains: document.getElementById('infra-subdomains')?.textContent,
|
|
load: document.getElementById('infra-load')?.textContent,
|
|
blade_ip: document.getElementById('infra-blade-info')?.textContent,
|
|
servers_detail_count: document.querySelectorAll('#infra-servers-detail div').length
|
|
})""")
|
|
results["tests"].append({"test":"infra_widget", "data":infra, "ok": infra.get("blade") and "ONLINE" in infra.get("blade","")})
|
|
print(f" ✓ T3 Infra: {infra}")
|
|
|
|
# === TEST 4: Orphans-rescue.html V82 premium page ===
|
|
page.goto(f"https://weval-consulting.com/orphans-rescue.html?e2e={TS}", wait_until="networkidle", timeout=15000)
|
|
time.sleep(5)
|
|
page.screenshot(path=str(OUT/"04-orphans-rescue.png"), full_page=True)
|
|
orphans_data = page.evaluate("""() => ({
|
|
title: document.title,
|
|
body_text_len: document.body.innerText.length,
|
|
has_kpis: document.body.innerText.match(/\\d+\\s*orphelins|orphan/i) ? true : false
|
|
})""")
|
|
results["tests"].append({"test":"orphans_rescue_page", "data":orphans_data})
|
|
print(f" ✓ T4 Orphans page: {orphans_data}")
|
|
|
|
# === TEST 5: Multi-agent chat (via API direct · auth chat requires login) ===
|
|
import urllib.request
|
|
req = urllib.request.Request(
|
|
"https://weval-consulting.com/api/wevia-master-api.php?fast=1",
|
|
data=json.dumps({"message":"rescue orphelins"}).encode(),
|
|
headers={'Content-Type': 'application/json'},
|
|
method='POST'
|
|
)
|
|
try:
|
|
import ssl
|
|
r = urllib.request.urlopen(req, timeout=15, context=ssl._create_unverified_context())
|
|
d = json.loads(r.read().decode(errors='replace'))
|
|
results["tests"].append({"test":"chat_rescue_orphelins", "intent":d.get("intent"), "output_len":len(d.get("output",""))})
|
|
print(f" ✓ T5 Chat rescue: intent={d.get('intent')} · output_len={len(d.get('output',''))}")
|
|
except Exception as e:
|
|
results["tests"].append({"test":"chat_rescue_orphelins", "err":str(e)[:100]})
|
|
|
|
# === TEST 6: Truth Registry + Autonomy ===
|
|
try:
|
|
req = urllib.request.Request("https://weval-consulting.com/api/opus5-autonomy-kpi.php")
|
|
r = urllib.request.urlopen(req, timeout=8, context=ssl._create_unverified_context())
|
|
kpi = json.loads(r.read().decode())
|
|
results["tests"].append({"test":"autonomy_kpi", "data": kpi.get("truth")})
|
|
print(f" ✓ T6 Autonomy KPI: {kpi.get('truth')}")
|
|
except Exception as e:
|
|
results["tests"].append({"test":"autonomy_kpi", "err":str(e)[:100]})
|
|
|
|
ctx.close()
|
|
browser.close()
|
|
|
|
videos = list(OUT.glob("*.webm"))
|
|
results["video"] = videos[0].name if videos else None
|
|
pngs = list(OUT.glob("*.png"))
|
|
results["screenshots"] = {p.name: p.stat().st_size for p in pngs}
|
|
|
|
# Summary
|
|
passed = [t for t in results["tests"] if "err" not in t]
|
|
failed = [t for t in results["tests"] if "err" in t]
|
|
results["summary"] = {"passed": len(passed), "failed": len(failed), "total": len(results["tests"])}
|
|
|
|
with open(OUT/"results.json","w") as f:
|
|
json.dump(results, f, indent=2, default=str)
|
|
|
|
print(f"\n ✓ Summary: {results['summary']}")
|
|
print(f" ✓ Video: {results['video']}")
|
|
print(f" ✓ Screenshots: {len(pngs)}")
|
|
except Exception as e:
|
|
print(f"ERR: {e}")
|