uiSmokeHelpers.test.mjs
1.16 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
import assert from 'node:assert/strict'
import test from 'node:test'
import {
findExactIndex,
waitForListData
} from './uiSmokeHelpers.mjs'
test('IT-OL-UI-005: exact context match ignores partial names', () => {
const items = [
{ merchantName: '流程测试园区门店-备选' },
{ merchantName: '流程测试园区门店' }
]
assert.equal(
findExactIndex(items, 'merchantName', '流程测试园区门店', 'park'),
1
)
})
test('IT-OL-UI-006: duplicate exact context is rejected', () => {
assert.throws(
() =>
findExactIndex(
[{ sceneName: '精品升级' }, { sceneName: '精品升级' }],
'sceneName',
'精品升级',
'scene'
),
/count=2/
)
})
test('IT-OL-UI-007: page list polling returns once data is available', async () => {
let reads = 0
const page = {
async data(field) {
assert.equal(field, 'sceneList')
reads += 1
return reads === 1 ? [] : [{ sceneName: '精品升级' }]
}
}
const result = await waitForListData(page, 'sceneList', {
timeoutMs: 100,
intervalMs: 1
})
assert.equal(reads, 2)
assert.equal(result[0].sceneName, '精品升级')
})