Files
ewoooc/tests/test_external_tool_entrypoints.py
OoO af0b49a819
All checks were successful
CD Pipeline / deploy (push) Successful in 1m6s
V10.510 啟用 Webcrumbs live plugin 試點
2026-05-31 20:39:08 +08:00

63 lines
3.0 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def test_metabase_and_grist_navigation_stays_inside_momo_pro():
app_source = (ROOT / "app.py").read_text(encoding="utf-8")
shell = (ROOT / "templates/components/_ewoooc_shell.html").read_text(encoding="utf-8")
tabs = (ROOT / "templates/components/_analysis_report_tabs.html").read_text(encoding="utf-8")
legacy_nav = (ROOT / "templates/components/_navbar.html").read_text(encoding="utf-8")
env_example = (ROOT / ".env.example").read_text(encoding="utf-8")
compose = (ROOT / "docker-compose.yml").read_text(encoding="utf-8")
assert "'metabase_url': '/metabase'" in app_source
assert "'grist_url': '/grist'" in app_source
assert "['sales', 'daily_sales', 'monthly', 'growth', 'metabase', 'grist']" in shell
assert 'href="/webcrumbs"' in shell
assert "GRIST_URL=https://mo.wooo.work/grist" in env_example
assert "APP_HOME_URL=${GRIST_APP_HOME_URL:-https://mo.wooo.work/grist}" in compose
navigation_sources = "\n".join([app_source, shell, tabs, legacy_nav])
combined = "\n".join([navigation_sources, env_example, compose])
assert "grist.wooo.work" not in combined
assert "awoooi" not in navigation_sources.lower()
def test_external_tool_bridge_pages_are_diagnostic_not_blank():
route_source = (ROOT / "routes/system_public_routes.py").read_text(encoding="utf-8")
template = (ROOT / "templates/external_tool_status.html").read_text(encoding="utf-8")
css = (ROOT / "web/static/css/page-external-tools.css").read_text(encoding="utf-8")
assert "def _external_tool_payload(kind)" in route_source
assert "parsed.path.rstrip('/') == bridge_path.rstrip('/')" in route_source
assert "def _is_blocked_external_url(configured_url)" in route_source
assert "external-tool-checks" in template
assert "external-tool-diagnostics" in template
assert "external-tool-action-grid" in template
assert "def webcrumbs_status()" in route_source
assert "def webcrumbs_asset_proxy(asset_path)" in route_source
assert "WEBCRUMBS_ASSET_ALLOWED_PREFIXES" in route_source
assert "Webcrumbs 共用 UI Runtime" in route_source
assert "plugin_previews" in route_source
assert "finance.market-ticker-strip/0.1.0" in route_source
assert "finance.ai-candidate-card/0.1.0" in route_source
assert "StockPlatformSharedUI.allowedPluginUris" in template
assert "stock-platform-plugin" in template
assert "external-tool-webcrumbs-grid" in css
assert "尚未接入 proxy" in route_source
assert "已由入口攔截" in route_source
assert "AwoooI" not in route_source
assert "--momo-accent-rust" not in css
assert "--momo-accent-honey" not in css
def test_analysis_tabs_use_internal_tool_labels_without_external_icon():
tabs = (ROOT / "templates/components/_analysis_report_tabs.html").read_text(encoding="utf-8")
assert "自訂圖表" in tabs
assert "資料協作" in tabs
assert "fa-up-right-from-square" not in tabs