141 lines
6.7 KiB
Python
141 lines
6.7 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": 1600, "height": 1100})
|
|
errs = []
|
|
pg.on("pageerror", lambda e: errs.append(str(e)))
|
|
pg.on("console", lambda m: errs.append(m.text) if m.type == "error" else None)
|
|
|
|
await pg.goto("https://parastoo.zebellkhan.com/", wait_until="networkidle", timeout=60000)
|
|
await pg.wait_for_timeout(2000)
|
|
await pg.evaluate("localStorage.clear()")
|
|
await pg.reload(wait_until="networkidle")
|
|
await pg.wait_for_timeout(1500)
|
|
|
|
R = {}
|
|
|
|
# 1. add task via modal
|
|
await pg.click('.fab')
|
|
await pg.wait_for_timeout(700)
|
|
await pg.fill('#fTitle', 'تست خودکار — طراحی کاور کمپین پاییز')
|
|
await pg.select_option('#fCat', 'design')
|
|
await pg.fill('#fEst', '2')
|
|
await pg.fill('#fAct', '2.5')
|
|
await pg.select_option('#fStatus', 'done')
|
|
await pg.check('#fAdhoc')
|
|
await pg.fill('#fNote', 'تست سیستم')
|
|
await pg.click('.modal-foot .btn-primary')
|
|
await pg.wait_for_timeout(900)
|
|
R['add_task'] = await pg.evaluate("""() => {
|
|
const t=JSON.parse(localStorage.getItem('parastoo_tasks')||'[]');
|
|
const found=t.find(x=>x.title.includes('تست خودکار'));
|
|
return {total:t.length, found: !!found, cat:found?.cat, act:found?.act, adhoc:found?.adhoc, status:found?.status};
|
|
}""")
|
|
|
|
# 2. quick add
|
|
await pg.click('nav.tabs button[data-view="calendar"]')
|
|
await pg.wait_for_timeout(700)
|
|
await pg.fill('#quickTitle', 'تست سریع — پاسخ فوری دایرکت')
|
|
await pg.fill('#quickHours', '0.75')
|
|
await pg.click('#view-calendar button.btn-primary:has-text("ثبت سریع")')
|
|
await pg.wait_for_timeout(800)
|
|
R['quick_add'] = await pg.evaluate("""() => {
|
|
const t=JSON.parse(localStorage.getItem('parastoo_tasks')||'[]');
|
|
const f=t.find(x=>x.title.includes('تست سریع'));
|
|
return {total:t.length, found:!!f, adhoc:f?.adhoc, act:f?.act, status:f?.status};
|
|
}""")
|
|
|
|
# 3. toggle task done
|
|
await pg.click('nav.tabs button[data-view="dashboard"]')
|
|
await pg.wait_for_timeout(700)
|
|
before = await pg.evaluate("() => JSON.parse(localStorage.getItem('parastoo_tasks')).filter(t=>t.status==='done').length")
|
|
await pg.click('#todayTasks .task-row .task-check')
|
|
await pg.wait_for_timeout(600)
|
|
after = await pg.evaluate("() => JSON.parse(localStorage.getItem('parastoo_tasks')).filter(t=>t.status==='done').length")
|
|
R['toggle'] = {'done_before': before, 'done_after': after, 'changed': before != after}
|
|
|
|
# 4. roadmap milestone
|
|
await pg.click('nav.tabs button[data-view="roadmap"]')
|
|
await pg.wait_for_timeout(800)
|
|
await pg.click('.ms input')
|
|
await pg.wait_for_timeout(700)
|
|
R['roadmap'] = await pg.evaluate("""() => ({
|
|
state: JSON.parse(localStorage.getItem('parastoo_roadmap')||'{}'),
|
|
pct: document.getElementById('roadmapPct').innerText,
|
|
barW: document.getElementById('roadmapBar').style.width
|
|
})""")
|
|
|
|
# 5. jira sync
|
|
await pg.click('nav.tabs button[data-view="sync"]')
|
|
await pg.wait_for_timeout(700)
|
|
await pg.click('button:has-text("🔄 سینک")')
|
|
await pg.wait_for_timeout(2200)
|
|
R['jira_sync'] = await pg.evaluate("""() => ({
|
|
status: document.getElementById('jiraStatus').innerText,
|
|
last: document.getElementById('jiraLast').innerText,
|
|
dot: document.getElementById('jiraDot').className,
|
|
jiraKeys: JSON.parse(localStorage.getItem('parastoo_tasks')||'[]').filter(t=>t.jira).length
|
|
})""")
|
|
|
|
# 6. persistence across reload
|
|
await pg.reload(wait_until="networkidle")
|
|
await pg.wait_for_timeout(1500)
|
|
R['persistence'] = await pg.evaluate("""() => ({
|
|
tasks: JSON.parse(localStorage.getItem('parastoo_tasks')||'[]').length,
|
|
roadmap: Object.keys(JSON.parse(localStorage.getItem('parastoo_roadmap')||'{}')).length,
|
|
renderOk: document.getElementById('kpiHours').innerText.length > 0,
|
|
calCells: document.querySelectorAll('.day').length
|
|
})""")
|
|
|
|
# 7. week navigation
|
|
await pg.click('nav.tabs button[data-view="calendar"]')
|
|
await pg.wait_for_timeout(600)
|
|
r1 = await pg.inner_text('#calRange')
|
|
await pg.click('button:has-text("هفته بعد")')
|
|
await pg.wait_for_timeout(700)
|
|
r2 = await pg.inner_text('#calRange')
|
|
await pg.click('button:has-text("هفته قبل")')
|
|
await pg.wait_for_timeout(700)
|
|
r3 = await pg.inner_text('#calRange')
|
|
R['week_nav'] = {'initial': r1, 'next': r2, 'back': r3, 'changed': r1 != r2, 'restored': r1 == r3}
|
|
|
|
# 8. month navigation
|
|
await pg.click('nav.tabs button[data-view="monthly"]')
|
|
await pg.wait_for_timeout(700)
|
|
m1 = await pg.inner_text('#monthRange')
|
|
await pg.click('button:has-text("ماه جاری")')
|
|
await pg.wait_for_timeout(600)
|
|
R['month_nav'] = {'range': m1, 'heatCells': await pg.evaluate("() => document.querySelectorAll('.heat-cell').length")}
|
|
|
|
# 9. close week moves tasks
|
|
await pg.click('nav.tabs button[data-view="weekly"]')
|
|
await pg.wait_for_timeout(700)
|
|
pg.on("dialog", lambda d: asyncio.ensure_future(d.accept()))
|
|
R['weekly'] = await pg.evaluate("""() => ({
|
|
hours: document.getElementById('wHours').innerText,
|
|
done: document.getElementById('wDone').innerText,
|
|
avg: document.getElementById('wAvg').innerText,
|
|
acc: document.getElementById('wAcc').innerText,
|
|
doneList: document.querySelectorAll('#wDoneList .task-row').length,
|
|
nextList: document.querySelectorAll('#wNextList .task-row').length,
|
|
summaryLen: document.getElementById('wSummary').innerText.length
|
|
})""")
|
|
|
|
# 10. export button exists & downloadable
|
|
R['export'] = await pg.evaluate("() => !!document.querySelector('button[onclick=\"exportData()\"]')")
|
|
|
|
R['console_errors'] = errs[:10]
|
|
print(json.dumps(R, ensure_ascii=False, indent=2))
|
|
|
|
# final screenshots
|
|
for vid in ["dashboard","calendar","weekly","monthly","roadmap","sync"]:
|
|
await pg.click(f'nav.tabs button[data-view="{vid}"]')
|
|
await pg.wait_for_timeout(1500)
|
|
await pg.screenshot(path=f"/workspace/parastoo_dashboard/audit/final_{vid}.png", full_page=True)
|
|
|
|
await b.close()
|
|
|
|
asyncio.run(main())
|