Files
weval-l99/v126_proof.py
2026-04-24 04:38:58 +02:00

109 lines
5.4 KiB
Python

#!/usr/bin/env python3
"""V126 E2E - Proof V124 (clear/section/recent) + V125 (theme)"""
import asyncio, json, os
from playwright.async_api import async_playwright
OUT = "/var/www/html/api/blade-tasks/v126-proof"
os.makedirs(OUT, exist_ok=True)
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True, args=['--no-sandbox'])
ctx = await browser.new_context(viewport={'width':1920,'height':1080}, record_video_dir=OUT)
page = await ctx.new_page()
errs = []
page.on('pageerror', lambda e: errs.append(f"pageerror: {e}"))
page.on('console', lambda m: errs.append(f"console-err: {m.text}") if m.type == 'error' else None)
await page.goto("https://weval-consulting.com/all-ia-hub.html?v=v126", wait_until='load', timeout=30000)
await page.wait_for_timeout(2000)
await page.click('[data-view="dashboards"]')
await page.wait_for_timeout(3500)
# Test V124: initial state — clear button hidden, pinned section hidden
initial = await page.evaluate("""() => ({
tiles_rest: document.querySelectorAll('#dash-grid a').length,
pinned_section_display: document.getElementById('dash-pinned-section')?.style.display,
clear_btn_display: document.getElementById('dash-clear-pins')?.style.display,
recent_badges: document.querySelectorAll('#dash-grid .dash-tile span[title*="Updated"]').length
})""")
print("V124 initial:", json.dumps(initial, indent=2))
await page.screenshot(path=f"{OUT}/01-initial.png", full_page=True)
# Pin 2 dashboards via JS
await page.evaluate("__dashTogglePin('ethica-dashboard-live.html')")
await page.wait_for_timeout(500)
await page.evaluate("__dashTogglePin('crm-dashboard-live.html')")
await page.wait_for_timeout(800)
after_pin = await page.evaluate("""() => ({
pinned_section_display: document.getElementById('dash-pinned-section')?.style.display,
pinned_grid_tiles: document.querySelectorAll('#dash-pinned-grid a').length,
rest_grid_tiles: document.querySelectorAll('#dash-grid a').length,
pinned_count_text: document.getElementById('dash-pinned-count')?.textContent,
clear_btn_display: document.getElementById('dash-clear-pins')?.style.display,
clear_btn_visible: !!document.querySelector('#dash-clear-pins:not([style*=\"display: none\"])')
})""")
print("\nV124 after 2 pins:", json.dumps(after_pin, indent=2))
await page.screenshot(path=f"{OUT}/02-pinned-section.png", full_page=True)
# Test V125: theme toggle
before_theme = await page.evaluate("() => ({body_class: document.body.className, hash: window.location.hash})")
print("\nV125 before toggle:", json.dumps(before_theme))
await page.click('#theme-toggle')
await page.wait_for_timeout(500)
after_theme = await page.evaluate("""() => ({
body_class: document.body.className,
hash: window.location.hash,
bg_color: getComputedStyle(document.body).getPropertyValue('--bg').trim()
})""")
print("V125 after toggle:", json.dumps(after_theme))
await page.screenshot(path=f"{OUT}/03-light-theme.png", full_page=True)
# Test V124 clear pins (with dialog handling)
page.on('dialog', lambda d: asyncio.create_task(d.accept()))
await page.click('#dash-clear-pins')
await page.wait_for_timeout(1000)
after_clear = await page.evaluate("""() => ({
pinned_section_display: document.getElementById('dash-pinned-section')?.style.display,
clear_btn_display: document.getElementById('dash-clear-pins')?.style.display,
rest_grid_tiles: document.querySelectorAll('#dash-grid a').length,
hash: window.location.hash
})""")
print("\nV124 after clear:", json.dumps(after_clear, indent=2))
await page.screenshot(path=f"{OUT}/04-after-clear.png", full_page=True)
# Toggle theme back to dark for final state
await page.click('#theme-toggle')
await page.wait_for_timeout(400)
final_theme = await page.evaluate("() => ({body_class: document.body.className})")
await ctx.close()
await browser.close()
v124_section = after_pin['pinned_grid_tiles'] == 2
v124_clear = after_clear['pinned_section_display'] == 'none' and after_clear['rest_grid_tiles'] == 69
v125_theme = 'light' in (after_theme.get('body_class') or '') and 'theme=light' in (after_theme.get('hash') or '')
v125_revert = 'light' not in final_theme.get('body_class', '')
verdict = 'WIRED' if (v124_section and v124_clear and v125_theme and v125_revert and not errs) else 'PARTIAL'
report = {
'v126': 'V124-V125-proof',
'v124_pinned_section_shown': v124_section,
'v124_clear_works': v124_clear,
'v125_light_theme_applied': v125_theme,
'v125_revert_to_dark': v125_revert,
'js_errors': errs[:3],
'VERDICT': verdict
}
with open(f"{OUT}/proof.json",'w') as f: json.dump(report, f, indent=2)
print("\n=== VERDICT:", verdict)
print(json.dumps(report, indent=2))
asyncio.run(main())