import asyncio, json from playwright.async_api import async_playwright BASE = "https://parastoo.zebellkhan.com/" async def main(): async with async_playwright() as p: b = await p.chromium.launch(args=["--no-sandbox"]) pg = await b.new_page(viewport={"width": 1600, "height": 1100}, device_scale_factor=1.5) errs = [] pg.on("pageerror", lambda e: errs.append("PAGEERR " + str(e))) pg.on("console", lambda m: errs.append("CONSOLE " + m.text) if m.type == "error" else None) await pg.goto(BASE, wait_until="networkidle", timeout=90000) await pg.wait_for_timeout(3500) await pg.evaluate("localStorage.clear()") await pg.reload(wait_until="networkidle") await pg.wait_for_timeout(3500) R = {} # A) live jira list loaded into the sync tab await pg.click('nav.tabs button[data-view="sync"]') await pg.wait_for_timeout(3000) R["jira_live"] = await pg.evaluate("""() => ({ rows: document.querySelectorAll('#jiraList .task-row').length, count: document.getElementById('jiraCount')?.innerText, status: document.getElementById('jiraStatus')?.innerText })""") # B) add a task, then push to Jira (REAL write) await pg.click('.fab'); await pg.wait_for_timeout(700) await pg.fill('#fTitle', 'تست نهایی داشبورد — هماهنگی بلاگر') await pg.select_option('#fCat', 'influencer') await pg.fill('#fEst', '1'); await pg.fill('#fAct', '1.25') await pg.select_option('#fStatus', 'done') await pg.fill('#fNote', 'تست پایان‌به‌پایان جیرا') await pg.click('.modal-foot .btn-primary') await pg.wait_for_timeout(1200) before_keys = await pg.evaluate("() => JSON.parse(localStorage.getItem('parastoo_tasks')||'[]').filter(t=>t.jira).length") await pg.click('nav.tabs button[data-view="sync"]'); await pg.wait_for_timeout(1500) await pg.click('#view-sync button:has-text("🔄 سینک")') await pg.wait_for_timeout(45000) R["jira_push"] = await pg.evaluate("""() => { const t=JSON.parse(localStorage.getItem('parastoo_tasks')||'[]'); return { status: document.getElementById('jiraStatus').innerText, last: document.getElementById('jiraLast').innerText, dot: document.getElementById('jiraDot').className, withKeys: t.filter(x=>x.jira).length, keys: t.filter(x=>x.jira).map(x=>x.jira).slice(-4) }; }""") R["jira_push"]["before"] = before_keys # C) push to Google Sheet (REAL write) await pg.click('#view-sync button:has-text("🔄 سینک") >> nth=1') await pg.wait_for_timeout(60000) R["sheet_push"] = await pg.evaluate("""() => ({ status: document.getElementById('sheetStatus').innerText, last: document.getElementById('sheetLast').innerText, dot: document.getElementById('sheetDot').className })""") # D) screenshots of all views (dashboard first, while data is loaded) for vid in ["dashboard","calendar","weekly","monthly","roadmap"]: await pg.click(f'nav.tabs button[data-view="{vid}"]') await pg.wait_for_timeout(1800) await pg.screenshot(path=f"/workspace/parastoo_dashboard/audit/live_{vid}.png", full_page=True) # E) final structural check R["final"] = await pg.evaluate("""() => ({ tasks: JSON.parse(localStorage.getItem('parastoo_tasks')||'[]').length, kpiHours: document.getElementById('kpiHours').innerText, kpiDone: document.getElementById('kpiDone').innerText, calRange: document.getElementById('calRange').innerText, charts: document.querySelectorAll('.js-plotly-plot').length, docScroll: document.documentElement.scrollWidth - document.documentElement.clientWidth })""") R["errors"] = errs[:12] print(json.dumps(R, ensure_ascii=False, indent=2)) await b.close() asyncio.run(main())