from pathlib import Path def root() -> Path: return Path(__file__).resolve().parents[1] def test_custom_ui_assets_exist(): base = root() assert (base / "web" / "index.html").exists() assert (base / "web" / "static" / "app.css").exists() assert (base / "web" / "static" / "app.js").exists() assert (base / "web" / "static" / "progress.js").exists() assert (base / "web" / "static" / "runs.js").exists() def test_app_registers_custom_routes_and_bridge_endpoints(): content = (root() / "app.py").read_text(encoding="utf-8") assert "def register_custom_routes" in content for route in [ '"/custom"', '"/api/me"', '"/api/bucket/status"', '"/api/bucket/create"', '"/api/build"', '"/api/validate"', '"/api/runs"', '"/api/runs/{run_id}/progress"', '"/api/runs/resumable"', '"/api/runs/{run_id}/view"', ]: assert route in content def test_one_page_workspace_contains_core_sections(): html = (root() / "web" / "index.html").read_text(encoding="utf-8") for text in [ "New Build", "Active Run", "Runs Explorer", "Selected run", "Space Test", "Artifacts", ]: assert text in html def test_one_page_workspace_keeps_required_ids_for_live_bridge(): html = (root() / "web" / "index.html").read_text(encoding="utf-8") required_ids = [ "launchBuild", "checkBucket", "createBucket", "launchValidate", "progressStatus", "timeline", "activityFeed", "runFilters", "runsTable", "selectedRunId", "artifactList", "reportPreview", "spaceTestPreview", "metricsList", "manualActionPanel", "selectedValidateBtn", "resumeLatestRun", ] for element_id in required_ids: assert element_id in html def test_frontend_calls_real_bridge_endpoints_and_keeps_run_logic(): app_js = (root() / "web" / "static" / "app.js").read_text(encoding="utf-8") runs_js = (root() / "web" / "static" / "runs.js").read_text(encoding="utf-8") progress_js = (root() / "web" / "static" / "progress.js").read_text(encoding="utf-8") for endpoint in ["/api/me", "/api/build", "/api/validate", "/api/bucket/status", "/api/bucket/create"]: assert endpoint in app_js assert "selectRun" in runs_js assert "renderRunDetail" in runs_js assert "renderRunViewModel" in progress_js assert "renderActivityFeed" in progress_js assert "renderDiagnostics" in progress_js def test_css_contains_one_page_responsive_layout(): css = (root() / "web" / "static" / "app.css").read_text(encoding="utf-8") compact = css.replace(" ", "") for snippet in [ ".workspace-grid{display:grid;grid-template-columns:minmax(300px,420px)minmax(460px,1fr)minmax(300px,420px)", ".space-test-grid{display:grid;grid-template-columns:minmax(0,1fr)minmax(300px,450px)", "word-break:normal", ".run-row.selected", "@media(max-width:720px)", ]: assert snippet.replace(" ", "") in compact