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/student-task-loading-lifecy...

24 lines
1005 B
JavaScript

const assert = require("assert");
const fs = require("fs");
const path = require("path");
const root = path.join(__dirname, "..");
const appMain = fs.readFileSync(path.join(root, "src", "layout", "components", "AppMain.vue"), "utf8");
const trainingTaskApi = fs.readFileSync(path.join(root, "src", "api", "trainingTask.js"), "utf8");
assert(
appMain.includes("studentTaskLoading.value = false;"),
"切回已缓存的学生实训页时,旧加载遮罩必须先清除"
);
assert(
!appMain.includes("studentTaskLoading.value = Boolean(taskKey);"),
"路由切换不能在没有真实请求时强制显示实训加载遮罩"
);
assert.match(
trainingTaskApi,
/if \(pendingTaskRequests\.has\(normalizedTaskKey\)\) \{[\s\S]*?notifyStudentTaskConfigLoading\(normalizedTaskKey, true\);[\s\S]*?return pendingTaskRequests\.get\(normalizedTaskKey\);/,
"复用进行中的任务配置请求时,必须重新广播加载状态"
);
console.log("student task loading lifecycle static checks passed");