"""Seam 1 page check: load a dashboard page with no backend, push contract envelopes through window.__pyMsg, and assert on what is visible. Page under test: set PAGE_CHECK_HTML to a generated dashboard.html. Without it, the no-AI template is filled with TEST_FILL. Every test runs in light, dark and narrow mode. The page sees a fake Qt bridge: each slot call lands in window.__calls as [slot, ...args]. PAGE_CHECK_WIRED=1: the page is wired to a bot (SAMPLE_DATA off), so sample-data cases skip. PAGE_CHECK_REPLAY: a JSON-lines file of envelopes a real bot run produced (bot_runner.py's dry run). Shared helpers (modes, fill, fake bridge, page opener): tests/page_check_common.py. """ import os import re from pathlib import Path import pytest from page_check_common import FAKE_BRIDGE, MODES, TEST_FILL, WIRED, open_page ROOT = Path(__file__).resolve().parents[2] TEMPLATE = ROOT / "rpa-dashboard-no-ai" / "templates" / "dashboard.html" @pytest.fixture(scope="session") def page_url(tmp_path_factory): if os.environ.get("PAGE_CHECK_HTML"): return Path(os.environ["PAGE_CHECK_HTML"]).resolve().as_uri() html = re.sub(r"\{\{(\w+)\}\}", lambda m: TEST_FILL[m[1]], TEMPLATE.read_text(encoding="utf-8")) if WIRED: html = html.replace("const SAMPLE_DATA = true", "const SAMPLE_DATA = false") out = tmp_path_factory.mktemp("page") / "dashboard.html" out.write_text(html, encoding="utf-8") return out.as_uri() @pytest.fixture(params=list(MODES)) def page(request, browser, page_url): yield from open_page(browser, page_url, request.param, FAKE_BRIDGE)