#!/usr/bin/env python3 """Cross-engine smoke test for MOLT. The acceptance bar is "playable in Chrome, Safari and Firefox", so this drives all three engines rather than asserting it. It runs the deterministic attract bot (`?demo=1`) and checks two things per engine: no page error was raised, and the simulation actually advanced (waves, kills and shed shells all moved). python3 -m pip install playwright && python3 -m playwright install python3 test.py """ import json import pathlib import sys from playwright.sync_api import sync_playwright URL = (pathlib.Path(__file__).parent / "index.html").as_uri() + "?demo=1" SECONDS = 45 rows, failed = [], False with sync_playwright() as pw: for name in ("chromium", "firefox", "webkit"): errors = [] browser = getattr(pw, name).launch() page = browser.new_page(viewport={"width": 1100, "height": 800}) page.on("pageerror", lambda e: errors.append(str(e))) page.goto(URL) page.wait_for_timeout(SECONDS * 1000) s = page.evaluate( "({wave:G.wave, kills:G.kills, shells:G.shells.length," " score:Math.round(G.score), t:Math.round(G.t)})") browser.close() advanced = s["wave"] >= 2 and s["t"] >= SECONDS - 10 ok = advanced and not errors failed |= not ok rows.append((name, ok, errors, s)) for name, ok, errors, s in rows: print(f"{name:<9} {'ok ' if ok else 'FAIL'} " f"{'no page errors' if not errors else errors[0][:60]:<16} " f"wave {s['wave']} @ {s['t']}s {json.dumps(s)}") sys.exit(1 if failed else 0)