53 lines
2.0 KiB
Python
53 lines
2.0 KiB
Python
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def test_frontend_v2_shell_assets_exist_and_are_indexed():
|
|
assert (ROOT / "web/static/css/ewoooc-tokens.css").exists()
|
|
assert (ROOT / "web/static/css/ewoooc-shell.css").exists()
|
|
assert (ROOT / "templates/ewoooc_base.html").exists()
|
|
assert (ROOT / "templates/components/_ewoooc_shell.html").exists()
|
|
|
|
agents = (ROOT / "AGENTS.md").read_text(encoding="utf-8")
|
|
constitution = (ROOT / "CONSTITUTION.md").read_text(encoding="utf-8")
|
|
roadmap = (ROOT / "docs/guides/frontend_upgrade_roadmap.md").read_text(encoding="utf-8")
|
|
|
|
assert "docs/guides/frontend_upgrade_roadmap.md" in agents
|
|
assert "前端 V2 視覺基準" in constitution
|
|
assert "禁止用 mock data" in roadmap
|
|
|
|
|
|
def test_frontend_v2_shell_uses_real_runtime_context():
|
|
shell = (ROOT / "templates/components/_ewoooc_shell.html").read_text(encoding="utf-8")
|
|
base = (ROOT / "templates/ewoooc_base.html").read_text(encoding="utf-8")
|
|
|
|
assert "scheduler_stats" in shell
|
|
assert "session.get('username')" in shell
|
|
assert "next_run|default(None)" in shell
|
|
assert "components/_ewoooc_shell.html" in base
|
|
|
|
forbidden_markers = [
|
|
"mockProducts",
|
|
"mockData",
|
|
"fake",
|
|
"假商品",
|
|
"假 KPI",
|
|
]
|
|
combined = shell + "\n" + base
|
|
assert all(marker not in combined for marker in forbidden_markers)
|
|
|
|
|
|
def test_dashboard_v2_is_feature_flagged_and_uses_real_dashboard_data():
|
|
route_source = (ROOT / "routes/dashboard_routes.py").read_text(encoding="utf-8")
|
|
dashboard = (ROOT / "templates/dashboard_v2.html").read_text(encoding="utf-8")
|
|
|
|
assert "request.args.get('ui') == 'v2'" in route_source
|
|
assert "template_name = 'dashboard_v2.html'" in route_source
|
|
assert "get_full_dashboard_data()" in route_source
|
|
assert "MockRecord" not in route_source
|
|
assert "{% for item in items %}" in dashboard
|
|
assert "mockProducts" not in dashboard
|
|
assert "假商品" not in dashboard
|