69 lines
No EOL
3.2 KiB
Python
69 lines
No EOL
3.2 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}, 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)
|
|
|
|
# open sync tab -> should trigger health check
|
|
await pg.click('#tabs button[data-view="sync"]')
|
|
await pg.wait_for_timeout(3000)
|
|
sync_state = await pg.evaluate("""() => ({
|
|
healthBox: document.getElementById('jiraHealthBox')?.innerText.slice(0,120),
|
|
jiraStatus: document.getElementById('jiraStatus')?.innerText,
|
|
sheetStatus: document.getElementById('sheetStatus')?.innerText,
|
|
jiraCount: document.getElementById('jiraCount')?.innerText
|
|
})""")
|
|
|
|
# add a task then try sheet sync -> confirmation modal should appear
|
|
await pg.evaluate("""() => {
|
|
const t = [...document.querySelectorAll('button')].find(b=>b.innerText.includes('تسک'));
|
|
}""")
|
|
# direct: create task via modal
|
|
await pg.evaluate("""() => {
|
|
const quick = document.querySelector('.fab');
|
|
if(quick) quick.click();
|
|
}""")
|
|
await pg.wait_for_timeout(800)
|
|
await pg.fill('#fTitle', 'تست تأیید سینک — رفع باگ استوری')
|
|
await pg.select_option('#fCat', 'instagram')
|
|
await pg.fill('#fEst', '1'); await pg.fill('#fAct', '1.5')
|
|
await pg.select_option('#fStatus', 'done')
|
|
await pg.click('.modal-foot .btn-primary')
|
|
await pg.wait_for_timeout(1500)
|
|
|
|
# go to sync tab, click sheet sync
|
|
await pg.click('#tabs button[data-view="sync"]')
|
|
await pg.wait_for_timeout(1500)
|
|
# find the sheet sync button
|
|
await pg.evaluate("""() => {
|
|
const btns=[...document.querySelectorAll('#view-sync button')];
|
|
const b=btns.find(x=>x.innerText.includes('شیت'));
|
|
if(b) b.click();
|
|
}""")
|
|
await pg.wait_for_timeout(2500)
|
|
sheet_confirm = await pg.evaluate("""() => ({
|
|
modalVisible: !!document.querySelector('.overlay .modal'),
|
|
modalText: document.querySelector('.overlay .modal-title')?.innerText,
|
|
confirmBtn: !!document.querySelector('#cfmOk'),
|
|
cancelBtn: !!document.querySelector('#cfmNo'),
|
|
itemPreview: document.querySelector('.overlay .day-row span:last-child')?.innerText
|
|
})""")
|
|
|
|
# cancel -> must NOT write
|
|
if sheet_confirm["cancelBtn"]:
|
|
await pg.click('#cfmNo')
|
|
await pg.wait_for_timeout(1000)
|
|
|
|
await pg.screenshot(path="/workspace/parastoo_dashboard/audit/confirm_gate.png", full_page=True)
|
|
print(json.dumps({"sync_state": sync_state, "sheet_confirm": sheet_confirm, "errors": errs[:6]}, ensure_ascii=False, indent=2))
|
|
await b.close()
|
|
|
|
asyncio.run(main()) |