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/market-opportunity-selection.vue"), "utf8"); test("第三步固定呈现三个产品品类的综合得分输入", () => { const expected = ["smart-fitness-mirror", "smart-bathroom-mirror", "smart-beauty-mirror"]; const productBlock = source.match(/const products = \[([^;]+)\];/)?.[1] || ""; const actual = [...productBlock.matchAll(/id: "([^"]+)"/g)].map((match) => match[1]); assert.deepEqual(actual, expected); assert.match(source, /[\s\S]*?综合得分[\s\S]*?v-model\.number="scores\[product\.id\]"[\s\S]*?min="0" max="100" step="0\.01"/); }); test("第三步下载真实 Excel 自动化模板,并保留 Min-Max 与三段式权重说明", () => { assert.match(source, /import \* as XLSX from "xlsx"/); assert.match(source, /XLSX\.utils\.book_new\(\)/); assert.match(source, /XLSX\.utils\.book_append_sheet\(workbook, worksheet, "综合得分计算"\)/); assert.match(source, /XLSX\.writeFile\(workbook, "市场机会识别与选品-自动化模板\.xlsx"\)/); assert.match(source, /primaryWeightCell = XLSX\.utils\.encode_cell\(\{ c: rawStartColumn \+ index, r: 9 \}\)/); assert.match(source, /dimensionWeightCell = XLSX\.utils\.encode_cell\(\{ c: rawStartColumn \+ index, r: 10 \}\)/); assert.match(source, /correspondingWeightCell = XLSX\.utils\.encode_cell\(\{ c: rawStartColumn \+ index, r: 11 \}\)/); assert.match(source, /\$\$\{correspondingStart\}\$12:\$\$\{correspondingEnd\}\$12/); assert.match(source, /Min-Max 归一法/); assert.match(source, /第 1–20 天、第 21–40 天、第 41–60 天/); });