Files
shanxia2.0/web-admin/scripts/test-mp-crm-contract-dom.mjs
T
2026-10-19 18:28:02 +08:00

74 lines
4.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
const root = new URL('../src/views/m/crm/contract/', import.meta.url)
const list = await readFile(new URL('MpContractList.vue', root), 'utf8')
const detail = await readFile(new URL('detail.vue', root), 'utf8')
assert.match(list, /<MpBusinessHeader/, '合同列表须用 MpBusinessHeader')
assert.match(list, /mp-contract-list/, '合同列表根节点须挂进绿头样式')
assert.match(list, /mp-customer-view-tabs/, '状态 Tab 须用绿头均分样式')
assert.match(list, /class="mp-customer-dd"/, '筛选行须复用透明白字下拉')
assert.match(list, /mp-wv-flat-card/, '合同列表须用扁平卡')
assert.match(list, /更多字段/, '合同卡须提供更多字段展开')
assert.match(list, /useIntersectionObserver/, '合同列表须滚动加载')
assert.match(list, /mp-wv-card-actions--single/, '单按钮卡片不得撑满整行')
assert.match(list, /van-date-picker/, '更多筛选日期须用 Vant 日期')
assert.match(list, /left-text="关闭"/, '筛选与审批弹层顶栏只保留关闭')
assert.match(list, /更多·已筛/, '更多条件须有已筛提示')
assert.doesNotMatch(list, /MpExpenseCard/, '合同列表不得再使用金额卡')
assert.doesNotMatch(list, /加载更多/, '合同列表不得使用加载更多按钮')
assert.doesNotMatch(list, /<el-select|<el-input/, '列表弹层不得露出 Element 输入控件')
assert.match(list, /mode === 'manage'/, 'Speed Dial 必须只在管理入口出现')
assert.match(list, /selectMode/, '合同列表必须保留多选模式')
assert.match(list, /mp-wv-batch-bar/, '合同列表必须保留选择后的批量底栏')
assert.match(
list,
/pendingApprovalUserId|buildContractListQuery/,
'审批入口必须保留当前用户待审批过滤'
)
assert.match(list, /approvedByUserId|buildContractListQuery/, '审批入口必须保留当前用户已审批过滤')
assert.match(list, /Promise\.allSettled/, '批量审批和作废必须保留部分成功统计')
assert.match(list, /fetchUserOptions/, '提交审批必须保留审批人选择')
assert.match(list, /requestSeq/, '列表必须忽略过期并发响应')
assert.match(list, /requestedPage = reset \? 1 : pageNum\.value \+ 1/, '分页必须成功后再提交页码')
assert.match(list, /onKeywordUpdate/, '搜索词从非空清空时必须自动刷新')
assert.match(list, /mp-wv-card-actions/, '待处理合同卡必须保留虚线操作栏')
assert.match(
list,
/v-if="cardActions\(card\)\.length"/,
'无操作按钮的合同卡必须隐藏空操作栏'
)
assert.doesNotMatch(list, /:has\(/, '不得依赖旧 WebView 不稳定的 :has 选择器')
assert.doesNotMatch(
list,
/from ['"](?:vue|vue-router|element-plus)['"]/,
'合同列表不得手工导入已配置 auto-import 的 Vue、Router 或 Element Plus API'
)
assert.match(detail, /title="合同详情"/, '详情顶栏必须使用固定标题')
assert.doesNotMatch(detail, /\{\{\s*headerTitle\s*\}\}/, '详情顶栏不得使用记录标题')
assert.doesNotMatch(detail, /mp-wv-header__sub/, '详情顶栏不得展示副标题')
assert.match(detail, /mp-contract-detail-tabs/, '详情必须提供业务 Tab')
assert.match(detail, /onAnchorTab/, '详情 Tab 须为锚点')
assert.match(detail, /--mp-h5-anchor-offset/, '详情锚点须避开吸顶 Tab')
assert.match(detail, /mp-h5-approve-sheet/, '通过/驳回须使用贴底审批弹层')
assert.match(detail, /left-text="关闭"/, '审批弹层顶栏只保留关闭')
assert.match(detail, /showCrmConfirmDialog/, '详情确认须走横排确认弹窗')
assert.match(detail, /kind: 'danger'/, '删除/作废须危险确认语义')
assert.match(detail, /别名/, '详情产品须含别名')
assert.doesNotMatch(detail, /v-if="activeTab ===/, '详情分区不得按 Tab 互斥隐藏')
assert.match(detail, /<MpApprovalTimeline/, '审批信息必须使用共用时间轴')
assert.match(detail, /<MpAttachmentGrid/, '附件必须使用 72×72 共用宫格')
assert.match(detail, /parseCrmAttachmentField/, '详情必须继续复用 CRM 附件解析工具链')
assert.match(detail, /fetchUploadAttachment/, '详情必须继续复用现有附件上传接口')
assert.match(detail, /uploadAttachments/, '详情必须保持现有合同附件保存接口')
assert.match(detail, /minStep/, '审批动作只能针对当前最小未决步骤')
assert.doesNotMatch(
detail,
/from ['"](?:vue|vue-router|element-plus)['"]/,
'合同详情不得手工导入已配置 auto-import 的 Vue、Router 或 Element Plus API'
)
console.log('contract DOM contract: PASS')