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

62 lines
3.8 KiB
JavaScript
Raw Permalink 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/quote/', import.meta.url)
const list = await readFile(new URL('MpQuoteList.vue', root), 'utf8')
const detail = await readFile(new URL('detail.vue', root), 'utf8')
const form = await readFile(new URL('form.vue', root), 'utf8')
const quoteScss = await readFile(new URL('quote.scss', root), 'utf8')
assert.match(list, /<MpBusinessHeader/, '报价列表须用 MpBusinessHeader')
assert.match(list, /van-tabs/, '报价列表须有状态 Tab')
assert.match(list, /van-dropdown-menu/, '报价列表须用三栏筛选')
assert.match(list, /mp-quote-list-card/, '报价列表须用扁平卡')
assert.match(list, /更多字段/, '报价卡须提供更多字段展开')
assert.doesNotMatch(list, /MpExpenseCard/, '报价列表不得再使用 MpExpenseCard')
assert.doesNotMatch(list, /MpStatusTabs/, '报价列表不得再使用 MpStatusTabs')
assert.doesNotMatch(list, /MpThreeColumnFilters/, '报价列表不得再使用 MpThreeColumnFilters')
assert.match(list, /mode === 'manage'/, 'Speed Dial 必须只在管理入口出现')
assert.match(list, /提交审批/, '管理草稿卡必须提供提交审批入口')
assert.match(list, /驳回/, '待审批卡必须提供驳回入口')
assert.match(list, /openDetailAction/, '列表动作必须复用详情状态机')
assert.match(
list,
/pendingApprovalUserId|buildQuoteListQuery/,
'审批入口必须保留当前用户待审批过滤'
)
assert.match(list, /approvedByUserId|buildQuoteListQuery/, '审批入口必须保留当前用户已审批过滤')
assert.match(list, /useIntersectionObserver/, '报价列表须滚动加载')
assert.doesNotMatch(list, /加载更多/, '报价列表不得使用加载更多按钮')
assert.match(list, /mp-wv-card-actions--single/, '单按钮卡片不得撑满整行')
assert.match(list, /van-date-picker/, '更多筛选日期须用 Vant 日期')
assert.match(detail, /title="报价单详情"/, '详情顶栏必须使用固定标题')
assert.doesNotMatch(detail, /\{\{\s*headerTitle\s*\}\}/, '详情顶栏不得使用记录标题')
assert.doesNotMatch(detail, /mp-wv-header__sub/, '详情顶栏不得展示副标题')
assert.match(detail, /class="mp-quote-detail-tabs"/, '详情必须提供业务 Tab')
assert.match(detail, /<van-tabs/, '详情 Tab 须为 van-tabs')
assert.match(detail, /<MpApprovalTimeline/, '审批信息必须使用共用时间轴')
assert.match(detail, /<MpAttachmentGrid/, '附件必须使用 72×72 共用宫格')
assert.match(detail, /mp-wv-fab-bar[\s\S]*mp-wv-touch-target/, '详情底栏按钮必须使用 44px 触达类')
assert.match(detail, /onAnchorTab/, '详情 Tab 须为锚点')
assert.match(detail, /--mp-quote-anchor-offset/, '详情锚点须避开吸顶 Tab')
assert.match(detail, /mp-quote-approve-sheet/, '通过/驳回须使用审批弹层')
assert.match(detail, /left-text="关闭"/, '审批弹层顶栏只保留关闭')
assert.match(
quoteScss,
/\.mp-quote-approve-sheet__foot \.van-button[\s\S]*min-height: 44px/,
'审批确认按钮触达须至少 44px'
)
assert.match(quoteScss, /#0a9f6d/, '审批弹层主色须为三墙绿')
assert.doesNotMatch(detail, /#10b981/, '审批详情不得使用 Fresh Mint 主色')
assert.match(detail, /返回报价单审批/, '审批入口返回文案须指向审批列表')
assert.match(detail, /别名/, '详情产品须含别名')
assert.match(quoteScss, /\.mp-quote-detail-page \.mp-wv-fab-bar[\s\S]*position: fixed/, '详情底栏须固定')
assert.match(quoteScss, /\.mp-quote-form-footer[\s\S]*position: fixed/, '表单底栏须固定')
assert.match(detail, /showCrmConfirmDialog/, '详情确认须走 CRM 确认弹窗')
assert.match(detail, /kind: 'danger'/, '删除/驳回须危险确认语义')
assert.match(form, /<MpBusinessHeader/, '表单外壳须用 MpBusinessHeader')
console.log('quote DOM contract: PASS')