test-mp-crm-customer-confirm-dom.mjs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import assert from 'node:assert/strict'
  2. import { readFile } from 'node:fs/promises'
  3. const root = new URL('../src/views/m/crm/customer/', import.meta.url)
  4. const files = [
  5. 'index.vue',
  6. 'detail.vue',
  7. 'form.vue',
  8. 'ContactPanel.vue',
  9. 'FollowPanel.vue',
  10. 'InvoicePanel.vue',
  11. 'OpportunityActions.vue',
  12. 'CustomerPoolSheet.vue'
  13. ]
  14. const sources = {}
  15. for (const name of files) {
  16. sources[name] = await readFile(new URL(name, root), 'utf8')
  17. }
  18. const customerScss = await readFile(new URL('customer.scss', root), 'utf8')
  19. assert.match(
  20. customerScss,
  21. /van-dialog:not\(\.mp-crm-dialog\)/,
  22. '客户 scss 不得用旧 Dialog 按钮样式压扁 mp-crm-dialog'
  23. )
  24. for (const [name, src] of Object.entries(sources)) {
  25. assert.doesNotMatch(src, /showConfirmDialog\s*\(/, `${name} 不得直接调用 showConfirmDialog`)
  26. assert.match(src, /showCrmConfirmDialog|from '@\/utils\/mp-crm-confirm'/, `${name} 必须使用 CRM 确认弹窗`)
  27. }
  28. assert.match(sources['index.vue'], /kind:\s*'danger'/, '列表删除客户须 danger')
  29. assert.match(sources['detail.vue'], /kind:\s*'danger'/, '详情删除客户须 danger')
  30. assert.match(sources['ContactPanel.vue'], /kind:\s*'danger'/, '删除联系人须 danger')
  31. assert.match(sources['ContactPanel.vue'], /kind:\s*'default'/, '设主要联系人须 default')
  32. assert.match(sources['FollowPanel.vue'], /kind:\s*'danger'/, '删除跟进须 danger')
  33. assert.match(sources['InvoicePanel.vue'], /kind:\s*'danger'/, '删除开票须 danger')
  34. assert.match(sources['OpportunityActions.vue'], /kind:\s*'danger'/, '删除商机须 danger')
  35. assert.match(sources['form.vue'], /kind:\s*'default'/, '新增字典项须 default')
  36. assert.match(sources['CustomerPoolSheet.vue'], /kind:\s*'default'/, '放入公海须 default')
  37. console.log('mp-crm-customer-confirm-dom: ok')