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.
49 lines
2.3 KiB
JavaScript
49 lines
2.3 KiB
JavaScript
const assert = require("assert");
|
|
const {
|
|
buildStudentTaskSections,
|
|
getComprehensiveTopTask,
|
|
} = require("../src/utils/studentTrainingNavigation.cjs");
|
|
|
|
const tasks = [
|
|
{ taskKey: "comprehensive-case-training", taskName: "综合案例实训", projectName: "综合实训", sort: 1 },
|
|
{ taskKey: "market-task", taskName: "需求访谈", projectName: "市场洞察与需求分析", sort: 3 },
|
|
{ taskKey: "new-product-survey", taskName: "新产品调查与分析", projectName: "互联网产品开发基础认知", sort: 2 },
|
|
{ taskKey: "teacher-added-task", taskName: "教师新增任务", projectName: "市场洞察与需求分析", sort: 4 },
|
|
];
|
|
|
|
const sections = buildStudentTaskSections(tasks);
|
|
|
|
assert.deepStrictEqual(sections, [
|
|
{
|
|
title: "互联网产品开发基础认知",
|
|
children: [{ title: "新产品调查与分析", path: "/foundation/new-product-survey" }],
|
|
},
|
|
{
|
|
title: "市场洞察与需求分析",
|
|
children: [
|
|
{ title: "需求访谈", path: "/training/task/market-task" },
|
|
{ title: "教师新增任务", path: "/training/task/teacher-added-task" },
|
|
],
|
|
},
|
|
]);
|
|
assert.deepStrictEqual(getComprehensiveTopTask(tasks), {
|
|
title: "综合案例实训",
|
|
path: "/comprehensive/index",
|
|
activePrefix: "/comprehensive",
|
|
});
|
|
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const frontendRoot = path.resolve(__dirname, "..");
|
|
const sidebarSource = fs.readFileSync(path.join(frontendRoot, "src/layout/components/Sidebar/index.vue"), "utf8");
|
|
const navbarSource = fs.readFileSync(path.join(frontendRoot, "src/layout/components/Navbar.vue"), "utf8");
|
|
const routerSource = fs.readFileSync(path.join(frontendRoot, "src/router/index.js"), "utf8");
|
|
|
|
assert(sidebarSource.includes("loadStudentTaskNavigation"), "student sidebar must load its task navigation from the task API");
|
|
assert(sidebarSource.includes("studentTaskSections"), "student sidebar must render dynamic task sections");
|
|
assert(navbarSource.includes("getComprehensiveTopTask"), "top navigation must derive comprehensive training from the task API");
|
|
assert(navbarSource.includes("studentTopTask"), "top navigation must hold the published comprehensive task");
|
|
assert(routerSource.includes('path: "task/:pageKey"'), "teacher-added tasks must have a generic student route");
|
|
|
|
console.log("student training navigation contract passed");
|