You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
5.4 KiB
JavaScript
47 lines
5.4 KiB
JavaScript
const assert = require("assert");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
const root = path.resolve(__dirname, "..");
|
|
const api = fs.readFileSync(path.join(root, "src/api/schoolProductConfig.js"), "utf8");
|
|
const router = fs.readFileSync(path.join(root, "src/router/index.js"), "utf8");
|
|
const sidebar = fs.readFileSync(path.join(root, "src/layout/components/Sidebar/index.vue"), "utf8");
|
|
const platformSchool = fs.readFileSync(path.join(root, "src/views/platformAdmin/school/index.vue"), "utf8");
|
|
const teacherClass = fs.readFileSync(path.join(root, "src/views/teacherEnd/class/index.vue"), "utf8");
|
|
const userStore = fs.readFileSync(path.join(root, "src/store/modules/user.js"), "utf8");
|
|
const teacherRoutes = router.slice(router.indexOf("export const teacherRoutes"), router.indexOf("export const platformAdminRoutes"));
|
|
const teacherManagementRoute = teacherRoutes.slice(teacherRoutes.indexOf('path: "/teacher"'), teacherRoutes.indexOf('path: "/student"'));
|
|
|
|
assert(/\/api\/school-product-config\/current/.test(api), "school users must load their product configuration");
|
|
assert(/\/product-config`/.test(api), "platform admins must update a school's product configuration");
|
|
assert(/requiresAdminClass:\s*true/.test(router), "administrative organization routes must be marked for configuration gating");
|
|
assert(/path: "\/school"[\s\S]*?requiresFacultyManagement:\s*true/.test(teacherRoutes), "teacher faculty menu must be gated by the faculty switch");
|
|
assert(/path: "\/major"[\s\S]*?requiresMajorManagement:\s*true/.test(teacherRoutes), "teacher major menu must be gated by the major switch");
|
|
assert(!/requiresAdminClass/.test(teacherManagementRoute), "teacher management must remain available when administrative-class management is disabled");
|
|
assert(/filterRoutesByOrganizationMode/.test(sidebar), "sidebar must remove unavailable administrative organization routes");
|
|
assert(/filterRoutesByOrganizationMode\(teacherRoutes\)/.test(sidebar), "teacher menus must be filtered by organization mode");
|
|
assert(/requiresFacultyManagement:\s*true/.test(sidebar), "the teacher course-style faculty item must declare its capability");
|
|
assert(/requiresMajorManagement:\s*true/.test(sidebar), "the teacher course-style major item must declare its capability");
|
|
assert(/filterTeacherManageNavigation\(teacherManageNav\)/.test(sidebar), "the teacher course-style sidebar must filter its hard-coded navigation before rendering");
|
|
assert(/currentCourseNav = computed\([\s\S]*?filterTeacherManageNavigation\(teacherManageNav\)/.test(sidebar), "teachers must render the filtered course-style navigation instead of the raw hard-coded menu");
|
|
assert(/watch\(\s*\(\) => userStore\.schoolProductConfig\?\.organizationMode/.test(sidebar), "sidebar must refresh when the asynchronous school configuration arrives");
|
|
assert(/organizationMode/.test(platformSchool) && /updatePlatformSchoolProductConfig/.test(platformSchool), "platform school editor must manage organization mode");
|
|
assert(/行政班管理/.test(platformSchool), "platform school editor must expose administrative-class management controls");
|
|
assert(/v-model="productConfig\.facultyManagementEnabled"/.test(platformSchool), "platform school editor must configure faculty management with a switch");
|
|
assert(/v-model="productConfig\.majorManagementEnabled"/.test(platformSchool), "platform school editor must configure major management with a switch");
|
|
assert(/v-model="productConfig\.adminClassManagementEnabled"/.test(platformSchool), "platform school editor must configure administrative classes with a switch");
|
|
assert(/requiresFacultyManagement/.test(router) && /requiresMajorManagement/.test(router), "teacher routes must declare their management capability");
|
|
assert(/adminClassManagementEnabled/.test(teacherClass), "teacher class page must derive administrative-class controls from the switch");
|
|
assert(/isTeacherRosterMode/.test(teacherClass), "teacher class page must recognize teacher-managed roster mode");
|
|
assert(!/!this\.userInfo\?\.schoolId\s*\|\|\s*this\.userInfo\?\.roleId\s*==\s*1/.test(userStore), "school configuration loading must not be skipped because cached user info lacks schoolId");
|
|
assert(/this\.userInfo\?\.roleId\s*==\s*1/.test(userStore) && /return getCurrentSchoolProductConfig\(\)/.test(userStore), "every non-platform user must load school configuration from the backend token");
|
|
assert(/await userStore\.ensureSchoolProductConfig\(\)/.test(sidebar), "school menus must load the product configuration before they are generated");
|
|
assert(/const facultyEnabled = config\?\.facultyManagementEnabled === true;/.test(sidebar), "faculty menus must fail closed until their school capability is confirmed");
|
|
assert(/const majorEnabled = config\?\.majorManagementEnabled === true;/.test(sidebar), "major menus must fail closed until their school capability is confirmed");
|
|
assert(/visibleSidebarRouters/.test(sidebar), "sidebar rendering must apply school capability filtering as a final guard");
|
|
assert(/v-for="\(route, index\) in visibleSidebarRouters"/.test(sidebar), "the sidebar must render the final filtered routes instead of the raw route list");
|
|
assert(/:key="sidebarMenuKey"/.test(sidebar), "the Element Plus menu must remount when visible school routes change");
|
|
assert(/const sidebarMenuKey = computed\(\(\) => visibleSidebarRouters\.value\.map\(\(route\) => route\.path\)\.join\("\|"\)\);/.test(sidebar), "menu remount key must derive from the visible routes");
|
|
|
|
console.log("School product configuration is represented in the API, routes, sidebar, and platform editor.");
|