"""Phase 3 gate, the WebApp: every page loads from the new API. The platform runs as in production (API, Dagster), loaded with the synthetic CaCu hospital and the messy site; Playwright drives the real pages against it (WebApp/e2e).""" import json import os import subprocess from pathlib import Path import pytest from test_conectar import ok, run ROOT = Path(__file__).parents[2] HOSPITAL = ROOT / "tests" / "fixtures" / "hospital" PIPELINE = ROOT / "tests" / "fixtures" / "pipelines" / "hospital_cacu.json" @pytest.mark.webapp @pytest.mark.parametrize("platform", ["sqlite"], indirect=True) # pages read one API either way def test_every_page_loads_from_the_api(api, platform, messy_site): hospital = json.loads(PIPELINE.read_text().replace("{hospital}", str(HOSPITAL))) ok(api.put("/ingest/pipelines/cacu", json=hospital)) run(api, "cacu") ok(api.put("/ingest/pipelines/site", json=json.loads(messy_site.drawn))) run(api, "site") subprocess.run(["npx", "playwright", "test"], cwd=ROOT / "WebApp", check=True, env={**os.environ, "API_URL": str(api.base_url).rstrip("/")}) # fmt: skip