| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import assert from 'node:assert/strict'
- import { readFile } from 'node:fs/promises'
- const root = new URL('../src/views/m/crm/customer/', import.meta.url)
- const files = [
- 'index.vue',
- 'detail.vue',
- 'form.vue',
- 'ContactPanel.vue',
- 'FollowPanel.vue',
- 'InvoicePanel.vue',
- 'OpportunityActions.vue',
- 'CustomerPoolSheet.vue'
- ]
- const sources = {}
- for (const name of files) {
- sources[name] = await readFile(new URL(name, root), 'utf8')
- }
- const customerScss = await readFile(new URL('customer.scss', root), 'utf8')
- assert.match(
- customerScss,
- /van-dialog:not\(\.mp-crm-dialog\)/,
- '客户 scss 不得用旧 Dialog 按钮样式压扁 mp-crm-dialog'
- )
- for (const [name, src] of Object.entries(sources)) {
- assert.doesNotMatch(src, /showConfirmDialog\s*\(/, `${name} 不得直接调用 showConfirmDialog`)
- assert.match(src, /showCrmConfirmDialog|from '@\/utils\/mp-crm-confirm'/, `${name} 必须使用 CRM 确认弹窗`)
- }
- assert.match(sources['index.vue'], /kind:\s*'danger'/, '列表删除客户须 danger')
- assert.match(sources['detail.vue'], /kind:\s*'danger'/, '详情删除客户须 danger')
- assert.match(sources['ContactPanel.vue'], /kind:\s*'danger'/, '删除联系人须 danger')
- assert.match(sources['ContactPanel.vue'], /kind:\s*'default'/, '设主要联系人须 default')
- assert.match(sources['FollowPanel.vue'], /kind:\s*'danger'/, '删除跟进须 danger')
- assert.match(sources['InvoicePanel.vue'], /kind:\s*'danger'/, '删除开票须 danger')
- assert.match(sources['OpportunityActions.vue'], /kind:\s*'danger'/, '删除商机须 danger')
- assert.match(sources['form.vue'], /kind:\s*'default'/, '新增字典项须 default')
- assert.match(sources['CustomerPoolSheet.vue'], /kind:\s*'default'/, '放入公海须 default')
- console.log('mp-crm-customer-confirm-dom: ok')
|