This commit is contained in:
nnduc
2026-10-24 14:03:52 +07:00
commit 4fe046de58
4790 changed files with 311146 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
import os
import asyncio
from playwright.async_api import async_playwright
from browser import login, BASE, OUT
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch()
ctx, page, errors = await login(browser, "alice@localhost", "alicepass", "logout")
await page.evaluate("Presence_ajaxAskLogout()")
await page.wait_for_timeout(800)
await page.click("#dialog footer button[name=submit]")
await page.wait_for_url("**/login**", timeout=15000)
await page.wait_for_timeout(2000)
print("after logout:", page.url, "quick login keys:", await page.evaluate("localStorage.getItem('quickDeviceId')"))
await page.screenshot(path=f"{OUT}/logout.png")
# Login again, then reload: quick login must work after a server restart
await page.fill("input#username", "alice@localhost")
await page.fill("input#password", "alicepass")
await page.click("#login_widget input[type=submit]")
await page.wait_for_url("**/chat**", timeout=30000)
print("logged again:", page.url)
import subprocess
subprocess.run([os.path.join(os.path.dirname(os.path.abspath(__file__)), "run.sh")])
await page.wait_for_timeout(1000)
await page.reload()
await page.wait_for_url("**/chat**", timeout=40000)
await page.wait_for_timeout(8000)
print("after server restart:", page.url)
await page.screenshot(path=f"{OUT}/restart.png")
for e in errors:
print(e[:200])
await browser.close()
asyncio.run(main())