parastoo-dashboards/parastoo_dashboard/test_routines2.py

55 lines
No EOL
2.5 KiB
Python

import asyncio, json
from playwright.async_api import async_playwright
async def main():
async with async_playwright() as p:
b = await p.chromium.launch(args=["--no-sandbox"])
pg = await b.new_page(viewport={"width": 1440, "height": 950})
errs = []
pg.on("pageerror", lambda e: errs.append(str(e)))
await pg.goto("https://parastoo.zebellkhan.com/", wait_until="networkidle", timeout=90000)
await pg.wait_for_timeout(3000)
# inspect the calendar DOM structure
await pg.click('#tabs button[data-view="calendar"]')
await pg.wait_for_timeout(1500)
dom = await pg.evaluate("""() => {
const v = document.getElementById('view-calendar');
const kids = [...v.querySelectorAll('*')].map(e=>e.className).filter(c=>c && typeof c==='string');
const uniq = [...new Set(kids)].slice(0,25);
return {classes: uniq, textLen: v.innerText.length, sample: v.innerText.slice(0,200)};
}""")
print("CALENDAR DOM classes:", json.dumps(dom['classes'], ensure_ascii=False))
print("text:", dom['sample'].replace("\n"," | "))
# now inject 3 routine tasks then re-render and look for them
added = await pg.evaluate("""() => {
const t = tasks.filter(x=>x.cat==='routine');
return t.map(x=>({title:x.title, date:x.date}));
}""")
print("\nroutine tasks in storage:", json.dumps(added, ensure_ascii=False))
# check weekly planner shows them
await pg.click('#tabs button[data-view="weekly"]')
await pg.wait_for_timeout(1500)
wk = await pg.evaluate("""() => {
const v=document.getElementById('view-weekly');
const txt=v.innerText;
const hit = tasks.filter(x=>x.cat==='routine').filter(x=>txt.includes(x.title)).map(x=>x.title);
return {textLen: txt.length, routinesVisible: hit};
}""")
print("\nWEEKLY PLANNER:", json.dumps(wk, ensure_ascii=False))
# dashboard KPI
await pg.click('#tabs button[data-view="dashboard"]')
await pg.wait_for_timeout(1500)
kpi = await pg.evaluate("""() => ({
hours: document.getElementById('kpiHours')?.innerText.trim(),
done: document.getElementById('kpiDone')?.innerText.trim(),
total: document.getElementById('kpiTotal')?.innerText.trim()
})""")
print("\nDASHBOARD KPIs:", json.dumps(kpi, ensure_ascii=False))
print("JS ERRORS:", errs[:5])
await b.close()
asyncio.run(main())