simpleQuotationPage.contract.test.mjs
3.5 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
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import { describe, it } from 'node:test'
const pageUrl = new URL(
'../pages/carQuotation/createOrderCarQuotationSimple/createOrderCarQuotationSimple.js',
import.meta.url
)
const firstStepUrl = new URL(
'../pages/carQuotation/components/FirstStep/FirstStep.js',
import.meta.url
)
describe('simple quotation page contract', () => {
it('IT-EQ-SIMPLE-PAGE-001: keeps business transformations in local services without cross-package imports', async () => {
const source = await readFile(pageUrl, 'utf8')
assert.match(source, /simpleQuotationCatalog\.helpers\.js/)
assert.match(source, /simpleQuotationRoute\.helpers\.js/)
assert.match(source, /simpleQuotationValidation\.helpers\.js/)
assert.match(source, /simpleQuotationFormConfig\.helpers\.js/)
assert.doesNotMatch(source, /tabWorkOrder|packageEquityAI/)
})
it('IT-EQ-SIMPLE-PAGE-002: removes debug output and the disabled wait-order polling path', async () => {
const source = await readFile(pageUrl, 'utf8')
assert.doesNotMatch(source, /console\.log\s*\(/)
assert.doesNotMatch(source, /\bwaitinputorder\b/)
assert.doesNotMatch(source, /\bgetWaitOrder\b/)
assert.doesNotMatch(source, /\bsetTime\s*\(/)
assert.doesNotMatch(source, /\bupdateOrderStatus\b/)
})
it('IT-EQ-SIMPLE-PAGE-003: delegates checkout, total and car-selection lifecycle to local services', async () => {
const source = await readFile(pageUrl, 'utf8')
assert.match(source, /submitSimpleQuotationCheckout\s*\(/)
assert.match(source, /calculateSimpleQuotationTotal\s*\(/)
assert.match(source, /bindSimpleQuotationCarSelection\s*\(/)
assert.match(source, /onUnload\s*\(\)[\s\S]*?_disposeCarSelection/)
assert.doesNotMatch(source, /total\s*\/\s*100/)
assert.doesNotMatch(source, /wx\.\$eventbus\.on\s*\(\s*['"]set_car_info/)
assert.doesNotMatch(source, /\binit\s*\(\)\s*\{\s*\}/)
assert.doesNotMatch(source, /onShareAppMessage\s*\(\)\s*\{\s*\}/)
})
it('IT-EQ-SIMPLE-PAGE-004: configures FirstStep through its public method', async () => {
const [pageSource, firstStepSource] = await Promise.all([
readFile(pageUrl, 'utf8'),
readFile(firstStepUrl, 'utf8')
])
assert.match(pageSource, /firstCom\.applyFormConfig\s*\(formConfig\)/)
assert.doesNotMatch(pageSource, /firstCom\.setData\s*\(/)
assert.match(firstStepSource, /async\s+applyFormConfig\s*\(config\s*=\s*\{\}\)/)
})
it('IT-EQ-SIMPLE-PAGE-005: keeps new services free of page, route and cross-package effects', async () => {
for (const serviceName of [
'simpleQuotationCheckout.workflow.js',
'simpleQuotationTotal.helpers.js',
'simpleQuotationLifecycle.js'
]) {
const source = await readFile(
new URL(`../pages/carQuotation/services/${serviceName}`, import.meta.url),
'utf8'
)
assert.doesNotMatch(source, /\bwx\./, serviceName)
assert.doesNotMatch(source, /\bsetData\s*\(/, serviceName)
assert.doesNotMatch(source, /\$router/, serviceName)
assert.doesNotMatch(source, /tabWorkOrder|packageEquityAI/, serviceName)
}
})
it('IT-EQ-SIMPLE-PAGE-006: closes the payment-document popup before recording success feedback and delayed navigation', async () => {
const source = await readFile(pageUrl, 'utf8')
assert.match(
source,
/outcome\.status === ["']list["'] && context\.isRecording[\s\S]*?this\.setData\(outcome\.patch\)[\s\S]*?wx\.showToast[\s\S]*?setTimeout/
)
})
})