quotationCustomerDailyFields.ui.test.mjs
6.26 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
const read = relativePath =>
readFileSync(fileURLToPath(new URL(relativePath, import.meta.url)), 'utf8')
describe('quotation customer daily field UI contract', () => {
it('IT-EQ-DAILY-UI-001: standard and simple forms contain both optional fields', () => {
const config = read('../pages/carQuotation/components/constant/stepData.js')
const wxml = read('../pages/carQuotation/components/FirstStep/FirstStep.wxml')
assert.equal((config.match(/label: "日报标签"/g) || []).length, 2)
assert.equal((config.match(/label: "实际交付日期"/g) || []).length, 2)
assert.match(wxml, /equityCustomerTagsPopup/)
assert.match(wxml, /onConfirmEquityCustomerTags/)
assert.match(wxml, /mode="date"/)
})
it('IT-EQ-DAILY-UI-009: delivery date picker prevents selecting a future local date', () => {
const js = read('../pages/carQuotation/components/FirstStep/FirstStep.js')
const wxml = read('../pages/carQuotation/components/FirstStep/FirstStep.wxml')
assert.match(
wxml,
/<picker\s+slot="actualDeliveryDate"\s+mode="date"\s+value="\{\{ actualDeliveryDateText \}\}"\s+end="\{\{ actualDeliveryDateMax \}\}"\s+disabled="\{\{ disable \}\}"\s+bindchange="onEquityDeliveryDateChange"\s*>/
)
assert.match(
js,
/var timeUtil = require\('~\/utils\/timeFormat\/time-utils\.js'\)/
)
assert.match(
js,
/actualDeliveryDateMax:\s*timeUtil\.getTodayDateStr\(\)/
)
})
it('IT-EQ-DAILY-UI-010: visible delivery date shows required state and blocks an empty next step', () => {
const config = read('../pages/carQuotation/components/constant/stepData.js')
const js = read('../pages/carQuotation/components/FirstStep/FirstStep.js')
const requiredDateFields = config.match(
/name: "actualDeliveryDate",[\s\S]*?required: true,[\s\S]*?requiredAfter: true,[\s\S]*?isShowObj:/g
) || []
assert.equal(requiredDateFields.length, 2)
assert.match(js, /isEquityActualDeliveryDateMissing/)
assert.match(
js,
/isEquityActualDeliveryDateMissing\(\s*dailyFieldVisibility\.actualDeliveryDate,\s*owner\.actualDeliveryDate\s*\)/
)
assert.match(js, /wx\.\$util\.showToast\('实际交付日期不能为空'\)/)
})
it('IT-EQ-DAILY-UI-002: required certificate config no longer relies on index', () => {
const page = read(
'../pages/carQuotation/createOrderCarQuotationSimple/createOrderCarQuotationSimple.js'
)
const formConfig = read(
'../pages/carQuotation/services/simpleQuotationFormConfig.helpers.js'
)
assert.match(page, /buildSimpleQuotationFormConfig/)
assert.doesNotMatch(formConfig, /customerFormList\[6\]/)
assert.match(formConfig, /findIndex\([\s\S]*certificateNo/)
})
it('IT-EQ-DAILY-UI-003: payment detail shows stored daily fields', () => {
const detail = read(
'../pages/carQuotation/CarQuotationDetail/CarQuotationDetail.wxml'
)
assert.match(detail, /日报标签/)
assert.match(detail, /实际交付日期/)
assert.match(detail, /customerTagLabels/)
})
it('IT-EQ-DAILY-UI-004: add, update and additional recording share owner formatting', () => {
const standard = read(
'../pages/carQuotation/createOrderCarQuotation/createOrderCarQuotation.js'
)
const simple = read(
'../pages/carQuotation/createOrderCarQuotationSimple/createOrderCarQuotationSimple.js'
)
assert.match(standard, /getOwnerInfo\(\)[\s\S]*buildOwnerPayload/)
assert.match(
standard,
/orderInfo\.owner = owner[\s\S]*submitStandardQuotation\([\s\S]*quotationAdd,[\s\S]*updateQuotation/
)
assert.match(simple, /getOwnerInfo\(\)[\s\S]*buildOwnerPayload/)
assert.match(
simple,
/setQuotationRecording\(preparedOrderInfo\)[\s\S]*preparedOrderInfo \|\| this\.getInsurance\(\)[\s\S]*recordSimpleQuotationOrder/
)
assert.match(
simple,
/const insurance = this\.getInsurance\(\)[\s\S]*submitSimpleQuotationCheckout\([\s\S]*quotationAdd,[\s\S]*updateQuotation,[\s\S]*errorOrderById/
)
})
it('IT-EQ-DAILY-UI-005: FirstStep hides the whole date row through GLForm visibility context', () => {
const form = read('../components/GLForm/GLForm.wxml')
const firstStep = read(
'../pages/carQuotation/components/FirstStep/FirstStep.wxml'
)
assert.match(form, /visibilityMap/)
assert.match(firstStep, /visibilityMap="\{\{ dailyFieldVisibility \}\}"/)
})
it('IT-EQ-DAILY-UI-006: standard and simple submitters pass order scene context', () => {
const standard = read(
'../pages/carQuotation/createOrderCarQuotation/createOrderCarQuotation.js'
)
const simple = read(
'../pages/carQuotation/createOrderCarQuotationSimple/createOrderCarQuotationSimple.js'
)
assert.match(
standard,
/buildOwnerPayload\([\s\S]*this\.data\.needChangeList,[\s\S]*orderInfo[\s\S]*\)/
)
assert.match(
simple,
/buildOwnerPayload\([\s\S]*this\.data\.needChangeList,[\s\S]*this\.data\.orderInfo[\s\S]*\)/
)
})
it('IT-EQ-DAILY-UI-007: quotation list renders normalized response fields conditionally', () => {
const listJs = read('../pages/carQuotation/index/index.js')
const listWxml = read('../pages/carQuotation/index/index.wxml')
assert.match(listJs, /buildEquityCustomerDailyListDisplay/)
assert.match(
listJs,
/item\.customerDailyDisplay\s*=\s*buildEquityCustomerDailyListDisplay\(item\)/
)
assert.doesNotMatch(
listJs,
/item\.customerDailyDisplay\s*=\s*buildEquityCustomerDailyDisplay\(item\)/
)
assert.match(listWxml, /item\.customerDailyDisplay\.showCustomerTags/)
assert.match(listWxml, /item\.customerDailyDisplay\.customerTagsText/)
assert.match(listWxml, /item\.customerDailyDisplay\.showActualDeliveryDate/)
assert.match(listWxml, /item\.customerDailyDisplay\.actualDeliveryDate/)
})
it('IT-EQ-DAILY-UI-008: FirstStep popup has no clear action', () => {
const wxml = read('../pages/carQuotation/components/FirstStep/FirstStep.wxml')
assert.doesNotMatch(wxml, /bindtap="onClearEquityCustomerTags">清空/)
assert.match(wxml, /onCancelEquityCustomerTags/)
assert.match(wxml, /onConfirmEquityCustomerTags/)
})
})