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.
70 lines
4.3 KiB
JavaScript
70 lines
4.3 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { existsSync, readFileSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
|
|
const root = resolve(import.meta.dirname, "..");
|
|
const previewUtilsPath = resolve(root, "src/utils/trainingReviewPreview.js");
|
|
|
|
assert.equal(existsSync(previewUtilsPath), true, "评阅预览上下文工具应存在");
|
|
|
|
const previewUtils = readFileSync(previewUtilsPath, "utf8");
|
|
const answerApi = readFileSync(resolve(root, "src/api/studentTrainingAnswer.js"), "utf8");
|
|
const trainingTaskApi = readFileSync(resolve(root, "src/api/trainingTask.js"), "utf8");
|
|
const requestApi = readFileSync(resolve(root, "src/utils/request.js"), "utf8");
|
|
const previewMapPath = resolve(root, "src/views/teacherEnd/taskReview/studentTaskPreviewMap.js");
|
|
const previewShellPath = resolve(root, "src/views/teacherEnd/taskReview/StudentTaskReadonlyPreview.vue");
|
|
const router = readFileSync(resolve(root, "src/router/index.js"), "utf8");
|
|
const reviewPanel = readFileSync(resolve(root, "src/views/teacherEnd/score/TaskReviewPanel.vue"), "utf8");
|
|
|
|
assert.match(previewUtils, /export function writeTrainingReviewPreview/);
|
|
assert.match(previewUtils, /export function getTrainingReviewPreviewContext/);
|
|
assert.match(previewUtils, /student\/project-study-time/);
|
|
assert.match(answerApi, /getTrainingReviewPreviewContext\(\)/);
|
|
assert.match(trainingTaskApi, /getTrainingReviewPreviewContext/);
|
|
assert.match(trainingTaskApi, /preview\.taskConfig/);
|
|
assert.match(trainingTaskApi, /评阅案例配置未加载/);
|
|
assert.match(requestApi, /isTrainingReviewPreviewRequest/);
|
|
assert.equal(existsSync(previewMapPath), true, "全部学生任务的预览映射应存在");
|
|
assert.equal(existsSync(previewShellPath), true, "学生任务只读预览容器应存在");
|
|
|
|
const previewMap = readFileSync(previewMapPath, "utf8");
|
|
const previewShell = readFileSync(previewShellPath, "utf8");
|
|
const expectedTaskKeys = [
|
|
"new-product-survey", "product-development-factors", "product-development-process",
|
|
"industry-demand-analysis", "competitive-environment-analysis", "market-opportunity-selection",
|
|
"business-feasibility", "target-user-profile", "consumer-behavior", "consumer-scenario",
|
|
"feature-conversion", "product-value-positioning", "product-structure", "after-sales-service",
|
|
"requirements-doc", "hardware-cost", "supplier-evaluation", "purchase-demand-forecast",
|
|
"product-pricing", "category-optimization", "release-channel-evaluation",
|
|
"promotion-effect-optimization", "product-diagnosis-iteration", "comprehensive-case-training",
|
|
];
|
|
for (const taskKey of expectedTaskKeys) assert.match(previewMap, new RegExp(`"${taskKey}"`));
|
|
assert.match(router, /path:\s*"\/task-review-preview"[\s\S]*?hidden:\s*true/);
|
|
assert.match(previewShell, /@click\.capture="guardPreviewInteraction"/);
|
|
assert.match(previewShell, /function guardPreviewInteraction/);
|
|
assert.match(previewShell, /getAttribute\("aria-label"\)/);
|
|
assert.match(previewShell, /pointer-events:\s*auto/);
|
|
assert.match(previewShell, /overflow-y:\s*scroll/);
|
|
assert.match(previewShell, /scrollbar-gutter:\s*stable/);
|
|
assert.match(previewShell, /scrollbar-color:\s*#238db8\s+#061724/);
|
|
assert.match(reviewPanel, /writeTrainingReviewPreview/);
|
|
assert.match(reviewPanel, /listClassTrainingTasks\(filters\.value\.classId/);
|
|
assert.match(reviewPanel, /find\(\(task\) => task\.taskKey === taskKey\)/);
|
|
assert.match(reviewPanel, /taskConfig:\s*effectiveTask/);
|
|
assert.match(reviewPanel, /previewRequestVersion/);
|
|
assert.match(reviewPanel, /studentPreviewError/);
|
|
assert.match(reviewPanel, /<iframe[^>]+studentPreviewSrc/);
|
|
assert.match(reviewPanel, /scrolling="yes"/);
|
|
assert.match(reviewPanel, /grid-template-columns: minmax\(360px, 400px\) minmax\(0, 1fr\)/);
|
|
assert.match(reviewPanel, /class="task-review__student-table"/);
|
|
assert.match(reviewPanel, /type="selection" width="38"/);
|
|
assert.match(reviewPanel, /prop="name" label="姓名" width="74"/);
|
|
assert.match(reviewPanel, /prop="username" label="学号" width="88"/);
|
|
assert.match(reviewPanel, /label="AI评分" width="66"/);
|
|
assert.match(reviewPanel, /label="老师评分" width="94"/);
|
|
assert.match(reviewPanel, /background:\s*#061724/);
|
|
assert.doesNotMatch(reviewPanel, /task-review__student-preview[^}]*background:\s*#fff/);
|
|
assert.doesNotMatch(reviewPanel, /<el-collapse[\s\S]*?formatAnswer/);
|
|
|
|
console.log("task review preview context blocks student-answer writes");
|