parastoo-dashboards/parastoo_dashboard/test_final_all.py

61 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": 393, "height": 852}, device_scale_factor=2, is_mobile=True)
logs = []
pg.on("console", lambda m: logs.append(f"[{m.type}] {m.text}"))
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(4000)
# 1) Verify dashboard starts EMPTY (no auto-seeded demo data)
initial = await pg.evaluate("""() => ({
taskCount: typeof tasks !== 'undefined' ? tasks.length : -1,
demoCount: typeof tasks !== 'undefined' ? tasks.filter(t=>t.demo).length : -1,
kpiText: document.getElementById('kpiHours')?.innerText.trim()
})""")
print("1) INITIAL STATE:", json.dumps(initial, ensure_ascii=False))
# 2) Add a real task via FAB
await pg.click('.fab')
await pg.wait_for_timeout(1200)
T = 'تست نهایی موبایل و سینک'
await pg.fill('#fTitle', T)
await pg.select_option('#fCat', 'instagram')
await pg.fill('#fEst', '1')
await pg.fill('#fAct', '1')
await pg.select_option('#fStatus', 'done')
await pg.click('button:has-text("ذخیره")')
print("2) task saved, awaiting background autoSync...")
synced = False
for i in range(10):
await pg.wait_for_timeout(5000)
st = await pg.evaluate(f"() => {{ const t=tasks.find(x=>x.title==='{T}'); return t?t.synced_sheet:null; }}")
print(f" {(i+1)*5}s synced_sheet={st}")
if st:
synced = True
break
# 3) Verify mobile layout across all tabs
TABS = ["dashboard","calendar","weekly","monthly","roadmap","tasks","team","remind","sync"]
layout = {}
for t in TABS:
await pg.click(f'#tabs button[data-view="{t}"]')
await pg.wait_for_timeout(1200)
layout[t] = await pg.evaluate("() => document.documentElement.scrollWidth - document.documentElement.clientWidth")
print("\n3) MOBILE H-OVERFLOW per tab:", json.dumps(layout))
print(" max overflow:", max(layout.values()))
print("\n4) SYNC RESULT:", "SUCCESS" if synced else "FAILED")
print(" autoSync logs:", [l for l in logs if "autoSync" in l][:6])
print(" JS errors:", errs[:3])
await pg.screenshot(path="/workspace/parastoo_dashboard/audit/mobile_final.png", full_page=False)
await b.close()
asyncio.run(main())