nomadro/apps/miniprogram/weapp/scripts/_smoke_all.py
eric 3e5b7c2098 Monorepo super-optimize: src layout, workspace scripts, docs.
Collapse portal under src/, unify pnpm workspace/scripts, thin VIP topic re-exports, drop orphan vip scaffolds and one-shot scripts, ignore xhs/release, document root commands.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-01 00:34:04 +08:00

36 lines
1.5 KiB
Python

from playwright.sync_api import sync_playwright
from pathlib import Path
OUT = Path(r"c:\project\gitlab-instance-0a899031_nomadro\apps\miniprogram\tmp\h5-smoke")
OUT.mkdir(parents=True, exist_ok=True)
ROUTES = [
("home", "/#/pages/index/index", ["nomadro", "随处工作", "VIP"]),
("nav", "/#/pages/nav/index", ["导航", "数字游民"]),
("book", "/#/pages/book/index", ["小册"]),
("community", "/#/pages/community/index", ["nomadro"]),
("vip", "/#/pages/vip/index", ["VIP"]),
]
with sync_playwright() as p:
b = p.chromium.launch(headless=True)
page = b.new_page(viewport={"width": 375, "height": 667}, is_mobile=True, device_scale_factor=2)
for name, url, need in ROUTES:
page.goto("http://127.0.0.1:10086" + url, wait_until="load", timeout=120000)
page.wait_for_timeout(3000)
if name == "book":
try:
page.wait_for_function(
"() => { const t=document.body.innerText||''; return t.includes('开始阅读')||t.includes('继续阅读')||t.includes('Youtube')||t.includes('章节'); }",
timeout=20000,
)
except Exception as e:
print("book wait", e)
body = page.inner_text("body")
miss = [t for t in need if t not in body]
stuck = body.strip().startswith("正在打开")
page.screenshot(path=str(OUT / f"all-{name}.png"))
ok = not miss and not stuck
print(name, "OK" if ok else "FAIL", "miss", miss, "stuck", stuck, body[:90].replace("\n", "|"))
b.close()