customerProfileOnlyTemplate.test.mjs 2.73 KB
import { readFileSync } from 'node:fs'
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'

const template = readFileSync(
  new URL('../createOrder.wxml', import.meta.url),
  'utf8'
)
const start = template.indexOf('<view class="customerName">')
const end = template.indexOf(
  '\n\t\t<view class="box" wx:if="{{ orderObj.userId && orderObj.baseSceneCode }}">',
  start
)
const customerSection = template.slice(start, end)

describe('createOrder customer information template', () => {
  it('keeps customer archive as the only manual customer-data entry', () => {
    assert.ok(start >= 0)
    assert.ok(end > start)
    assert.match(customerSection, /bindtitleClick="showCustomPop"/)
    assert.match(customerSection, /label="车主姓名"/)
    assert.match(customerSection, /labelWidth="var\(--fontSize290\)"/)
    assert.match(customerSection, /orderObj\.customer\.customerName \|\| '请通过客户档案选择'/)
    assert.match(customerSection, /label="客户来源"/)
    assert.match(customerSection, /filter\.getSalesTypeName\(Sourcecolumns, orderObj\.customer\.salesType\) \|\| '请通过客户档案选择'/)
    assert.match(customerSection, /label="性别"/)
    assert.match(customerSection, /orderObj\.customer\.customerSex == 1 \? '男' : \(orderObj\.customer\.customerSex == 2 \? '女' : '请通过客户档案选择'\)/)
    assert.match(customerSection, /label="手机号"/)
    assert.match(customerSection, /orderObj\.customer\.customerPhone \|\| '请通过客户档案选择'/)
    assert.match(customerSection, /label="选择车型"/)
    assert.match(customerSection, /orderObj\.customer\.carSeriesName \? orderObj\.customer\.carBrand \+ ' - ' \+ orderObj\.customer\.carChildsBrandName \+ ' - ' \+ orderObj\.customer\.carSeriesName : '请通过客户档案选择'/)
    assert.match(customerSection, /label="车架号\( VIN \)"/)
    assert.match(customerSection, /orderObj\.customer\.standNo \|\| '请通过客户档案选择'/)
    assert.match(customerSection, /label="车牌号"/)
    assert.match(customerSection, /orderObj\.customer\.plateNumber \|\| '请通过客户档案选择'/)
    assert.match(customerSection, /label="是否体验"/)
    assert.match(customerSection, /orderObj\.customer\.experienceFlag == 'Y' \? '是' : \(orderObj\.customer\.experienceFlag == 'N' \? '否' : '请通过客户档案选择'\)/)
    assert.doesNotMatch(customerSection, /<input/)
    assert.doesNotMatch(customerSection, /bind:click="toSelectCustomerSource"/)
    assert.doesNotMatch(customerSection, /bindtap="changeGender"/)
    assert.doesNotMatch(customerSection, /data-show-name="carBrandBox"/)
    assert.doesNotMatch(customerSection, /bindtitleClick="navOcr"/)
    assert.doesNotMatch(customerSection, /bindtap="changeExperience"/)
  })
})