fix(web-admin): 下线市场侧栏中试服务菜单
超管在 frontend 模式下走静态路由全量展示,仅解绑 sys_role_menu 无效;同步移除 sqxp/STATIC_MENU_TREE 并软删对应 sys_menu。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
4dc352e4f4
commit
77cdeede15
4 files changed
+184
-98
No files matched your search
@@ -0,0 +1,53 @@
|
||||
"""市场下「中试服务」已从静态菜单树下线(Issue #158)。"""
|
||||
import ast
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
MENU_PY = ROOT / "backend/app/api/menu.py"
|
||||
SQXP_TS = ROOT / "web-admin/src/router/modules/sqxp.ts"
|
||||
HIDE_SQL = ROOT / "docs/sql/migrations/2026-11-20-hide-market-pilot-service-menus.sql"
|
||||
|
||||
|
||||
def _market_children_titles_from_menu_py() -> list[str]:
|
||||
source = MENU_PY.read_text(encoding="utf-8")
|
||||
tree_match = re.search(r"STATIC_MENU_TREE\s*=\s*(\[[\s\S]*?\n\])\s*\n", source)
|
||||
assert tree_match, "STATIC_MENU_TREE not found"
|
||||
tree = ast.literal_eval(tree_match.group(1))
|
||||
market = next(
|
||||
node
|
||||
for node in tree
|
||||
if isinstance(node, dict) and (node.get("meta") or {}).get("menuCode") == "menu:market"
|
||||
)
|
||||
titles = []
|
||||
for child in market.get("children") or []:
|
||||
meta = child.get("meta") or {}
|
||||
titles.append(str(meta.get("title") or ""))
|
||||
return titles
|
||||
|
||||
|
||||
def test_backend_static_menu_has_no_market_pilot_service():
|
||||
titles = _market_children_titles_from_menu_py()
|
||||
assert "中试服务" not in titles
|
||||
assert "中试服务申请单" not in titles
|
||||
|
||||
|
||||
def test_frontend_sqxp_has_no_market_pilot_service_block():
|
||||
text = SQXP_TS.read_text(encoding="utf-8")
|
||||
assert "name: 'PilotService'" not in text
|
||||
assert "id: 'PIL00000000000000000000000000001'" not in text
|
||||
assert "pilot-service:pilot-application:list" not in text
|
||||
# 基础实验 / 临床仍可复用出库放行组件与权限码前缀
|
||||
assert "basic-experiment:outbound-release-review:list" in text
|
||||
assert "clinical-application:outbound-release-review:list" in text
|
||||
|
||||
|
||||
def test_hide_sql_soft_deletes_sys_menu_only_under_market_pilot():
|
||||
sql = HIDE_SQL.read_text(encoding="utf-8")
|
||||
compact = re.sub(r"\s+", " ", re.sub(r"--[^\n]*", "", sql))
|
||||
assert re.search(r"UPDATE\s+sys_menu", compact, re.IGNORECASE)
|
||||
assert re.search(r"SET\s+m\.del_flag\s*=\s*1", compact, re.IGNORECASE)
|
||||
assert "menu:market" in compact
|
||||
assert "中试服务" in compact
|
||||
assert not re.search(r"DELETE\s+FROM\s+sys_menu", compact, re.IGNORECASE)
|
||||
Reference in new issue
Block a user