customerDailyFields.ui.test.mjs
9.82 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
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('boutique customer daily field UI contract', () => {
it('IT-WO-DAILY-UI-001: create page renders optional fields and multi-select popup', () => {
const wxml = read('../createOrder.wxml')
assert.match(wxml, /label="日报标签"/)
assert.match(wxml, /label="实际交付日期"/)
assert.match(wxml, /customerTagsPopup/)
assert.match(wxml, /onConfirmCustomerTags/)
assert.match(wxml, /mode="date"/)
})
it('IT-WO-DAILY-UI-011: delivery date picker prevents selecting a future local date', () => {
const js = read('../createOrder.js')
const wxml = read('../createOrder.wxml')
assert.match(
wxml,
/<picker\s+wx:if="\{\{ showActualDeliveryDate \}\}"\s+mode="date"\s+value="\{\{ orderObj\.customer\.actualDeliveryDate \}\}"\s+end="\{\{ actualDeliveryDateMax \}\}"\s+bindchange="onCustomerDeliveryDateChange"\s*>/
)
assert.match(
js,
/import timeUtil from '~\/utils\/timeFormat\/time-utils\.js'/
)
assert.match(js, /actualDeliveryDateMax:\s*timeUtil\.getTodayDateStr\(\)/)
})
it('IT-WO-DAILY-UI-012: visible delivery date shows required state and blocks an empty submit', () => {
const js = read('../createOrder.js')
const validation = read('../services/orderValidation.helpers.js')
const wxml = read('../createOrder.wxml')
assert.match(js, /validateBoutiqueRequiredFields/)
assert.match(validation, /isBoutiqueActualDeliveryDateMissing/)
assert.match(
validation,
/isBoutiqueActualDeliveryDateMissing\(\s*input\.showActualDeliveryDate,\s*customer\.actualDeliveryDate\s*\)/
)
assert.match(js, /actualDeliveryDate:\s*'实际交付日期不能为空'/)
assert.match(validation, /errorKey:\s*["']actualDeliveryDate["']/)
assert.match(
wxml,
/<gl-cell[\s\S]*?class="actualDeliveryDate"[\s\S]*?label="实际交付日期"[\s\S]*?required[\s\S]*?requiredAfter[\s\S]*?\/>/
)
})
it('IT-WO-DAILY-UI-002: removed dormant count request cannot return to the create page', () => {
const js = read('../createOrder.js')
assert.doesNotMatch(js, /waitinputorder\(/)
})
it('IT-WO-DAILY-UI-003: confirm and detail show tags and delivery date', () => {
const confirm = read('../../confirmOrder/confirmOrder.wxml')
const detail = read('../../orderDetail/orderDetail.wxml')
;[confirm, detail].forEach(source => {
assert.match(source, /日报标签/)
assert.match(source, /实际交付日期/)
assert.match(source, /customerTagLabels/)
})
})
it('IT-WO-DAILY-UI-004: create and submit retain scene and merchant-brand context', () => {
const page = read('../createOrder.js')
const submitStrategy = read('../submitStrategy.js')
assert.match(page, /customerDailyFieldMerchantBrands/)
assert.match(
page,
/baseSceneName:[\s\S]*baseSceneCode:[\s\S]*merchantBrands:/
)
assert.match(
submitStrategy,
/merchantBrands:\s*data\.customerDailyFieldMerchantBrands/
)
})
it('IT-WO-DAILY-UI-005: list conditionally renders each response display value', () => {
const listWxml = read('../../tabWorkOrderRelevance/index.wxml')
assert.match(listWxml, /li\.customerDailyDisplay\.showCustomerTags/)
assert.match(listWxml, /li\.customerDailyDisplay\.customerTagsText/)
assert.match(listWxml, /li\.customerDailyDisplay\.showActualDeliveryDate/)
assert.match(listWxml, /li\.customerDailyDisplay\.actualDeliveryDate/)
})
it('IT-WO-DAILY-UI-007: detail conditionally renders each response display value', () => {
const detailWxml = read('../../orderDetail/orderDetail.wxml')
assert.match(detailWxml, /orderInfo\.showCustomerTags/)
assert.match(detailWxml, /customerTagLabels/)
assert.match(detailWxml, /orderInfo\.showActualDeliveryDate/)
assert.match(detailWxml, /orderInfo\.actualDeliveryDateDisplay/)
})
it('IT-WO-DAILY-UI-008: confirm conditionally renders each response display value', () => {
const confirmWxml = read('../../confirmOrder/confirmOrder.wxml')
assert.match(confirmWxml, /orderInfo\.showCustomerTags/)
assert.match(confirmWxml, /customerTagLabels/)
assert.match(confirmWxml, /orderInfo\.showActualDeliveryDate/)
assert.match(confirmWxml, /orderInfo\.actualDeliveryDateDisplay/)
})
it('IT-WO-DAILY-UI-009: construction detail renders returned daily fields independently', () => {
const detailJs = read(
'../../constructionOrderDetail/constructionOrderDetail.js'
)
const detailWxml = read(
'../../constructionOrderDetail/constructionOrderDetail.wxml'
)
const detailSass = read(
'../../constructionOrderDetail/constructionOrderDetail.sass'
)
assert.match(detailJs, /buildBoutiqueCustomerDailyDisplay/)
assert.match(
detailJs,
/buildBoutiqueCustomerDailyDisplay\(\s*data\.customer\s*\)/
)
assert.match(detailJs, /data\.showCustomerTags/)
assert.match(detailJs, /data\.showActualDeliveryDate/)
assert.match(detailJs, /customerTagLabels:\s*data\.customerTagLabels/)
assert.match(detailWxml, /orderInfo\.showCustomerTags/)
assert.match(detailWxml, /customerTagLabels/)
assert.match(detailWxml, /orderInfo\.showActualDeliveryDate/)
assert.match(detailWxml, /orderInfo\.actualDeliveryDateDisplay/)
assert.match(
detailSass,
/\.daily-tag-list\s*\{[\s\S]*?gap:\s*var\(--fontSize12\);[\s\S]*?\}/
)
assert.match(
detailSass,
/\.daily-tag\s*\{[\s\S]*?padding:\s*var\(--fontSize6\)\s+var\(--fontSize14\);[\s\S]*?background:\s*#F2F6FF;[\s\S]*?border:\s*var\(--fontSize1\)\s+solid\s+#9BBCFF;[\s\S]*?\}/
)
})
it('IT-WO-DAILY-UI-010: boutique read-only pages resolve the phone from the full response', () => {
const orderDetail = read('../../orderDetail/orderDetail.js')
const constructionDetail = read(
'../../constructionOrderDetail/constructionOrderDetail.js'
)
const confirmOrder = read('../../confirmOrder/confirmOrder.js')
;[orderDetail, constructionDetail, confirmOrder].forEach(source => {
assert.match(source, /resolveBoutiqueDetailCustomerPhone\(data\)/)
})
})
it('IT-WO-DAILY-UI-006: create popup has no clear action', () => {
const wxml = read('../createOrder.wxml')
assert.doesNotMatch(wxml, /bindtap="onClearCustomerTags">清空/)
assert.match(wxml, /onCancelCustomerTags/)
assert.match(wxml, /onConfirmCustomerTags/)
})
it('IT-WO-DAILY-UI-013: create echo uses the tested two-phase coordinator and request guard', () => {
const page = read('../createOrder.js')
const hydration = read('../services/orderHydration.helpers.js')
assert.match(page, /buildBoutiqueOrderHydration/)
assert.match(hydration, /coordinateBoutiqueCustomerDailyFieldsEcho/)
assert.match(page, /coordinateBoutiqueCustomerDailyFieldsEcho/)
assert.match(
hydration,
/orderObj\.customer\s*=\s*coordinateBoutiqueCustomerDailyFieldsEcho\(\{[\s\S]*?phase:\s*["']pending["'][\s\S]*?customer:\s*orderObj\.customer[\s\S]*?\}\)/
)
assert.match(
page,
/coordinateBoutiqueCustomerDailyFieldsEcho\(\{[\s\S]*?phase:\s*'resolved'[\s\S]*?requestMerchantId[\s\S]*?currentMerchantId[\s\S]*?requestId[\s\S]*?currentRequestId[\s\S]*?\}\)/
)
assert.match(
page,
/applyBoutiqueCustomerDailyFields\([\s\S]*?this\._boutiqueCustomerDailyFieldsEchoPending[\s\S]*?coordinateBoutiqueCustomerDailyFieldsEcho\(\{[\s\S]*?phase:\s*'pending'[\s\S]*?return/
)
assert.ok(
(page.match(/phase:\s*'resolved'/g) || []).length >= 2,
'brand setData callback must re-check the resolved request before applying customer data'
)
})
it('IT-WO-DAILY-UI-014: boutique main list builds and conditionally renders daily fields', () => {
const mainListJs = read(
'../../../../pages/tabWorkOrder/pages/index/index.js'
)
const mainListWxml = read(
'../../../../pages/tabWorkOrder/pages/index/index.wxml'
)
assert.match(mainListJs, /buildBoutiqueCustomerDailyListDisplay/)
assert.match(
mainListJs,
/from '~\/utils\/boutiqueCustomerDailyDisplay\.helpers\.js'/
)
assert.doesNotMatch(mainListJs, /from '~\/tabWorkOrder\//)
assert.match(
mainListJs,
/e\.customerDailyDisplay\s*=\s*buildBoutiqueCustomerDailyListDisplay\(e\)/
)
assert.match(mainListWxml, /li\.customerDailyDisplay\.showCustomerTags/)
assert.match(mainListWxml, /li\.customerDailyDisplay\.customerTagsText/)
assert.match(
mainListWxml,
/li\.customerDailyDisplay\.showActualDeliveryDate/
)
assert.match(mainListWxml, /li\.customerDailyDisplay\.actualDeliveryDate/)
const orderListStart = mainListWxml.indexOf('<view class="order-list">')
const orderPayTypeStart = mainListWxml.indexOf(
'<view class="order-payType"'
)
const dailyTagStart = mainListWxml.indexOf(
'li.customerDailyDisplay.showCustomerTags'
)
const deliveryDateStart = mainListWxml.indexOf(
'li.customerDailyDisplay.showActualDeliveryDate'
)
assert.ok(
orderListStart < dailyTagStart && dailyTagStart < orderPayTypeStart
)
assert.ok(
orderListStart < deliveryDateStart &&
deliveryDateStart < orderPayTypeStart
)
})
it('IT-WO-DAILY-UI-015: customer source picker remounts with the current source index', () => {
const wxml = read('../createOrder.wxml')
const sourcePopup = wxml.match(
/<van-popup show="\{\{ showSource \}\}"[\s\S]*?<\/van-popup>/
)?.[0]
assert.ok(sourcePopup, 'customer source popup must exist')
assert.match(sourcePopup, /<van-picker[\s\S]*?wx:if="\{\{ showSource \}\}"/)
assert.match(
sourcePopup,
/default-index="\{\{ customerSourcePickerIndex \}\}"/
)
})
})