Files
zyt/server/tests/QywxCustomerChannelUiContractTest.mjs
2026-09-03 16:03:41 +08:00

61 lines
3.4 KiB
JavaScript

import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const currentDir = path.dirname(fileURLToPath(import.meta.url))
const pagePath = path.resolve(currentDir, '../../admin/src/views/fans/qywx.vue')
const source = fs.readFileSync(pagePath, 'utf8')
function expect(condition, message) {
if (!condition) throw new Error(message)
}
expect(source.includes('<el-table-column label="添加渠道"'), '客户主表缺少添加渠道列')
expect(source.includes('<el-descriptions-item label="添加渠道"'), '客户详情缺少添加渠道')
expect(source.includes('<el-form-item label="渠道"'), '客户检索区缺少渠道筛选')
expect(source.includes('v-model="queryParams.add_way"'), '渠道筛选未绑定 add_way 参数')
expect(source.includes('v-for="option in ADD_WAY_OPTIONS"'), '渠道筛选未复用完整添加方式枚举')
expect(source.includes('placeholder="选择或搜索添加渠道"'), '渠道筛选必须支持按可读文案检索')
expect(source.includes('queryParams.add_way ='), '重置操作未清空渠道筛选')
expect(source.includes('customerAddSources(row)'), '客户主表未读取可读添加方式')
expect(source.includes('customerAddSources(currentCustomer)'), '客户详情未读取可读添加方式')
expect(source.includes(':key="source.key"'), '添加方式循环必须使用成员关系级稳定 key')
expect(source.includes('add_channel_states'), '前端缺少原始渠道数组兼容逻辑')
expect(source.includes('未记录'), '无渠道客户必须明确显示未记录')
for (const [addWay, label] of [
[0, '未知添加方式'],
[1, '通过扫描二维码添加'],
[2, '通过搜索手机号添加'],
[3, '通过名片分享添加'],
[4, '通过群聊添加'],
[5, '通过手机通讯录添加'],
[6, '通过微信联系人添加'],
[8, '安装第三方应用时自动添加'],
[9, '通过搜索邮箱添加'],
[10, '通过视频号添加'],
[11, '通过日程参与人添加'],
[12, '通过会议参与人添加'],
[13, '通过微信好友添加'],
[14, '通过智慧硬件专属客服添加'],
[15, '通过上门服务客服添加'],
[16, '通过获客链接添加'],
[17, '通过定制开发添加'],
[18, '通过需求回复添加'],
[21, '通过第三方售前客服添加'],
[22, '通过可能的商务伙伴添加'],
[24, '通过接受微信好友申请添加'],
[201, '通过内部成员共享添加'],
[202, '通过管理员或负责人分配添加']
]) {
expect(source.includes(`${addWay}: '${label}'`), `add_way=${addWay} 未显示可读来源`)
}
expect(source.includes('add_way_label'), '前端未优先使用后端返回的添加方式文案')
expect(source.includes('添加方式:${source.label}'), '悬浮说明缺少直观添加方式')
expect(source.includes('获客助手方案:${source.channel_label}'), '悬浮说明缺少获客助手方案')
expect(source.includes('跟进人:${source.staff_name}'), '悬浮说明缺少对应跟进人')
expect(source.includes('添加时间:${formatTime(source.event_time)}'), '悬浮说明缺少添加时间')
expect(source.includes('渠道参数:${source.state}'), '原始 state 必须仅保留在悬浮说明')
expect(!source.includes('{{ addChannelText(channel) }}'), '列表不得继续直接展示原始渠道参数')
console.log('QYWX_CUSTOMER_CHANNEL_UI_CONTRACT_OK')