Files
weval-l99/growth-quick-test.py
2026-04-13 12:43:21 +02:00

110 lines
4.5 KiB
Python

from playwright.sync_api import sync_playwright
import json, os, time
os.makedirs('/var/www/html/api/screenshots', exist_ok=True)
results = []
with sync_playwright() as p:
b = p.chromium.launch(headless=True, args=['--no-sandbox'])
ctx = b.new_context(viewport={"width":1920,"height":1080}, ignore_https_errors=True,
record_video_dir="/opt/weval-l99/videos/growth-quick",
record_video_size={"width":1920,"height":1080})
pg = ctx.new_page()
# Auth via localhost (pas cloudflare)
pg.goto("https://127.0.0.1/login", timeout=10000)
time.sleep(1)
try:
pg.fill("input[name=user]", "yacine")
pg.fill("input[name=pass]", "Weval@2026")
pg.click("button[type=submit]")
time.sleep(2)
results.append({"test":"auth","ok":True})
except Exception as e:
results.append({"test":"auth","ok":False,"err":str(e)[:80]})
# Page 1: agents-archi
pg.goto("https://127.0.0.1/agents-archi.html", timeout=30000)
time.sleep(5)
pg.screenshot(path="/var/www/html/api/screenshots/agents-archi-full.png")
growth = "Growth" in pg.evaluate("document.body.innerText")
canvas = pg.evaluate("!!document.querySelector('canvas')")
cards = pg.evaluate("document.querySelectorAll('.ag-card').length")
results.append({"test":"agents-archi-growth","ok":growth})
results.append({"test":"agents-archi-3d","ok":canvas})
results.append({"test":"agents-archi-cards","ok":cards>20,"detail":f"{cards} cards"})
# Cinematic: wait and take screenshots
for i in range(3):
time.sleep(3)
pg.screenshot(path=f"/var/www/html/api/screenshots/agents-archi-cinema-{i}.png")
# Page 2: enterprise-model
pg.goto("https://127.0.0.1/enterprise-model.html", timeout=30000)
time.sleep(5)
pg.screenshot(path="/var/www/html/api/screenshots/enterprise-full.png")
growth_ent = "Growth" in pg.evaluate("document.body.innerText")
canvas_ent = pg.evaluate("!!document.querySelector('canvas')")
results.append({"test":"enterprise-growth","ok":growth_ent})
results.append({"test":"enterprise-3d","ok":canvas_ent})
for i in range(3):
time.sleep(3)
pg.screenshot(path=f"/var/www/html/api/screenshots/enterprise-cinema-{i}.png")
# Page 3: meeting-rooms
pg.goto("https://127.0.0.1/wevia-meeting-rooms.html", timeout=30000)
time.sleep(5)
pg.screenshot(path="/var/www/html/api/screenshots/meeting-full.png")
growth_meet = "Growth" in pg.evaluate("document.body.innerText")
results.append({"test":"meeting-growth","ok":growth_meet})
for i in range(3):
time.sleep(3)
pg.screenshot(path=f"/var/www/html/api/screenshots/meeting-cinema-{i}.png")
# Page 4: growth-engine
pg.goto("https://127.0.0.1/growth-engine.html", timeout=30000)
time.sleep(3)
pg.screenshot(path="/var/www/html/api/screenshots/growth-dashboard.png")
kpis = pg.evaluate("document.querySelectorAll('.kpi').length")
pipe = pg.evaluate("document.querySelectorAll('.pipe-col').length")
chat = pg.evaluate("!!document.querySelector('.chat-box')")
results.append({"test":"growth-kpis","ok":kpis>=4,"detail":f"{kpis}"})
results.append({"test":"growth-pipeline","ok":pipe>=3,"detail":f"{pipe}"})
results.append({"test":"growth-chat","ok":chat})
# Test tabs
for tab in ['opportunities','actions','assets','intel']:
try:
pg.evaluate(f"document.querySelectorAll('.tab').forEach(t => {{ if(t.dataset && t.dataset.t === '{tab}') t.click() }})")
time.sleep(1)
pg.screenshot(path=f"/var/www/html/api/screenshots/growth-tab-{tab}.png")
results.append({"test":f"growth-tab-{tab}","ok":True})
except:
results.append({"test":f"growth-tab-{tab}","ok":False})
ctx.close()
b.close()
passed = sum(1 for r in results if r['ok'])
total = len(results)
print(f"\nSCORE: {passed}/{total}")
for r in results:
print(f" {'PASS' if r['ok'] else 'FAIL'} {r['test']} {r.get('detail','')}")
json.dump({"results":results,"passed":passed,"total":total,"ts":time.strftime("%c")},
open("/opt/weval-l99/growth-visual-test-results.json","w"), indent=2)
# List screenshots
import glob
shots = glob.glob("/var/www/html/api/screenshots/*.png")
print(f"\n{len(shots)} screenshots saved")
# List videos
vids = glob.glob("/opt/weval-l99/videos/growth-quick/*.webm")
print(f"{len(vids)} videos saved")
for v in vids:
print(f" {os.path.basename(v)}: {round(os.path.getsize(v)/1024)}KB")