|
|
|
|
const fs = require("node:fs");
|
|
|
|
|
const path = require("node:path");
|
|
|
|
|
const test = require("node:test");
|
|
|
|
|
const assert = require("node:assert/strict");
|
|
|
|
|
|
|
|
|
|
const source = fs.readFileSync(path.resolve(__dirname, "../src/views/student/index.vue"), "utf8");
|
|
|
|
|
|
|
|
|
|
test("学生首页按老师评分优先、AI评分兜底显示成绩", () => {
|
|
|
|
|
assert.match(source, /report\.value\.teacherScore/);
|
|
|
|
|
assert.match(source, /report\.value\.aiAssessmentScore/);
|
|
|
|
|
assert.match(source, /hasTeacherScore\.value \? formatScore\(teacherScore\.value\) : formatScore\(aiScore\.value\)/);
|
|
|
|
|
assert.match(source, /const hasScore = computed\(\(\) => hasTeacherScore\.value \|\| hasAiScore\.value\)/);
|
|
|
|
|
assert.match(source, /评分:<\/span>\s*<strong>\{\{ displayScore \}\}/);
|
|
|
|
|
assert.doesNotMatch(source, /scoreLabel/);
|
|
|
|
|
assert.doesNotMatch(source, /summary-unit/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("学生首页成绩摘要保持单行且不展示当前排名", () => {
|
|
|
|
|
assert.match(source, /\.score-summary[^}]*flex-wrap:\s*nowrap/);
|
|
|
|
|
assert.match(source, /\.score-summary[^}]*white-space:\s*nowrap/);
|
|
|
|
|
assert.doesNotMatch(source, /当前排名/);
|
|
|
|
|
assert.doesNotMatch(source, /rank-copy/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("没有任何成绩时保持空值并显示占位符", () => {
|
|
|
|
|
assert.match(source, /totalScore: null, aiAssessmentScore: null, teacherScore: null/);
|
|
|
|
|
assert.match(source, /if \(value === null \|\| value === undefined \|\| value === ""\) return "—"/);
|
|
|
|
|
assert.match(source, /const aiScore = computed\(\(\) => report\.value\.aiAssessmentScore \?\? report\.value\.aiScore \?\? null\)/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log("student home AI and teacher score static checks passed");
|