import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; const appSource = readFileSync(new URL("../src/App.vue", import.meta.url), "utf8"); const routerSource = readFileSync(new URL("../src/router/index.js", import.meta.url), "utf8"); const systemPermissionSource = readFileSync(new URL("../src/views/SystemPermissionView.vue", import.meta.url), "utf8"); const orgMindMapSource = readFileSync(new URL("../src/components/OrgMindMap.vue", import.meta.url), "utf8"); const orgPermissionTreeSource = readFileSync(new URL("../src/components/OrgPermissionTree.vue", import.meta.url), "utf8"); assert.match(appSource, /系统管理/, "App.vue should show the system-management parent menu"); assert.match(appSource, /系统权限管理/, "App.vue should show the system permission child menu"); assert.match(appSource, /系统拓展/, "App.vue should keep the system extension child menu"); assert.match( appSource, /permissionsAny:\s*\[[\s\S]*"MENU_SYSTEM_PERMISSION"[\s\S]*"MENU_SYSTEM_EXTENSION"[\s\S]*\]/, "App.vue system menu should allow either system permission" ); assert.match( routerSource, /component:\s*view\("SystemPermissionView"\)/, "router should lazy load SystemPermissionView" ); assert.match(routerSource, /path:\s*"\/system-management"[\s\S]*redirect:/, "router should add /system-management redirect"); assert.match(routerSource, /path:\s*"\/system-permissions"/, "router should add /system-permissions route"); assert.match( routerSource, /name:\s*"system-permissions"[\s\S]*permission:\s*"MENU_SYSTEM_PERMISSION"/, "system-permissions route should require MENU_SYSTEM_PERMISSION" ); assert.match(systemPermissionSource, /系统权限管理/, "SystemPermissionView should show page title"); assert.match(systemPermissionSource, /组织架构/, "SystemPermissionView should expose organization structure tab"); assert.match(systemPermissionSource, /角色维护/, "SystemPermissionView should expose role-only maintenance tab"); assert.doesNotMatch(systemPermissionSource, /人员与角色维护/, "personnel and role maintenance should be renamed"); assert.doesNotMatch(systemPermissionSource, /maintenanceSubTab/, "role maintenance should not keep nested personnel tabs"); assert.doesNotMatch(systemPermissionSource, /system-permission-sub-tabs/, "role maintenance should not render nested sub tabs"); assert.doesNotMatch( systemPermissionSource, /v-if="maintenanceSubTab === 'users'"/, "standalone system users table should be removed from maintenance page" ); assert.doesNotMatch( systemPermissionSource, /v-if="maintenanceSubTab === 'roles'"/, "roles should render directly in the role maintenance tab" ); assert.match( systemPermissionSource, /import PaginationBar from "\.\.\/components\/PaginationBar\.vue";/, "page should use global PaginationBar" ); assert.match( systemPermissionSource, /import \{ usePagination \} from "\.\.\/utils\/pagination";/, "page should use global pagination helper" ); assert.match(systemPermissionSource, /paginatedRoles/, "roles table should use paginated rows"); assert.match(systemPermissionSource, //, "role maintenance should use global table styling"); assert.doesNotMatch( systemPermissionSource, /class="maintenance-grid"/, "maintenance page should not use the old side-by-side card grid" ); assert.doesNotMatch( systemPermissionSource, /