customerProfileOnlyTemplate.test.mjs
3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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 constantsSource = readFileSync(
new URL('../constants.js', 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 archive fields read-only while allowing VIN and plate input', () => {
assert.ok(start >= 0)
assert.ok(end > start)
assert.match(customerSection, /bindtitleClick="showCustomPop"/)
assert.match(customerSection, /label="车主姓名"/)
assert.match(customerSection, /iconSrc="\{\{ recordIcon \}\}"/)
assert.match(
constantsSource,
/RECORD_ICON: `\$\{CDN_BASE\}\/miniProgram\/record\.png`/
)
assert.match(customerSection, /labelWidth="var\(--fontSize290\)"/)
assert.match(customerSection, /orderObj\.customer\.customerName \|\| '请通过选择客户档案'/)
assert.equal(customerSection.match(/请通过选择客户档案/g)?.length, 1)
assert.doesNotMatch(customerSection, /请通过客户档案选择/)
assert.match(customerSection, /label="客户来源"/)
assert.match(customerSection, /value="\{\{ filter\.getSalesTypeName\(Sourcecolumns, orderObj\.customer\.salesType\) \}\}"/)
assert.match(
customerSection,
/label="客户来源"[\s\S]*bindclick="toSelectCustomerSource"/
)
assert.match(template, /default-index="\{\{ sourceDefaultIndex \}\}"/)
assert.match(customerSection, /label="性别"/)
assert.match(customerSection, /orderObj\.customer\.customerSex == 1 \? '男' : \(orderObj\.customer\.customerSex == 2 \? '女' : ''\)/)
assert.match(customerSection, /label="手机号"/)
assert.match(customerSection, /value="\{\{ 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, /value="\{\{ orderObj\.customer\.standNo \}\}"/)
assert.match(customerSection, /data-name="customer\.standNo"/)
assert.match(customerSection, /label="车牌号"/)
assert.match(customerSection, /value="\{\{ orderObj\.customer\.plateNumber \}\}"/)
assert.match(customerSection, /data-name="customer\.plateNumber"/)
assert.match(customerSection, /label="是否体验"/)
assert.match(customerSection, /orderObj\.customer\.experienceFlag == 'Y' \? '是' : \(orderObj\.customer\.experienceFlag == 'N' \? '否' : ''\)/)
assert.equal(customerSection.match(/<input/g)?.length, 2)
assert.doesNotMatch(customerSection, /bind:click="toSelectCustomerSource"/)
assert.doesNotMatch(customerSection, /bindtap="changeGender"/)
assert.doesNotMatch(customerSection, /data-show-name="carBrandBox"/)
assert.equal(customerSection.match(/bindtitleClick="navOcr"/g)?.length, 2)
assert.doesNotMatch(customerSection, /bindtap="changeExperience"/)
})
it('queries customer archives with the 4S store selected before order creation', () => {
assert.match(template, /<customerInfo[\s\S]*merchantId="\{\{ orderObj\.merchantId \|\| 0 \}\}"/)
assert.doesNotMatch(template, /<customerInfo[\s\S]*merchantId="\{\{ workOrderUserContext\.shopMerchantId \|\| 0 \}\}"/)
})
})