from pathlib import Path ROOT = Path(__file__).resolve().parents[2] def test_vue2_ontology_center_routes_and_api_contract_exist(): routes = (ROOT / "frontend/src/router/routes.js").read_text(encoding="utf-8") api = (ROOT / "frontend/src/api/dataDevelopment.js").read_text(encoding="utf-8") request = (ROOT / "frontend/src/utils/request.js").read_text(encoding="utf-8") index = (ROOT / "frontend/src/views/dataGovernance/ontology/index.vue").read_text(encoding="utf-8") workbench = "".join( path.read_text(encoding="utf-8") for path in ( ROOT / "frontend/src/views/dataGovernance/ontology/workbench.vue", ROOT / "frontend/src/views/dataGovernance/ontology/components/GraphSectionEditor.vue", ROOT / "frontend/src/views/dataGovernance/ontology/components/VersionWorkspace.vue", ROOT / "frontend/src/views/dataGovernance/ontology/components/SuggestionReviewDialog.vue", ) ) assert "ontologyCenter" in routes assert "dataGovernance/ontology/index" in routes assert "dataGovernance/ontology/workbench" in routes workbench_route = routes[routes.index("path: '/data-governance/ontology/:uid'") :] workbench_route = workbench_route[: workbench_route.index("alwaysShow: 0")] assert "roles: ['viewer', 'editor', 'admin']" in workbench_route for name in ( "getOntologies", "getOntology", "getOntologyGraph", "getOntologyVersions", "createOntology", "validateOntology", "publishOntology", "diffOntology", "rollbackOntology", "getDataElements", "reviewOntologyChangeSet", "importOntology", "exportOntology", ): assert name in api assert "patch (url, params, config = {})" in request assert request.count("...(config.headers || {})") >= 2 assert "本体中心" in index assert "选择业务域" in index for label in ( "概念", "属性", "关系", "约束", "业务域", "数据元素映射", "版本历史", "版本差异", "动态建议", "导入", "导出", "发布确认", "高级 JSON", ): assert label in workbench assert "canEditOntology" in workbench assert "canPublishOntology" in workbench assert "loadOntology" in workbench assert "loadVersions" in workbench assert "'$route.params.uid'" in workbench combined = api + index + workbench assert "MINIO_PASSWORD" not in combined assert "NEO4J_PASSWORD" not in combined assert "DEEPSEEK_API_KEY" not in combined def test_ontology_workbench_uses_focused_editor_components(): component_root = ( ROOT / "frontend/src/views/dataGovernance/ontology/components" ) editor = (component_root / "GraphSectionEditor.vue").read_text( encoding="utf-8" ) versions = (component_root / "VersionWorkspace.vue").read_text( encoding="utf-8" ) suggestions = (component_root / "SuggestionReviewDialog.vue").read_text( encoding="utf-8" ) assert "新增" in editor and "编辑" in editor and "删除" in editor assert "查看差异" in versions and "回滚" in versions assert "置信度" in suggestions and "证据" in suggestions assert "接受" in suggestions and "拒绝" in suggestions