65 lines
2.8 KiB
JavaScript
65 lines
2.8 KiB
JavaScript
const assert = require('assert')
|
|
|
|
const requests = []
|
|
const storage = {}
|
|
global.wx = {
|
|
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
|
getDeviceInfo: () => ({ platform: 'devtools' }),
|
|
getStorageSync: key => storage[key] || '',
|
|
setStorageSync: (key, value) => { storage[key] = value },
|
|
removeStorageSync: key => { delete storage[key] },
|
|
request: options => {
|
|
requests.push(options)
|
|
options.success({ statusCode: 200, data: { code: 200, data: {} } })
|
|
}
|
|
}
|
|
global.getApp = () => ({ clearSession: () => {}, goLogin: () => {} })
|
|
|
|
const employeesApi = require('./api/employees')
|
|
const authApi = require('./api/auth')
|
|
const planningApi = require('./api/planning')
|
|
const request = require('./utils/request')
|
|
|
|
async function run() {
|
|
await planningApi.calendar({ startDate: '2026-10-27' })
|
|
await authApi.login({ account: 'manager', password: 'secret' })
|
|
await authApi.getLoginShops('manager')
|
|
await authApi.switchShop(12)
|
|
await authApi.logout()
|
|
await employeesApi.reviewSummary()
|
|
await employeesApi.reviewApplications()
|
|
await employeesApi.unboundArtists(12)
|
|
await employeesApi.preAssociateApplication(14, 22)
|
|
await employeesApi.approveApplication(12, {
|
|
targetArtistUserId: 22,
|
|
useApplicantNickname: true,
|
|
useApplicantAvatar: false
|
|
})
|
|
await employeesApi.rejectApplication(12, '资料不完整')
|
|
|
|
assert.deepStrictEqual(requests.map(item => [item.method || 'GET', item.url, item.data]), [
|
|
['GET', 'http://127.0.0.1:80/api/manager/planning/calendar?startDate=2026-10-27', undefined],
|
|
['POST', 'http://127.0.0.1:80/api/user/login', { account: 'manager', password: 'secret' }],
|
|
['GET', 'http://127.0.0.1:80/api/user/check/login-shops/account/manager', undefined],
|
|
['POST', 'http://127.0.0.1:80/api/user/switch-shop', { shopId: 12 }],
|
|
['POST', 'http://127.0.0.1:80/api/user/logout', undefined],
|
|
['GET', 'http://127.0.0.1:80/api/user/workbench/registration/summary', undefined],
|
|
['GET', 'http://127.0.0.1:80/api/user/workbench/registration/list', undefined],
|
|
['GET', 'http://127.0.0.1:80/api/user/workbench/registration/12/unbound-artists', undefined],
|
|
['POST', 'http://127.0.0.1:80/api/user/workbench/registration/14/pre-associate', { targetArtistUserId: 22 }],
|
|
['POST', 'http://127.0.0.1:80/api/user/workbench/registration/12/approve', {
|
|
targetArtistUserId: 22,
|
|
useApplicantNickname: true,
|
|
useApplicantAvatar: false
|
|
}],
|
|
['POST', 'http://127.0.0.1:80/api/user/workbench/registration/12/reject', { reason: '资料不完整' }]
|
|
])
|
|
assert(requests.every(item => !item.url.includes('/api/admin/')))
|
|
assert.strictEqual(request.toBackendRequestPath('http://127.0.0.1:80/api/manager/planning/calendar'), '/manager/planning/calendar')
|
|
}
|
|
|
|
run().catch(error => {
|
|
console.error(error)
|
|
process.exitCode = 1
|
|
})
|