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

96 lines
3.7 KiB
Python

#!/usr/bin/env python3
"""V128 E2E - Test scroll-to-top button appears/hides + works"""
import asyncio, json, os
from playwright.async_api import async_playwright
OUT = "/var/www/html/api/blade-tasks/v128-scroll-top-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(str(e)))
await page.goto("https://weval-consulting.com/all-ia-hub.html?v=v128", wait_until='load', timeout=30000)
await page.wait_for_timeout(2000)
await page.click('[data-view="dashboards"]')
await page.wait_for_timeout(3500)
# Initial: button exists, hidden (not scrolled)
initial = await page.evaluate("""() => {
const b = document.getElementById('dash-scroll-top');
return {
exists: !!b,
display: b?.style.display,
scroll_y: window.scrollY
};
}""")
print("Initial:", json.dumps(initial))
# Scroll down 600px
await page.evaluate("window.scrollTo(0, 600)")
await page.wait_for_timeout(600)
after_scroll = await page.evaluate("""() => {
const b = document.getElementById('dash-scroll-top');
return {
display: b?.style.display,
scroll_y: window.scrollY
};
}""")
print("After scroll 600px:", json.dumps(after_scroll))
await page.screenshot(path=f"{OUT}/01-scrolled.png", full_page=False)
# Click scroll-to-top
if after_scroll['display'] == 'block':
await page.click('#dash-scroll-top')
await page.wait_for_timeout(1500)
after_click = await page.evaluate("""() => ({
scroll_y: window.scrollY,
btn_display: document.getElementById('dash-scroll-top')?.style.display
})""")
print("After click scroll-top:", json.dumps(after_click))
# Switch tab - button should hide
await page.click('[data-view="chat"]')
await page.wait_for_timeout(600)
await page.evaluate("window.scrollTo(0, 600)")
await page.wait_for_timeout(500)
tab_switch = await page.evaluate("""() => ({
btn_display: document.getElementById('dash-scroll-top')?.style.display,
active_tab: document.querySelector('.tab.on')?.textContent?.trim()
})""")
print("After switch to CHAT + scroll:", json.dumps(tab_switch))
await ctx.close()
await browser.close()
verdict = 'OK' if (
initial['exists'] and
(initial['display'] == 'none' or initial['display'] == '') and
after_scroll['display'] == 'block' and
after_click['scroll_y'] < 100 and
tab_switch['btn_display'] == 'none' and
not errs
) else 'PARTIAL'
report = {
'v128': 'scroll-to-top-button',
'button_exists': initial['exists'],
'hidden_when_top': initial['display'] in ('none',''),
'shown_when_scrolled': after_scroll['display'] == 'block',
'click_scrolls_up': after_click['scroll_y'] < 100,
'hidden_other_tab': tab_switch['btn_display'] == 'none',
'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())