fix: render student training step names
parent
1df7b1781a
commit
4296341202
@ -0,0 +1,26 @@
|
|||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { buildStudentTaskSections, getComprehensiveTopTask } from "../src/utils/studentTrainingNavigation.js";
|
||||||
|
|
||||||
|
const sections = buildStudentTaskSections([
|
||||||
|
{
|
||||||
|
taskKey: "teacher-added-task",
|
||||||
|
taskName: "教师新增任务",
|
||||||
|
projectName: "市场洞察与需求分析",
|
||||||
|
sort: 1,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
assert.deepEqual(sections, [
|
||||||
|
{
|
||||||
|
title: "市场洞察与需求分析",
|
||||||
|
children: [{ title: "教师新增任务", path: "/training/task/teacher-added-task" }],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
assert.deepEqual(getComprehensiveTopTask([{ taskKey: "comprehensive-case-training", taskName: "综合实训" }]), {
|
||||||
|
title: "综合实训",
|
||||||
|
path: "/comprehensive/index",
|
||||||
|
activePrefix: "/comprehensive",
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("student training navigation ESM contract passed");
|
||||||
@ -1,48 +0,0 @@
|
|||||||
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");
|
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { extractTrainingStepNames } from "../src/views/training/taskKeyMap.js";
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
extractTrainingStepNames('[{"id":"custom-123","kind":"builtin","name":"电商产品调研"}]'),
|
||||||
|
["电商产品调研"]
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log("training step names contract passed");
|
||||||
Loading…
Reference in New Issue