62 lines
3.2 KiB
Python
62 lines
3.2 KiB
Python
import asyncio, json
|
|
from playwright.async_api import async_playwright
|
|
|
|
VERSIONS = [("/", "v1"), ("/v2/", "v2"), ("/v3/", "v3")]
|
|
VIEWS = ["dashboard", "calendar", "weekly", "monthly", "roadmap", "tasks", "sync"]
|
|
|
|
async def main():
|
|
async with async_playwright() as p:
|
|
b = await p.chromium.launch(args=["--no-sandbox"])
|
|
out = {}
|
|
for base, tag in VERSIONS:
|
|
pg = await b.new_page(viewport={"width": 1600, "height": 1100}, device_scale_factor=1.5)
|
|
errs = []
|
|
pg.on("pageerror", lambda e: errs.append(f"PAGEERR {e}"))
|
|
pg.on("console", lambda m: errs.append(f"CONSOLE {m.text}") if m.type == "error" else None)
|
|
await pg.goto("https://parastoo.zebellkhan.com" + base, wait_until="networkidle", timeout=90000)
|
|
await pg.wait_for_timeout(3000)
|
|
res = await pg.evaluate("""() => ({
|
|
title: document.title,
|
|
tabs: document.querySelectorAll('nav.tabs button').length,
|
|
active: document.querySelector('nav.tabs button.active')?.dataset.view,
|
|
dir: document.documentElement.dir,
|
|
font: getComputedStyle(document.querySelector('.card-title')).fontFamily.split(',')[0],
|
|
overflow: document.documentElement.scrollWidth - document.documentElement.clientWidth,
|
|
plots: document.querySelectorAll('.js-plotly-plot').length,
|
|
fontsLoaded: [...document.fonts].filter(f=>f.status==='loaded').length
|
|
})""")
|
|
# tasks tab content check
|
|
await pg.click('nav.tabs button[data-view="tasks"]')
|
|
await pg.wait_for_timeout(1500)
|
|
res["tasks_tab"] = await pg.evaluate("""() => ({
|
|
cards: document.querySelectorAll('#view-tasks .card').length,
|
|
listItems: document.querySelectorAll('#view-tasks .task-list-ul li').length,
|
|
kpis: document.querySelectorAll('#view-tasks .kpi').length,
|
|
textLen: document.getElementById('view-tasks').innerText.length
|
|
})""")
|
|
# per-view overflow
|
|
vh = {}
|
|
for v in VIEWS:
|
|
await pg.click(f'nav.tabs button[data-view="{v}"]')
|
|
await pg.wait_for_timeout(1200)
|
|
vh[v] = await pg.evaluate("""(v) => {
|
|
const el = document.getElementById('view-'+v);
|
|
let mo = 0;
|
|
el.querySelectorAll('.card,.kpi,.day,.task-row,.phase,.heat-cell,table,li').forEach(x=>{
|
|
const o = x.scrollWidth - x.clientWidth;
|
|
if(o > 2 && getComputedStyle(x).overflowX==='visible' && o > mo) mo = o;
|
|
});
|
|
return {vis: el.offsetParent!==null, len: el.innerText.trim().length, over: mo};
|
|
}""", v)
|
|
res["views"] = vh
|
|
res["errors"] = errs[:6]
|
|
# screenshot the tasks tab
|
|
await pg.click('nav.tabs button[data-view="tasks"]')
|
|
await pg.wait_for_timeout(1600)
|
|
await pg.screenshot(path=f"/workspace/parastoo_dashboard/audit/tasks_{tag}.png", full_page=True)
|
|
out[tag] = res
|
|
await pg.close()
|
|
print(json.dumps(out, ensure_ascii=False, indent=2))
|
|
await b.close()
|
|
|
|
asyncio.run(main())
|