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/after-sales-three-step-subm...

21 lines
1.3 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 assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const test = require("node:test");
const source = fs.readFileSync(path.join(__dirname, "../src/views/product/after-sales-service.vue"), "utf8");
test("实训任务14只定义三个步骤,末步不再指向第4步", () => {
assert.match(source, /const fallbackSteps = \["故障类型分类", "服务分级与处理方案", "售后服务流程设计"\];/);
assert.match(source, /const trainingSteps = computed\(\(\) => \{\s*const configuredSteps = parseTrainingArray\(taskConfig\.value\?\.steps, fallbackSteps\);\s*return fallbackSteps\.map\(\(fallbackStep, index\) => configuredSteps\[index\] \|\| fallbackStep\);\s*\}\);/);
assert.doesNotMatch(source, /保存并进入第 4 步/);
assert.doesNotMatch(source, /已进入第 4 步/);
});
test("实训任务14第3步校验通过后提交成果", () => {
assert.match(source, /校验并提交任务/);
assert.match(source, /currentStep\.value = normalizeStep\(3\);\s*await persist\("SUBMIT"\);/);
assert.match(source, /async function persist\(saveAction = "SAVE"\) \{ await saveStudentTrainingAnswer\(TASK_KEY, \{ saveAction, currentStep: currentStep\.value, submitted: saveAction === "SUBMIT",/);
assert.match(source, /msgSuccess\("售后政策已校验通过,任务提交成功"\)/);
});