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.
dianshang-qianduan/tests/training-task-toolbar.stati...

71 lines
2.9 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

const fs = require("node:fs");
const path = require("node:path");
const test = require("node:test");
const assert = require("node:assert/strict");
const frontendRoot = path.resolve(__dirname, "..");
const toolbarPath = path.join(frontendRoot, "src/views/components/TrainingTaskToolbar.vue");
const studentTrainingPages = [
"foundation/new-product-survey.vue",
"foundation/product-development-factors.vue",
"foundation/product-development-process.vue",
"demand/industry-demand-analysis.vue",
"demand/competitive-environment-analysis.vue",
"demand/business-feasibility.vue",
"demand/people.vue",
"demand/consumer-behavior.vue",
"demand/consumer-scenario.vue",
"demand/feature-conversion.vue",
"product/market-opportunity-selection.vue",
"product/differentiation.vue",
"product/structure.vue",
"product/after-sales-service.vue",
"product/requirements-doc.vue",
"product/hardware-cost.vue",
"product/price.vue",
"test/index.vue",
"test/promotion.vue",
"channel/index.vue",
"channel/supplier.vue",
"assessment/diagnosis.vue",
"assessment/optimization.vue",
];
test("统一实训工具栏同时提供案例下载、提交、重新实训和导出入口", () => {
const source = fs.readFileSync(toolbarPath, "utf8");
assert.match(source, /TrainingMaterialButton/);
assert.match(source, /提交任务/);
assert.match(source, /重新实训/);
assert.match(source, /导出实训成果/);
});
test("每个学生端实训菜单均接入统一顶部工具栏", () => {
for (const relativePath of studentTrainingPages) {
const source = fs.readFileSync(path.join(frontendRoot, "src/views", relativePath), "utf8");
assert.match(source, /<TrainingTaskToolbar\b/, relativePath);
}
// 任务说明区包装组件(TrainingTaskBrief)内部也必须接入同一工具栏
const briefSource = fs.readFileSync(path.join(frontendRoot, "src/views/components/TrainingTaskBrief.vue"), "utf8");
assert.match(briefSource, /<TrainingTaskToolbar\b/);
});
test("内置实训页面必须把页面自身的提交动作接线到工具栏", () => {
// 漏接 on-submit 时,工具栏"提交任务"会落入旧版兜底分支,对内置任务直接拒绝
// (提示"请先完成各步骤,再通过本实训的提交按钮提交。",学生无法提交)。
for (const relativePath of studentTrainingPages) {
const source = fs.readFileSync(path.join(frontendRoot, "src/views", relativePath), "utf8");
assert.match(source, /:on-submit=/, `${relativePath} 未接线 on-submit`);
}
// 历史事故页面(2026-10-27 学生无法提交)必须保持重置接线
for (const relativePath of [
"foundation/product-development-factors.vue",
"foundation/product-development-process.vue",
]) {
const source = fs.readFileSync(path.join(frontendRoot, "src/views", relativePath), "utf8");
assert.match(source, /:on-reset="resetTraining"/, `${relativePath} 未接线 on-reset`);
}
});