parastoo-dashboards/parastoo_dashboard/audit.py

93 lines
4.1 KiB
Python

import asyncio, os
from playwright.async_api import async_playwright
OUT = "/workspace/parastoo_dashboard/audit"
os.makedirs(OUT, exist_ok=True)
VIEWS = [
("dashboard", "داشبورد"),
("calendar", "تقویم"),
("weekly", "پلنر هفتگی"),
("monthly", "نمای ماهانه"),
("roadmap", "رودمپ رشد"),
("sync", "سینک جیرا و شیت"),
]
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("console", lambda m: errs.append(f"[{m.type}] {m.text}") if m.type in ("error", "warning") else None)
pg.on("pageerror", lambda e: errs.append(f"[pageerror] {e}"))
await pg.goto("https://parastoo.zebellkhan.com/", wait_until="networkidle", timeout=60000)
await pg.wait_for_timeout(2500)
await pg.screenshot(path=f"{OUT}/01_dashboard.png", full_page=True)
print("captured dashboard")
for i, (vid, label) in enumerate(VIEWS[1:], start=2):
await pg.click(f'nav.tabs button[data-view="{vid}"]')
await pg.wait_for_timeout(1800)
await pg.screenshot(path=f"{OUT}/{i:02d}_{vid}.png", full_page=True)
print(f"captured {vid}")
# modal test
await pg.click('nav.tabs button[data-view="calendar"]')
await pg.wait_for_timeout(600)
await pg.click('.fab')
await pg.wait_for_timeout(900)
await pg.screenshot(path=f"{OUT}/07_modal.png")
print("captured modal")
# day modal
await pg.keyboard.press("Escape")
await pg.wait_for_timeout(400)
await pg.click('.day.today')
await pg.wait_for_timeout(900)
await pg.screenshot(path=f"{OUT}/08_daymodal.png")
print("captured day modal")
# checks
checks = await pg.evaluate("""() => {
const r = {};
r.title = document.title;
r.tabs = document.querySelectorAll('nav.tabs button').length;
r.views = document.querySelectorAll('.view').length;
r.tasks = JSON.parse(localStorage.getItem('parastoo_tasks')||'[]').length;
r.kpiHours = document.getElementById('kpiHours')?.innerText;
r.kpiDone = document.getElementById('kpiDone')?.innerText;
r.kpiRate = document.getElementById('kpiRate')?.innerText;
r.kpiAvg = document.getElementById('kpiAvg')?.innerText;
r.ringVal = document.getElementById('ringVal')?.innerText;
r.calCells = document.querySelectorAll('.day').length;
r.calRange = document.getElementById('calRange')?.innerText;
r.weeklyRange = document.getElementById('weeklyRange')?.innerText;
r.monthRange = document.getElementById('monthRange')?.innerText;
r.heatCells = document.querySelectorAll('.heat-cell').length;
r.phases = document.querySelectorAll('.phase').length;
r.milestones = document.querySelectorAll('.ms').length;
r.plotly = document.querySelectorAll('.js-plotly-plot').length;
r.jiraRows = document.querySelectorAll('#jiraList .task-row').length;
r.queueRows = document.querySelectorAll('#queueBody tr').length;
r.todayTasks = document.querySelectorAll('#todayTasks .task-row').length;
r.wDone = document.querySelectorAll('#wDoneList .task-row').length;
r.roadmapPct = document.getElementById('roadmapPct')?.innerText;
// font check
const el = document.querySelector('.card-title');
r.font = el ? getComputedStyle(el).fontFamily : null;
r.dir = document.documentElement.dir;
r.hasMono = !!document.querySelector('.font-mono');
return r;
}""")
print("\n=== STRUCTURAL AUDIT ===")
for k, v in checks.items():
print(f" {k}: {v}")
print("\n=== CONSOLE ISSUES ===")
for e in errs[:15]:
print(" ", e)
if not errs:
print(" none")
await b.close()
asyncio.run(main())