menuTestHelpers.mjs
1.94 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
/**
* packageEquity Menu 单测公共 mock(对齐 tabIndex/tests/menuTestHelpers.mjs)
*/
export function setupWxMock(globalRef = globalThis) {
globalRef.wx = {
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'release' } }),
getDeviceInfo: () => ({ platform: 'devtools' }),
getWindowInfo: () => ({
windowWidth: 375,
windowHeight: 667,
statusBarHeight: 20,
pixelRatio: 2,
screenWidth: 375,
screenHeight: 667,
safeArea: { top: 20, bottom: 667, height: 647 },
}),
getAppBaseInfo: () => ({
SDKVersion: '3.0.0',
host: 'WeChat',
version: '8.0.0',
language: 'zh_CN',
}),
$hasPermission: {
isSuper: u => !!u?.isSuper,
isNotMentor: u => u?.loginRole !== 6,
canSelectMultiStore: u =>
!!u?.isSuper || [3, 5, 6, 8].includes(u?.loginRole),
canSelectMultiStoreForStaffDaily: u =>
!!u?.isSuper || [3, 5, 8].includes(u?.loginRole),
canViewMentorship: u => !!u?.isSuper || u?.loginRole === 6,
canViewRecruit: u => [3, 8].includes(u?.loginRole),
canViewViolation: u =>
!!u?.isSuper || [3, 6, 8].includes(u?.loginRole)
}
}
return globalRef.wx
}
/** 默认异步 deps,各用例可按需覆盖 */
export function createDefaultEquityAsyncDeps(overrides = {}) {
return {
commonApi: {
hasPerformanceConfig: async () => ({ data: false }),
getStaffTargetTaskApi: async () => ({ code: 0, data: [] }),
getYqStoreConfig: async () => ({ data: { customerExchangeFlag: 'N' } }),
getStaffMentorFlag: async () => ({ code: 0 }),
...overrides.commonApi
},
aiApi: {
extractCheck: async () => ({ data: false }),
...overrides.aiApi
},
carLifeApi: {
selectrecmerchantList: async () => ({ code: 0, data: [] }),
...overrides.carLifeApi
},
receptionRecordsApi: {
checkMerchantDirect: async () => ({ data: false }),
checkMissingReception: async () => ({ code: 0, data: [] }),
...overrides.receptionRecordsApi
},
getBusinessSchoolScene: async () => false,
...overrides
}
}