parastoo-dashboards/parastoo_dashboard/audit_team.py

55 lines
No EOL
2.7 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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": 1600, "height": 1100}, device_scale_factor=1.5)
errs = []
pg.on("pageerror", lambda e: errs.append(f"PAGEERR {e}"))
pg.on("console", lambda m: errs.append(f"CONSOLE {m.text}") if m.type == "error" else None)
await pg.goto("https://parastoo.zebellkhan.com/", wait_until="networkidle", timeout=90000)
await pg.wait_for_timeout(4000)
# TEAM TAB
await pg.click('nav.tabs button[data-view="team"]')
await pg.wait_for_timeout(6000)
team = await pg.evaluate("""() => ({
meta: document.getElementById('teamMeta')?.innerText,
cards: document.querySelectorAll('#teamCards .card').length,
detail: document.querySelectorAll('#teamDetail .card').length,
verdict: document.getElementById('teamVerdict')?.innerText.slice(0, 220),
textLen: document.getElementById('view-team').innerText.length
})""")
# REMINDERS TAB
await pg.click('nav.tabs button[data-view="remind"]')
await pg.wait_for_timeout(4000)
remind = await pg.evaluate("""() => ({
meta: document.getElementById('remindMeta')?.innerText,
platformCards: document.querySelectorAll('#remindCalendar .card').length,
calDays: document.querySelectorAll('#calendarDays .card').length,
dailyItems: document.querySelectorAll('#dailyTasks .task-row').length,
customReminders: document.querySelectorAll('#customReminders .task-row').length,
textLen: document.getElementById('view-remind').innerText.length,
overflow: document.documentElement.scrollWidth - document.documentElement.clientWidth
})""")
# ADD a personal reminder via UI
await pg.fill('#remTitle', 'تست یادآور — پیگیری بلاگر')
await pg.select_option('#remFreq', 'daily')
await pg.click('button:has-text("➕ افزودن یادآور")')
await pg.wait_for_timeout(1200)
remind["afterAdd"] = await pg.evaluate("() => document.querySelectorAll('#customReminders .task-row').length")
# screenshot
await pg.screenshot(path="/workspace/parastoo_dashboard/audit/team_tab.png", full_page=True)
await pg.click('nav.tabs button[data-view="remind"]')
await pg.wait_for_timeout(2000)
await pg.screenshot(path="/workspace/parastoo_dashboard/audit/remind_tab.png", full_page=True)
print(json.dumps({"team": team, "remind": remind, "errors": errs[:6]}, ensure_ascii=False, indent=2))
await b.close()
asyncio.run(main())