storeSwitch.test.mjs
1.19 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
/**
* 精品切 4S 店 — 菜单/缓存补全单测
*
* 运行:npm run test:tabIndex
* 用例前缀:IT-MENU-STORE-SWITCH-*
*/
import { describe, it, beforeEach, afterEach } from 'node:test'
import assert from 'node:assert/strict'
import { invalidateSharedMenuApiCaches } from '../../utils/invalidateMenuApiCaches.js'
import {
__setApiClientForTest,
clearDailyReportNewVersionCache,
fetchDailyReportNewVersionMenuVisible
} from '../../utils/dailyReportNewVersionGate.js'
describe('tabIndexStoreSwitch', () => {
beforeEach(() => {
clearDailyReportNewVersionCache()
})
afterEach(() => {
clearDailyReportNewVersionCache()
__setApiClientForTest(null)
})
it('IT-MENU-STORE-SWITCH-001: invalidateSharedMenuApiCaches clears daily report isNeed cache', async () => {
let isNeedCalls = 0
__setApiClientForTest({
dailyReportNewVersionIsNeed: async () => {
isNeedCalls++
return { code: 0, data: true }
}
})
await fetchDailyReportNewVersionMenuVisible('store-a')
await fetchDailyReportNewVersionMenuVisible('store-a')
assert.equal(isNeedCalls, 1)
invalidateSharedMenuApiCaches()
await fetchDailyReportNewVersionMenuVisible('store-a')
assert.equal(isNeedCalls, 2)
})
})