58 lines
2.2 KiB
Python
58 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""V135 E2E - KPI banner live fetches health, updates text, shows health dot"""
|
|
import asyncio, json, os
|
|
from playwright.async_api import async_playwright
|
|
|
|
OUT = "/var/www/html/api/blade-tasks/v135-kpi-banner-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})
|
|
page = await ctx.new_page()
|
|
errs = []
|
|
page.on('pageerror', lambda e: errs.append(str(e)))
|
|
|
|
await page.goto("https://weval-consulting.com/all-ia-hub.html?v=v135", wait_until='load', timeout=30000)
|
|
await page.wait_for_timeout(4000) # wait for fetch
|
|
|
|
state = await page.evaluate("""() => {
|
|
const kpi = document.getElementById('v135-kpi-live');
|
|
return {
|
|
exists: !!kpi,
|
|
innerHTML: kpi?.innerHTML,
|
|
title: kpi?.title,
|
|
contains_pct: kpi?.innerHTML?.includes('%'),
|
|
contains_dot: kpi?.innerHTML?.includes('🟢') || kpi?.innerHTML?.includes('🟡') || kpi?.innerHTML?.includes('🔴')
|
|
};
|
|
}""")
|
|
print("V135 KPI banner state:", json.dumps(state, indent=2))
|
|
await page.screenshot(path=f"{OUT}/01-kpi-banner-top.png", clip={'x':0,'y':0,'width':1920,'height':100})
|
|
|
|
await ctx.close()
|
|
await browser.close()
|
|
|
|
verdict = 'OK' if (
|
|
state['exists'] and
|
|
state['contains_pct'] and
|
|
state['contains_dot'] and
|
|
not errs
|
|
) else 'PARTIAL'
|
|
|
|
report = {
|
|
'v135': 'kpi-banner-live',
|
|
'banner_exists': state['exists'],
|
|
'fetches_health_live': state['contains_pct'],
|
|
'shows_status_dot': state['contains_dot'],
|
|
'innerHTML_preview': state['innerHTML'],
|
|
'title_preview': state['title'],
|
|
'js_errors': errs,
|
|
'VERDICT': verdict
|
|
}
|
|
with open(f"{OUT}/proof.json",'w') as f: json.dump(report, f, indent=2)
|
|
print("=== VERDICT:", verdict)
|
|
print(json.dumps(report, indent=2))
|
|
|
|
asyncio.run(main())
|