const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const test = require("node:test");
const frontendRoot = path.resolve(__dirname, "..");
const page = fs.readFileSync(path.join(frontendRoot, "src/views/assessment/diagnosis.vue"), "utf8");
const api = fs.readFileSync(path.join(frontendRoot, "src/api/studentTrainingAnswer.js"), "utf8");
test("产品问题诊断第一步固定首尾列并支持动态增删中间渠道", () => {
assert.match(page, /
链路节点<\/th>[\s\S]*?v-for="channel in channels"[\s\S]*? | 行业均值<\/th>/);
assert.match(page, /@click="addFunnelChannel"/);
assert.match(page, /@click="removeFunnelChannel\(channel\.id\)"/);
assert.match(page, /row\.channelRates\[channel\.id\]/);
assert.doesNotMatch(page, / | 天猫<\/th> | 京东<\/th> | 抖音<\/th> | 拼多多<\/th>/);
});
test("百分号与转化率输入框保持同行", () => {
assert.match(page, / [\s\S]*?%<\/span>[\s\S]*?<\/div>/);
assert.match(page, /\.rate-input\{[^}]*display:flex[^}]*white-space:nowrap/);
assert.match(page, /\.rate-input \.unit\{[^}]*white-space:nowrap/);
});
test("动态渠道随第一步答案提交并用于校验", () => {
assert.match(page, /channels: channelSnapshot/);
assert.match(page, /channelRates: \{ \.\.\.row\.channelRates \}/);
assert.match(api, /data: \{ channels: submittedChannels, conversionRates/);
assert.match(api, /source\.channelRates\[channel\.id\]/);
});
|