53 lines
2.4 KiB
Python
53 lines
2.4 KiB
Python
"""Static Admin Console routing and public API integration checks."""
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
from ekp_api.main import create_app
|
|
from ekp_core.config import Settings
|
|
|
|
|
|
def test_admin_console_exposes_three_pages_and_assets(
|
|
isolated_settings_environment: None,
|
|
) -> None:
|
|
"""Every Demo page must be directly addressable without provider credentials."""
|
|
with TestClient(create_app(Settings(app_env="test"))) as client:
|
|
page_responses = [
|
|
client.get("/admin"),
|
|
client.get("/admin/upload"),
|
|
client.get("/admin/documents"),
|
|
client.get("/admin/search"),
|
|
]
|
|
script_response = client.get("/admin/assets/app.js")
|
|
stylesheet_response = client.get("/admin/assets/styles.css")
|
|
|
|
assert all(response.status_code == 200 for response in page_responses)
|
|
assert all("Enterprise Knowledge Platform" in response.text for response in page_responses)
|
|
assert script_response.status_code == 200
|
|
assert script_response.headers["content-type"].startswith("text/javascript")
|
|
assert stylesheet_response.status_code == 200
|
|
assert stylesheet_response.headers["content-type"].startswith("text/css")
|
|
|
|
|
|
def test_admin_console_contains_only_demo_pages_and_versioned_api_calls(
|
|
isolated_settings_environment: None,
|
|
) -> None:
|
|
"""Guard the DEMO-010 UI boundary and its API-first integration contract."""
|
|
with TestClient(create_app(Settings(app_env="test"))) as client:
|
|
html = client.get("/admin").text
|
|
script = client.get("/admin/assets/app.js").text
|
|
stylesheet = client.get("/admin/assets/styles.css").text
|
|
|
|
assert all(label in html for label in ("上传文档", "文档列表", "Search Lab"))
|
|
assert "地瓜机器人" in html
|
|
assert all(page_id in html for page_id in ("upload-page", "documents-page", "search-page"))
|
|
assert all(label not in html for label in ("权限管理", "任务管理", "Compiled Knowledge"))
|
|
assert 'const API_BASE = "/api/v1"' in script
|
|
assert "innerHTML" not in script
|
|
assert all(endpoint in script for endpoint in ('"/ingestion-batches"', '"/search"'))
|
|
assert "multiple" in html
|
|
assert "BATCH_POLL_INTERVAL_MS" in script
|
|
assert all(field in script for field in ("Page", "Section", "Dense Score", "Rerank Score"))
|
|
assert "--brand: #FF3C00" in stylesheet
|
|
assert "prefers-reduced-motion" in stylesheet
|
|
assert "https://" not in html
|