108 lines
5.1 KiB
Python
108 lines
5.1 KiB
Python
#!/usr/bin/env python3
|
|
"""V124b - Verify V123 pinning works with new V124-ENRICH split sections"""
|
|
import asyncio, json, os
|
|
from playwright.async_api import async_playwright
|
|
|
|
OUT = "/var/www/html/api/blade-tasks/v124b-enrich-verify"
|
|
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(str(e)))
|
|
|
|
await page.goto("https://weval-consulting.com/all-ia-hub.html?v=v124b", wait_until='load', timeout=30000)
|
|
await page.wait_for_timeout(2000)
|
|
await page.click('[data-view="dashboards"]')
|
|
await page.wait_for_timeout(3500)
|
|
|
|
# Initial
|
|
initial = await page.evaluate("""() => ({
|
|
has_pinned_section: !!document.getElementById('dash-pinned-section'),
|
|
pinned_section_display: document.getElementById('dash-pinned-section')?.style.display,
|
|
grid_tiles: document.querySelectorAll('#dash-grid a').length,
|
|
pinned_tiles: document.querySelectorAll('#dash-pinned-section a').length
|
|
})""")
|
|
print("Initial:", json.dumps(initial))
|
|
|
|
# Pin ethica
|
|
await page.evaluate("__dashTogglePin('ethica-dashboard-live.html')")
|
|
await page.wait_for_timeout(800)
|
|
|
|
after_pin = await page.evaluate("""() => ({
|
|
pinned_section_display: document.getElementById('dash-pinned-section')?.style.display,
|
|
grid_tiles: document.querySelectorAll('#dash-grid a').length,
|
|
pinned_tiles: document.querySelectorAll('#dash-pinned-section a').length,
|
|
pinned_first: document.querySelector('#dash-pinned-section a')?.href.split('/').pop(),
|
|
hash: window.location.hash
|
|
})""")
|
|
print("After pin ethica:", json.dumps(after_pin, indent=2))
|
|
await page.screenshot(path=f"{OUT}/01-pinned-ethica.png", full_page=True)
|
|
|
|
# Pin crm
|
|
await page.evaluate("__dashTogglePin('crm-dashboard-live.html')")
|
|
await page.wait_for_timeout(800)
|
|
|
|
after_two = await page.evaluate("""() => ({
|
|
pinned_tiles: document.querySelectorAll('#dash-pinned-section a').length,
|
|
grid_tiles: document.querySelectorAll('#dash-grid a').length
|
|
})""")
|
|
print("After 2 pins:", json.dumps(after_two))
|
|
|
|
# Unpin both via clear button if exists
|
|
clear = await page.query_selector('#dash-clear-pins, [id*="clear"]')
|
|
await page.screenshot(path=f"{OUT}/02-two-pinned.png", full_page=True)
|
|
|
|
# Clean manually
|
|
await page.evaluate("__dashTogglePin('ethica-dashboard-live.html')")
|
|
await page.evaluate("__dashTogglePin('crm-dashboard-live.html')")
|
|
await page.wait_for_timeout(500)
|
|
|
|
after_clear = await page.evaluate("""() => ({
|
|
pinned_section_display: document.getElementById('dash-pinned-section')?.style.display,
|
|
pinned_tiles: document.querySelectorAll('#dash-pinned-section a').length,
|
|
grid_tiles: document.querySelectorAll('#dash-grid a').length,
|
|
hash: window.location.hash
|
|
})""")
|
|
print("After clear:", json.dumps(after_clear))
|
|
|
|
await ctx.close()
|
|
await browser.close()
|
|
|
|
verdict = 'OK' if (
|
|
initial['has_pinned_section'] and
|
|
initial['pinned_section_display'] == 'none' and # hidden when 0 pins
|
|
initial['grid_tiles'] == 69 and
|
|
after_pin['pinned_section_display'] == 'block' and # shown when pinned
|
|
after_pin['pinned_tiles'] == 1 and
|
|
after_pin['grid_tiles'] == 68 and # reduced by 1
|
|
after_pin['pinned_first'] == 'ethica-dashboard-live.html' and
|
|
after_two['pinned_tiles'] == 2 and
|
|
after_two['grid_tiles'] == 67 and
|
|
after_clear['pinned_tiles'] == 0 and
|
|
after_clear['grid_tiles'] == 69 and
|
|
not errs
|
|
) else 'PARTIAL'
|
|
|
|
report = {
|
|
'v124b': 'enrich-split-sections-verify',
|
|
'has_pinned_section': initial['has_pinned_section'],
|
|
'hidden_when_empty': initial['pinned_section_display'] == 'none',
|
|
'shown_when_pinned': after_pin['pinned_section_display'] == 'block',
|
|
'pin_moves_to_pinned_section': after_pin['pinned_tiles'] == 1 and after_pin['grid_tiles'] == 68,
|
|
'pinned_visible_in_section': after_pin['pinned_first'] == 'ethica-dashboard-live.html',
|
|
'two_pins_split_correctly': after_two['pinned_tiles'] == 2 and after_two['grid_tiles'] == 67,
|
|
'unpin_restores_grid': after_clear['pinned_tiles'] == 0 and after_clear['grid_tiles'] == 69,
|
|
'url_hash_works': 'pins=' in after_pin['hash'],
|
|
'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())
|