parastoo-dashboards/parastoo_dashboard/test_routines4.py

58 lines
No EOL
2.7 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})
await pg.goto("https://parastoo.zebellkhan.com/", wait_until="networkidle", timeout=90000)
await pg.wait_for_timeout(3000)
# 1) Add 4 daily routines
await pg.click('#tabs button[data-view="tasks"]')
await pg.wait_for_timeout(1000)
await pg.evaluate("""() => {
document.querySelectorAll('.routine-check').forEach(c=>c.checked=false);
const all=[...document.querySelectorAll('.routine-check')];
[0,1,2,3].forEach(i=>{ if(all[i]) all[i].checked=true; });
}""")
await pg.click('button[onclick="addRoutinesToToday()"]')
await pg.wait_for_timeout(1500)
# 2) Inspect the calendar with the REAL .mini-task selector
await pg.click('#tabs button[data-view="calendar"]')
await pg.wait_for_timeout(1500)
cal = await pg.evaluate("""() => {
const days=[...document.querySelectorAll('.day')];
const today=days.find(d=>d.className.includes('today'));
if(!today) return {todayFound:false};
const tasks=[...today.querySelectorAll('.mini-task')].map(t=>t.innerText.trim());
const allDaysTasks=days.map(d=>({
name: d.querySelector('.day-name')?.innerText,
num: d.querySelector('.day-num')?.innerText?.replace(/\\s+/g,' '),
tasks: [...d.querySelectorAll('.mini-task')].map(t=>t.innerText.trim()),
isToday: d.className.includes('today')
}));
return {
todayFound: true,
todayTasks: tasks,
dayHours: today.querySelector('.day-hours')?.innerText,
allDays: allDaysTasks
};
}""")
print("CALENDAR REAL CHECK:", json.dumps(cal, ensure_ascii=False, indent=1))
# 3) Test mobile layout with routines tab
await pg.set_viewport_size({"width": 393, "height": 852})
await pg.click('#tabs button[data-view="tasks"]')
await pg.wait_for_timeout(1500)
mob = await pg.evaluate("""() => ({
hOverflow: document.documentElement.scrollWidth - document.documentElement.clientWidth,
cards: document.querySelectorAll('.card').length,
routines: document.querySelectorAll('.routine-item').length
})""")
print("\nMOBILE ROUTINES TAB:", json.dumps(mob, ensure_ascii=False))
await pg.screenshot(path="/workspace/parastoo_dashboard/audit/routines_mobile.png")
await b.close()
asyncio.run(main())