99 lines
4.6 KiB
Python
99 lines
4.6 KiB
Python
"""Validate V85 deprecation banner + V92 Decisions Table chat"""
|
|
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/v85-v92-{TS}")
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
results = {"ts": TS, "tests": []}
|
|
|
|
try:
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True, args=["--no-sandbox"])
|
|
ctx = browser.new_context(
|
|
viewport={"width":1400,"height":900},
|
|
ignore_https_errors=True,
|
|
record_video_dir=str(OUT),
|
|
record_video_size={"width":1400,"height":900}
|
|
)
|
|
page = ctx.new_page()
|
|
|
|
# TEST 1: V85 Portal deprecation (DISABLE redirect to see banner)
|
|
page.goto(f"https://weval-consulting.com/weval-portal.html?no_redirect={TS}", wait_until="domcontentloaded", timeout=15000)
|
|
# Cancel redirect by navigation immediately
|
|
page.evaluate("window.stop()")
|
|
time.sleep(1)
|
|
page.screenshot(path=str(OUT/"01-v85-deprecated.png"), full_page=False)
|
|
banner_text = page.evaluate("""() => {
|
|
const body = document.body.innerText.slice(0, 500);
|
|
return {
|
|
has_deprecated: body.toLowerCase().includes('dépréciée') || body.toLowerCase().includes('deprecated'),
|
|
has_wtp: body.includes('WTP'),
|
|
has_countdown: /\\d+s/.test(body),
|
|
text_preview: body.slice(0, 200)
|
|
};
|
|
}""")
|
|
results["tests"].append({"test":"v85_banner", "data":banner_text})
|
|
print(f" ✓ V85: deprecated={banner_text.get('has_deprecated')} wtp={banner_text.get('has_wtp')}")
|
|
|
|
# TEST 2: V92 Decisions Table summary (API direct)
|
|
import urllib.request, ssl
|
|
try:
|
|
req = urllib.request.Request("https://weval-consulting.com/api/wevia-decisions-api.php?action=summary")
|
|
r = urllib.request.urlopen(req, timeout=10, context=ssl._create_unverified_context())
|
|
d = json.loads(r.read().decode())
|
|
results["tests"].append({"test":"v92_api_summary", "stats":d.get("stats"), "ok": int(d.get("stats",{}).get("total", 0)) > 0})
|
|
print(f" ✓ V92 API: {d.get('stats')}")
|
|
except Exception as e:
|
|
results["tests"].append({"test":"v92_api_summary", "err":str(e)[:100]})
|
|
|
|
# TEST 3: V92 chat intent via API
|
|
req = urllib.request.Request(
|
|
"https://weval-consulting.com/api/wevia-master-api.php?fast=1",
|
|
data=json.dumps({"message":"decisions wevia"}).encode(),
|
|
headers={'Content-Type': 'application/json'},
|
|
method='POST'
|
|
)
|
|
try:
|
|
r = urllib.request.urlopen(req, timeout=15, context=ssl._create_unverified_context())
|
|
d = json.loads(r.read().decode())
|
|
results["tests"].append({
|
|
"test":"v92_chat",
|
|
"intent": d.get("intent"),
|
|
"output_contains_v92": "V92" in d.get("output","") or "Decisions" in d.get("output",""),
|
|
"output_len": len(d.get("output",""))
|
|
})
|
|
print(f" ✓ V92 chat: intent={d.get('intent')} output_len={len(d.get('output',''))}")
|
|
except Exception as e:
|
|
results["tests"].append({"test":"v92_chat", "err":str(e)[:100]})
|
|
|
|
# TEST 4: L99 cron check (via API)
|
|
try:
|
|
req = urllib.request.Request("https://weval-consulting.com/api/nonreg-latest.json")
|
|
r = urllib.request.urlopen(req, timeout=5, context=ssl._create_unverified_context())
|
|
d = json.loads(r.read().decode())
|
|
results["tests"].append({"test":"l99_latest", "score":d.get("score"), "pass":d.get("pass"), "total":d.get("total"), "ts":d.get("ts")})
|
|
print(f" ✓ L99: {d.get('score')}% {d.get('pass')}/{d.get('total')} ts:{d.get('ts')}")
|
|
except Exception as e:
|
|
results["tests"].append({"test":"l99_latest", "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 for p in pngs]
|
|
|
|
passed = [t for t in results["tests"] if "err" not in t]
|
|
results["summary"] = {"passed": len(passed), "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']}")
|
|
except Exception as e:
|
|
print(f"ERR: {e}")
|