|
|
|
|
const assert = require("node:assert/strict");
|
|
|
|
|
const fs = require("node:fs");
|
|
|
|
|
const path = require("node:path");
|
|
|
|
|
|
|
|
|
|
const root = path.resolve(__dirname, "..");
|
|
|
|
|
const page = fs.readFileSync(path.join(root, "src/views/foundation/new-product-survey.vue"), "utf8");
|
|
|
|
|
const api = fs.readFileSync(path.join(root, "src/api/studentTrainingAnswer.js"), "utf8");
|
|
|
|
|
const materialButton = fs.readFileSync(path.join(root, "src/views/components/TrainingMaterialButton.vue"), "utf8");
|
|
|
|
|
|
|
|
|
|
assert.match(page, /const STEP_ONE_SELLING_POINTS = \[/, "step one must define its fixed selling-point questions");
|
|
|
|
|
assert.ok((page.match(/selling-point-/g) || []).length >= 11, "step one must contain all 11 selling points");
|
|
|
|
|
assert.match(page, /核心层/, "classification options must include 核心层");
|
|
|
|
|
assert.match(page, /有形层/, "classification options must include 有形层");
|
|
|
|
|
assert.match(page, /延伸层/, "classification options must include 延伸层");
|
|
|
|
|
assert.match(page, /checkNewProductSurveyStepOne/, "step one must request server-side grading");
|
|
|
|
|
assert.match(page, /checkResult/, "step one must retain grading feedback");
|
|
|
|
|
assert.match(page, /TrainingMaterialButton/, "the existing material download button must remain in place");
|
|
|
|
|
assert.match(api, /new-product-survey\/step-1\/check/, "the student API must call the step-one grading endpoint");
|
|
|
|
|
assert.match(page, /const STEP_TWO_PLATFORM_OPTIONS = \[/, "step two must offer the prescribed survey platforms");
|
|
|
|
|
assert.match(page, /const STEP_TWO_SCENE_OPTIONS = \[/, "step two must offer the prescribed survey scenes");
|
|
|
|
|
assert.match(page, /v-if="step2Form\.scene === '其他场景'"/, "other scenes must reveal a custom-scene input");
|
|
|
|
|
assert.match(page, /MAX_STEP_TWO_IMAGES = 5/, "step two must cap product image uploads at five");
|
|
|
|
|
assert.match(page, /@click="previewStepTwoImage\(image\.url\)"/, "uploaded product thumbnails must be previewable");
|
|
|
|
|
assert.match(page, /step2Answer: JSON\.stringify\(step2Form\.value\)/, "step two must persist the survey form instead of table rows");
|
|
|
|
|
assert.match(page, /checkNewProductSurveyStepTwo\(step2Form\.value\)/, "step two must request server-side validation before advancing");
|
|
|
|
|
assert.match(api, /new-product-survey\/step-2\/validate/, "the student API must call the step-two validation endpoint");
|
|
|
|
|
assert.match(materialButton, /下载案例资料/, "the download button must use a fixed student-facing label");
|
|
|
|
|
assert.doesNotMatch(materialButton, /\{\{ material\?\.name \|\| "案例文档" \}\}/, "the upload file name must not become button text");
|
|
|
|
|
|
|
|
|
|
console.log("new product survey step-one contract passed");
|