uiSmokeConfig.test.mjs
3.1 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
import assert from 'node:assert/strict'
import test from 'node:test'
import {
loadUiSmokeConfig,
requireUiSmokeConfig
} from './uiSmokeConfig.mjs'
test('IT-OL-UI-001: UI smoke defaults contain only non-sensitive values', () => {
const config = loadUiSmokeConfig({})
assert.equal(config.enabled, false)
assert.equal(config.parkName, '流程测试园区门店')
assert.equal(config.storeName, '波波的单店门店')
assert.equal(config.sceneName, '精品升级')
assert.equal(config.wsEndpoint, 'ws://127.0.0.1:9420')
assert.equal(config.launchDevTools, false)
assert.equal(config.cliPath, '')
assert.equal(config.port, 9420)
assert.equal(config.mobile, '')
assert.equal(config.code, '')
})
test('IT-OL-UI-002: live UI smoke requires explicit switch and credentials', () => {
assert.throws(
() =>
requireUiSmokeConfig({
RUN_ORDER_UI_E2E: '1',
ORDER_E2E_MOBILE: '',
ORDER_E2E_CODE: ''
}),
/ORDER_E2E_MOBILE, ORDER_E2E_CODE/
)
})
test('IT-OL-UI-003: UI smoke accepts runtime-only credentials', () => {
const config = requireUiSmokeConfig({
RUN_ORDER_UI_E2E: '1',
ORDER_E2E_MOBILE: 'runtime-mobile',
ORDER_E2E_CODE: 'runtime-code',
ORDER_E2E_YQ_NAME: '流程测试园区门店',
ORDER_E2E_STORE_NAME: '波波的单店门店'
})
assert.equal(config.enabled, true)
assert.equal(config.parkName, '流程测试园区门店')
assert.equal(config.storeName, '波波的单店门店')
assert.equal(config.mobile, 'runtime-mobile')
assert.equal(config.code, 'runtime-code')
})
test('IT-OL-UI-004: UI smoke only connects to a loopback automator endpoint', () => {
assert.throws(
() =>
requireUiSmokeConfig({
RUN_ORDER_UI_E2E: '1',
ORDER_E2E_MOBILE: 'runtime-mobile',
ORDER_E2E_CODE: 'runtime-code',
ORDER_UI_WS_ENDPOINT: 'ws://192.168.1.10:9420'
}),
/loopback/
)
})
test('IT-OL-UI-008: launch mode requires an explicit DevTools CLI path', () => {
assert.throws(
() =>
requireUiSmokeConfig({
RUN_ORDER_UI_E2E: '1',
RUN_ORDER_UI_LAUNCH: '1',
ORDER_E2E_MOBILE: 'runtime-mobile',
ORDER_E2E_CODE: 'runtime-code'
}),
/ORDER_UI_CLI_PATH/
)
})
test('IT-OL-UI-009: launch mode uses runtime CLI, project and port values', () => {
const config = requireUiSmokeConfig({
RUN_ORDER_UI_E2E: '1',
RUN_ORDER_UI_LAUNCH: '1',
ORDER_E2E_MOBILE: 'runtime-mobile',
ORDER_E2E_CODE: 'runtime-code',
ORDER_UI_CLI_PATH: 'C:/tools/wechat/cli.bat',
ORDER_UI_PROJECT_PATH: 'C:/workspace/project',
ORDER_UI_PORT: '9527'
})
assert.equal(config.launchDevTools, true)
assert.equal(config.cliPath, 'C:/tools/wechat/cli.bat')
assert.equal(config.projectPath, 'C:/workspace/project')
assert.equal(config.port, 9527)
})
test('IT-OL-UI-012: UI smoke rejects a non-approved store context', () => {
assert.throws(
() =>
requireUiSmokeConfig({
RUN_ORDER_UI_E2E: '1',
ORDER_E2E_MOBILE: 'runtime-mobile',
ORDER_E2E_CODE: 'runtime-code',
ORDER_E2E_STORE_NAME: '其它门店'
}),
/approved fixed context/
)
})