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))) logs = [] pg.on("console", lambda m: logs.append(f"[{m.type}] {m.text}")) await pg.goto("https://parastoo.zebellkhan.com/", wait_until="networkidle", timeout=90000) await pg.wait_for_timeout(3000) # clear any leftover localStorage so we start clean await pg.evaluate("() => { localStorage.clear(); }") await pg.reload(wait_until="networkidle") await pg.wait_for_timeout(3000) # open the routines tab await pg.click('#tabs button[data-view="tasks"]') await pg.wait_for_timeout(1500) info = await pg.evaluate("""() => { const items = document.querySelectorAll('.routine-check'); const groups = document.querySelectorAll('.routine-list'); const checked = document.querySelectorAll('.routine-check:checked'); return { totalRoutines: items.length, groups: groups.length, preChecked: checked.length, firstNames: Array.from(items).slice(0,4).map(c=>c.dataset.task), btn: !!document.querySelector('button[onclick="addRoutinesToToday()"]'), tabLabel: document.querySelector('#tabs button[data-view="tasks"]').innerText.trim() }; }""") print("ROUTINE TAB:", json.dumps(info, ensure_ascii=False, indent=1)) # now test "add to today": check 3 specific routines and click await pg.evaluate("""() => { document.querySelectorAll('.routine-check').forEach(c=>c.checked=false); const all=[...document.querySelectorAll('.routine-check')]; [0,1,9].forEach(i=>{ if(all[i]) all[i].checked=true; }); }""") picked = await pg.evaluate("() => [...document.querySelectorAll('.routine-check:checked')].map(c=>c.dataset.task)") print("\nPICKED:", json.dumps(picked, ensure_ascii=False)) await pg.click('button[onclick="addRoutinesToToday()"]') await pg.wait_for_timeout(2500) result = await pg.evaluate("""() => { const t = tasks.filter(x=>x.cat==='routine'); return {count: t.length, titles: t.map(x=>x.title), date: t[0]?.date, synced: t.map(x=>x.synced_sheet)}; }""") print("TASKS ADDED:", json.dumps(result, ensure_ascii=False, indent=1)) # verify they show in the dashboard tab / calendar await pg.click('#tabs button[data-view="calendar"]') await pg.wait_for_timeout(1500) cal = await pg.evaluate("""() => { const cells=[...document.querySelectorAll('.cal-cell,.day-cell,.cal-day')]; const today=cells.find(c=>c.className.includes('today')); return {cells: cells.length, todayText: today? today.innerText.slice(0,120) : null}; }""") print("\nCALENDAR:", json.dumps(cal, ensure_ascii=False)) print("\nJS ERRORS:", errs[:5]) await pg.screenshot(path="/workspace/parastoo_dashboard/audit/routines_tab.png", full_page=True) await b.close() asyncio.run(main())