subpackage-split.live.test.mjs
5.74 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
import assert from 'node:assert/strict'
import test from 'node:test'
import automator from 'miniprogram-automator'
import { releaseMiniProgram } from '../../order-lifecycle/ui/uiLauncher.mjs'
import { createSplitEvidenceRecorder } from './evidence.mjs'
import { loadSplitUiConfig, requireSplitUiConfig } from './live-config.mjs'
import {
getSplitUiRoutes,
goByProjectRouter,
loginAndSelectSplitContext,
openSplitMiniProgram
} from './page-driver.mjs'
const liveEnabled = loadSplitUiConfig().enabled
const readDataAfterSettle = async (page, milliseconds = 800) => {
await page.waitFor(milliseconds)
return page.data()
}
test(
'IT-SPLIT-UI-001/010/011/012/020/021/022/030: pre/post split read-only smoke',
{ skip: !liveEnabled, timeout: 300000 },
async () => {
const config = requireSplitUiConfig()
const routes = getSplitUiRoutes(config.phase)
let miniProgram
let recorder
let status = '阻塞'
let failure = ''
try {
miniProgram = await openSplitMiniProgram(automator, config)
recorder = await createSplitEvidenceRecorder({
outputDir: config.evidenceDir,
miniProgram
})
const context = await loginAndSelectSplitContext(miniProgram, config)
assert.equal(String(context.storeName), config.storeName)
assert.equal(Number(context.sceneType), 1)
recorder.add('IT-SPLIT-UI-001', { context })
const startPage = await goByProjectRouter(
miniProgram,
routes.aiStartAlias,
{},
routes.aiStartPath
)
assert.equal(startPage.path, routes.aiStartPath)
recorder.add('IT-SPLIT-UI-010', {
alias: routes.aiStartAlias,
path: startPage.path
})
await recorder.screenshot('ai-start')
await miniProgram.navigateBack()
const listRoute =
`${routes.aiExerciseListAlias}?staffid=${encodeURIComponent(config.aiTaskId)}` +
'&tryCount=1&roleType=7&promptOnOff=true'
const listPage = await goByProjectRouter(
miniProgram,
listRoute,
{},
routes.aiExerciseListPath
)
const listData = await readDataAfterSettle(listPage)
assert.equal(String(listData.taskStaffId), config.aiTaskId)
assert.equal(String(listData.tryCount), '1')
assert.equal(String(listData.roleType), '7')
assert.equal(listData.promptOnOff, true)
recorder.add('IT-SPLIT-UI-011', {
path: listPage.path,
taskStaffId: listData.taskStaffId,
tryCount: listData.tryCount,
roleType: listData.roleType,
promptOnOff: listData.promptOnOff
})
await miniProgram.navigateBack()
const inspectionPage = await goByProjectRouter(
miniProgram,
routes.aiInspectionDetailAlias,
{
id: config.aiTaskId,
estimatedResult: '未知',
customerName: '自动化脱敏客户'
},
routes.aiInspectionDetailPath
)
assert.equal(
String((await inspectionPage.data('detailInfo'))?.id),
config.aiTaskId
)
await miniProgram.navigateBack()
const receptionPage = await goByProjectRouter(
miniProgram,
routes.aiInspectionReceptionAlias,
{ title: '自动化质检项', marker: 'reception-back' },
routes.aiInspectionReceptionPath
)
assert.equal(
(await receptionPage.data('detailInfo'))?.marker,
'reception-back'
)
await miniProgram.navigateBack()
recorder.add('IT-SPLIT-UI-012', {
detailPath: inspectionPage.path,
receptionPath: receptionPage.path,
backPath: (await miniProgram.currentPage())?.path
})
for (const [alias, expectedPath] of [
[routes.staffDailyAlias, routes.staffDailyPath],
[routes.upgradeStaffDailyAlias, routes.upgradeStaffDailyPath]
]) {
const page = await goByProjectRouter(
miniProgram,
`${alias}?reportDate=${encodeURIComponent(config.reportDate)}`,
{},
expectedPath
)
assert.equal(page.path, expectedPath)
await miniProgram.navigateBack()
}
recorder.add('IT-SPLIT-UI-020', {
reportDate: config.reportDate,
paths: [routes.staffDailyPath, routes.upgradeStaffDailyPath]
})
for (const [reportTypeAttr, reportType] of [
['daily', 1],
['weekly', 2],
['monthly', 3]
]) {
const page = await goByProjectRouter(
miniProgram,
routes.supervisorDailyAlias,
{
params: {
reportTypeAttr,
reportType,
code: `split-smoke-${reportTypeAttr}`
}
},
routes.supervisorDailyPath
)
const routeParams = await page.data('routeParams')
assert.equal(routeParams.reportTypeAttr, reportTypeAttr)
assert.equal(Number(routeParams.reportType), reportType)
if (reportTypeAttr === 'daily') {
await page.setData({
tmlpObj: { smoke: [] },
tabActive: 'smoke',
tabChange: true
})
assert.ok(await page.$('gl-cust-form'))
recorder.add('IT-SPLIT-UI-022', { component: 'gl-cust-form' })
}
await miniProgram.navigateBack()
}
recorder.add('IT-SPLIT-UI-021', {
path: routes.supervisorDailyPath,
reportTypes: ['daily', 'weekly', 'monthly']
})
const h5Page = await miniProgram.reLaunch(
`/${routes.upgradeStaffDailyPath}?reportDate=${encodeURIComponent(config.reportDate)}`
)
assert.equal(h5Page.path, routes.upgradeStaffDailyPath)
recorder.add('IT-SPLIT-UI-030', {
path: h5Page.path,
reportDate: config.reportDate
})
await recorder.screenshot('report-deep-link')
recorder.add('write-guard', {
allowAiWrite: config.allowAiWrite,
allowReportWrite: config.allowReportWrite,
performedWrites: false
})
status = '通过'
} catch (error) {
failure = error instanceof Error ? error.message : 'Unknown split UI error'
if (recorder) recorder.add('failure', { message: failure })
throw error
} finally {
if (recorder) {
await recorder.write({
caseId: 'IT-SPLIT-UI-001-030',
phase: config.phase,
status,
error: failure
})
}
if (miniProgram) await releaseMiniProgram(miniProgram, config)
}
}
)