parastoo-dashboards/parastoo_dashboard/test_autosync_live.py

47 lines
No EOL
2 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}"))
await pg.goto("https://parastoo.zebellkhan.com/", wait_until="networkidle", timeout=90000)
await pg.wait_for_timeout(4000)
# 1) Open FAB, add a task
await pg.click('.fab')
await pg.wait_for_timeout(1000)
test_title = 'تست سینک خودکار نهایی'
await pg.fill('#fTitle', test_title)
await pg.select_option('#fCat', 'instagram')
await pg.fill('#fEst', '0.5')
await pg.fill('#fAct', '0.5')
await pg.select_option('#fStatus', 'done')
await pg.click('button:has-text("ذخیره")')
print("Task saved in UI, waiting for background autoSync (up to 45s)...")
# Wait for Composio append to finish in background
for i in range(10):
await pg.wait_for_timeout(5000)
synced = await pg.evaluate(f"""() => {{
const t = tasks.find(x => x.title === '{test_title}');
return t ? t.synced_sheet : null;
}}""")
print(f" {(i+1)*5}s: synced_sheet = {synced}")
if synced:
print("SUCCESS! Task was auto-synced to Google Sheets!")
break
# Final task state
state = await pg.evaluate(f"""() => {{
const t = tasks.find(x => x.title === '{test_title}');
return t ? {{title: t.title, synced_sheet: t.synced_sheet, synced_jira: t.synced_jira}} : null;
}}""")
print("\nFINAL TASK STATE:", json.dumps(state, ensure_ascii=False))
print("RELEVANT LOGS:", [l for l in logs if "autoSync" in l or "push" in l][:8])
await b.close()
asyncio.run(main())