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/project-study-time.static.t...

38 lines
1.7 KiB
JavaScript

const fs = require("node:fs");
const path = require("node:path");
const test = require("node:test");
const assert = require("node:assert/strict");
const root = path.resolve(__dirname, "..");
const api = fs.readFileSync(path.join(root, "src/api/projectStudyTime.js"), "utf8");
const genericPage = fs.readFileSync(path.join(root, "src/views/training/GenericTrainingPage.vue"), "utf8");
const customPage = fs.readFileSync(path.join(root, "src/views/training/CustomTrainingStepPage.vue"), "utf8");
const dashboard = fs.readFileSync(path.join(root, "src/views/student/index.vue"), "utf8");
const analysis = fs.readFileSync(path.join(root, "src/views/analysis-of-students/analysis.vue"), "utf8");
test("project study time API records and loads current student's module durations", () => {
assert.match(api, /recordProjectStudyTime/);
assert.match(api, /getCurrentProjectStudyTime/);
assert.match(api, /\/api\/student\/project-study-time\/record/);
assert.match(api, /\/api\/student\/project-study-time\/current/);
});
test("training pages flush time spent in the active project", () => {
for (const page of [genericPage, customPage]) {
assert.match(page, /useProjectStudyTime/);
assert.match(page, /projectName/);
}
});
test("student dashboard visualizes per-project study time and keeps task progress beside it", () => {
assert.match(dashboard, /studyTimeChartRef/);
assert.match(dashboard, /renderStudyTimeChart/);
assert.match(dashboard, /getCurrentProjectStudyTime/);
assert.match(dashboard, /progressChartRef/);
});
test("AI learning analysis reads current project study durations", () => {
assert.match(analysis, /getCurrentProjectStudyTime/);
assert.match(analysis, /projectStudyTimes/);
});