#!/usr/bin/env python3 """Six Sigma E2E v2 · fix A03 tips_catalog (GET endpoint) · target 6σ""" 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/six-sigma-v2-{TS}") OUT.mkdir(parents=True, exist_ok=True) # Fix A03: replaced wevia-master-api (POST) with v83-business-kpi (GET) SCENARII = [ ("D01_home", "https://weval-consulting.com/", "DEFINE: Landing client"), ("D02_wevia_training", "https://weval-consulting.com/wevia-training.html", "DEFINE: Training ecosystem"), ("D03_wtp", "https://weval-consulting.com/weval-technology-platform.html", "DEFINE: Platform portal"), ("M01_intelligence", "https://weval-consulting.com/intelligence-growth.html", "MEASURE: Growth KPIs"), ("M02_enterprise", "https://weval-consulting.com/enterprise-complete.html", "MEASURE: 20 depts 169 KPIs"), ("M03_stripe_live", "https://weval-consulting.com/api/stripe-live-bridge.php", "MEASURE: Revenue MRR live"), ("M04_dg_command", "https://weval-consulting.com/api/wevia-v69-dg-command-center.php", "MEASURE: 7 alerts DG + 6 risks"), ("M05_v83_kpi", "https://weval-consulting.com/api/wevia-v83-business-kpi.php?action=summary", "MEASURE: 56 KPIs business"), ("M06_v71_growth", "https://weval-consulting.com/api/wevia-v71-intelligence-growth.php", "MEASURE: V71 intel growth"), ("M07_products_v80", "https://weval-consulting.com/products-kpi-dashboard.php", "MEASURE: V80 products KPI"), ("A01_dsh_predict", "https://weval-consulting.com/api/dsh-predict-api.php", "ANALYZE: Predictive health"), ("A02_release_check", "https://weval-consulting.com/api/release-check.php?window=60", "ANALYZE: Multi-Opus activity"), ("A03_v83_full", "https://weval-consulting.com/api/wevia-v83-business-kpi.php?action=full", "ANALYZE: V83 full 56 KPIs"), # FIX ("I01_vm_widget_test", "https://weval-consulting.com/test-vm-widget.html", "IMPROVE: VM widget DG live"), ("I02_ethica_hub", "https://weval-consulting.com/ethica-hub.html", "IMPROVE: Ethica hub widget"), ("C01_business_kpi_dash", "https://weval-consulting.com/business-kpi-dashboard.php", "CONTROL: Business KPI dashboard"), ("C02_weval_tech_api", "https://weval-consulting.com/api/weval-technology-platform-api.php", "CONTROL: WTP API 160 submodules"), ("C03_nonreg_latest", "https://weval-consulting.com/api/nonreg-latest.json", "CONTROL: NonReg 153/153"), # Extra scenarii for robustness ("C04_opus_registry", "https://weval-consulting.com/api/ecosystem-registry.php?q=wevia", "CONTROL: Ecosystem registry"), ("C05_opus_arch_scan", "https://weval-consulting.com/api/architecture-scan.json", "CONTROL: Architecture scan"), ] results = {"ts": TS, "out": str(OUT), "methodology": "DMAIC 6σ", "total_scenarios": len(SCENARII), "scenarios": []} print(f"[six-sigma v2] {len(SCENARII)} scenarios", flush=True) try: with sync_playwright() as p: browser = p.chromium.launch(headless=True, args=["--no-sandbox", "--disable-dev-shm-usage"]) ctx = browser.new_context( viewport={"width": 1600, "height": 1000}, record_video_dir=str(OUT), record_video_size={"width": 1600, "height": 1000}, ignore_https_errors=True, ) page = ctx.new_page() pass_count = 0; fail_count = 0; total_ms = 0 for slug, url, desc in SCENARII: t0 = time.time() entry = {"slug": slug, "url": url, "description": desc} try: resp = page.goto(url, wait_until="domcontentloaded", timeout=20000) entry["http"] = resp.status if resp else None time.sleep(1.3) page.screenshot(path=str(OUT / f"{slug}.png"), full_page=False) entry["title"] = page.title()[:80] entry["body_len"] = page.evaluate("document.body ? document.body.innerText.length : 0") entry["elapsed_ms"] = round((time.time() - t0) * 1000, 0) if entry["http"] == 200 and entry["body_len"] > 80: entry["status"] = "PASS" pass_count += 1 print(f" ✓ {slug}: {entry['body_len']}b · {entry['elapsed_ms']}ms", flush=True) else: entry["status"] = "FAIL" fail_count += 1 print(f" ✗ {slug}: FAIL http={entry['http']} body={entry['body_len']}", flush=True) total_ms += entry["elapsed_ms"] except Exception as e: entry["error"] = str(e)[:150] entry["status"] = "ERROR" fail_count += 1 print(f" 💥 {slug}: ERROR: {e}", flush=True) results["scenarios"].append(entry) defects = sum(1 for s in results["scenarios"] if s.get("status") in ["FAIL", "ERROR"]) opp = len(SCENARII) dpmo = round((defects / opp) * 1_000_000) if opp else 0 sigma = "6σ (world-class)" if dpmo <= 3.4 else "5σ" if dpmo <= 230 else "4σ" if dpmo <= 6210 else "3σ" if dpmo <= 66807 else "<3σ" results["summary"] = { "pass": pass_count, "fail_or_error": defects, "total": opp, "total_elapsed_ms": total_ms, "avg_ms_per_scenario": round(total_ms / opp, 0), "dpmo": dpmo, "sigma_level": sigma, "pass_rate_pct": round((pass_count / opp) * 100, 2), } ctx.close() browser.close() print(f"\n[6σ v2] {pass_count}/{opp} PASS · DPMO={dpmo} · {sigma}", flush=True) except Exception as e: results["fatal"] = str(e) with open(OUT / "six-sigma-v2-results.json","w") as f: json.dump(results, f, indent=2) videos = list(OUT.glob("*.webm")) print(f"[VIDEO] {len(videos)} · {sum(v.stat().st_size for v in videos) // 1024}KB") print(f"[OUT] {OUT}")