From 2558e48ee771ab72b1751f738257a4eb3c147c14 Mon Sep 17 00:00:00 2001 From: qiann Date: Sat, 6 Jun 2026 21:27:23 +0800 Subject: [PATCH] Make web lab tests use explicit UTF-8 encoding --- tests/test_web_lab.py | 803 ++++++++++++++++++++---------------------- 1 file changed, 379 insertions(+), 424 deletions(-) diff --git a/tests/test_web_lab.py b/tests/test_web_lab.py index 8c6bd65..8742961 100644 --- a/tests/test_web_lab.py +++ b/tests/test_web_lab.py @@ -1,426 +1,381 @@ -"""Smoke tests for the agent-payments canvas lab (``web/agents-demo.html``). - -The canvas lab is intentionally a no-build single-file frontend, so the test -surface here is correspondingly small but load-bearing: - -- the file parses as HTML and contains the structural anchors we depend on -- every scene wired into ``SCENE_ORDER`` has a matching ``SCENES.`` - definition with a name + caption -- the named cast (Patty, Abhi, Tridib) is wired through the canonical - agent registry -- the home page links to the multi-page lab and canvas lab -- the embedded JavaScript has no syntax errors (run via ``node --check``) - -Skip the node check if a ``node`` binary isn't on PATH. -""" - -from __future__ import annotations - -import html.parser -import re -import shutil -import subprocess -import tempfile -from pathlib import Path - -import pytest - - -HERE = Path(__file__).resolve().parent -WEB = HERE.parent / "web" -LAB = WEB / "agents-demo.html" -MULTIPAGE_LAB = WEB / "lab" -HOME = WEB / "index.html" -SIMULATOR = WEB / "simulator.html" - -LAB_PAGES = [ - "index.html", - "x402.html", - "escrow.html", - "streaming.html", - "auction.html", - "taxi.html", - "cafe.html", - "delivery.html", - "trip.html", - "multichain.html", - "pq.html", - "rails.html", - "tools.html", -] - - -@pytest.fixture(scope="module") +"""Smoke tests for the agent-payments lab (``web/agents-demo.html``). + +The lab is intentionally a no-build single-file frontend, so the test +surface here is correspondingly small but load-bearing: + +- the file parses as HTML and contains the structural anchors we depend on +- every scene wired into ``SCENE_ORDER`` has a matching ``SCENES.`` + definition with a name + caption +- the named cast (Patty, Abhi, Tridib) is wired through the canonical + agent registry +- the home page links to the lab and the lab links back +- the embedded JavaScript has no syntax errors (run via ``node --check``) + +Skip the node check if a ``node`` binary isn't on PATH. +""" + +from __future__ import annotations + +import html.parser +import re +import shutil +import subprocess +import tempfile +from pathlib import Path + +import pytest + + +HERE = Path(__file__).resolve().parent +WEB = HERE.parent / "web" +LAB = WEB / "agents-demo.html" +HOME = WEB / "index.html" + + +@pytest.fixture(scope="module") def lab_html() -> str: - return LAB.read_text() - - -@pytest.fixture(scope="module") + return LAB.read_text(encoding="utf-8") + + +@pytest.fixture(scope="module") def home_html() -> str: - return HOME.read_text() - - -@pytest.fixture(scope="module") -def simulator_html() -> str: - return SIMULATOR.read_text() - - -@pytest.fixture(scope="module") -def lab_script(lab_html: str) -> str: - m = re.search(r"", lab_html, re.DOTALL) - assert m, "expected one ", lab_html, re.DOTALL) + assert m, "expected one