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\("售后政策已校验通过,任务提交成功"\)/); });