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.resolve(__dirname, "../src/views/demand/consumer-behavior.vue"), "utf8"); const templatePath = path.resolve( __dirname, "../../dianshang-houduan/src/main/resources/static/file/training-materials/consumer-behavior/9.问卷调查报告模板.docx" ); test("消费者需求与行为第三步从后端下载问卷模板", () => { assert.ok(fs.existsSync(templatePath), "问卷模板应随后端资源发布"); assert.match(source, /\/file\/training-materials\/consumer-behavior\/9\.问卷调查报告模板\.docx/); assert.match(source, /下载模板/); assert.match(source, /function downloadQuestionnaireTemplate\(/); const reportFunction = source.match(/function downloadSurveyReportTemplate\(\)[\s\S]*?\n}\n<\/script>/)?.[0] || ""; assert.match(reportFunction, /downloadBuiltInFile\(QUESTIONNAIRE_TEMPLATE_URL, "9\.问卷调查报告模板\.docx"\)/); assert.doesNotMatch(reportFunction, /new Blob/, "报告模板不应由前端临时生成"); });