parastoo-dashboards/parastoo_dashboard/test_sync2.py

58 lines
No EOL
2.3 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}"))
# Intercept network to see what autoSync does
requests = []
pg.on("request", lambda r: requests.append({"url": r.url, "method": r.method}) if "api" in r.url else None)
responses = []
pg.on("response", lambda r: responses.append({"url": r.url, "status": r.status}) if "api" in r.url else None)
await pg.goto("https://parastoo.zebellkhan.com/", wait_until="networkidle", timeout=90000)
await pg.wait_for_timeout(3000)
# Open FAB, fill task, save
await pg.click('.fab')
await pg.wait_for_timeout(1000)
await pg.fill('#fTitle', 'تست سینک ۲ — بررسی شبکه')
await pg.select_option('#fCat', 'instagram')
await pg.fill('#fEst', '0.25')
await pg.fill('#fAct', '0.25')
await pg.select_option('#fStatus', 'done')
# Clear previous network logs
requests.clear()
responses.clear()
logs_before = len(logs)
await pg.click('button:has-text("ذخیره")')
# Wait generously for autoSync
await pg.wait_for_timeout(8000)
# Check results
new_logs = logs[logs_before:]
sync_logs = [l for l in new_logs if "sync" in l.lower() or "auto" in l.lower() or "error" in l.lower() or "warn" in l.lower()]
task = await pg.evaluate("""() => {
const t = tasks.find(x => x.title.includes('سینک ۲'));
return t ? {title: t.title, synced_sheet: t.synced_sheet, synced_jira: t.synced_jira} : null;
}""")
print("TASK:", json.dumps(task, ensure_ascii=False))
print("\nNETWORK REQUESTS:")
for r in requests:
print(f" {r['method']} {r['url']}")
print("\nNETWORK RESPONSES:")
for r in responses:
print(f" {r['status']} {r['url']}")
print("\nSYNC LOGS:", sync_logs[:10])
print("\nALL NEW LOGS:", new_logs[:15])
await b.close()
asyncio.run(main())