You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.6 KiB
JavaScript
30 lines
1.6 KiB
JavaScript
|
1 month ago
|
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 class="fixed-column">链路节点<\/th>[\s\S]*?v-for="channel in channels"[\s\S]*?<th class="fixed-column">行业均值<\/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><th>抖音<\/th><th>拼多多<\/th>/);
|
||
|
|
});
|
||
|
|
|
||
|
|
test("百分号与转化率输入框保持同行", () => {
|
||
|
|
assert.match(page, /<div class="rate-input">[\s\S]*?<el-input-number[\s\S]*?<span class="unit">%<\/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\]/);
|
||
|
|
});
|