功能:支持待分配预约与首次排班引导
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
const assert = require('assert')
|
||||
const planningApi = require('../../api/planning')
|
||||
|
||||
let redirectedTo = ''
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
getDeviceInfo: () => ({ platform: 'devtools' }),
|
||||
removeStorageSync: () => {},
|
||||
setStorageSync: () => {},
|
||||
showToast: () => {},
|
||||
showModal: ({ success }) => success({ confirm: true }),
|
||||
redirectTo: ({ url }) => { redirectedTo = url }
|
||||
}
|
||||
global.getApp = () => ({ globalData: {} })
|
||||
global.getCurrentPages = () => []
|
||||
|
||||
let definition
|
||||
global.Page = value => { definition = value }
|
||||
require('./index')
|
||||
|
||||
function createPage() {
|
||||
return {
|
||||
...definition,
|
||||
data: JSON.parse(JSON.stringify(definition.data)),
|
||||
setData(values) {
|
||||
Object.entries(values).forEach(([key, value]) => {
|
||||
const parts = key.split('.')
|
||||
let target = this.data
|
||||
for (let index = 0; index < parts.length - 1; index += 1) target = target[parts[index]]
|
||||
target[parts[parts.length - 1]] = value
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const page = createPage()
|
||||
Object.assign(page.data.form, {
|
||||
customerUserId: '31',
|
||||
customerName: '测试客户',
|
||||
phone: '13800138000',
|
||||
productId: '41',
|
||||
appointmentDate: '2026-10-13',
|
||||
appointmentTime: '14:00',
|
||||
durationMinutes: '60',
|
||||
artistId: ''
|
||||
})
|
||||
|
||||
await page.refreshAvailableTimes()
|
||||
assert.strictEqual(page.data.availableTimeGroups.length > 0, true)
|
||||
assert.strictEqual(page.data.timeSelectTip, '请选择预约时间,员工可稍后分配')
|
||||
const availability = await page.checkAvailability()
|
||||
assert.strictEqual(availability.ok, true)
|
||||
assert.strictEqual(page.data.conflictTip.includes('待分配'), true)
|
||||
|
||||
let submittedPayload
|
||||
planningApi.createAppointment = async payload => {
|
||||
submittedPayload = payload
|
||||
return { orderItemId: 61 }
|
||||
}
|
||||
await page.submit()
|
||||
|
||||
assert.strictEqual(submittedPayload.artistId, undefined)
|
||||
assert.strictEqual(submittedPayload.appointmentTime, '14:00')
|
||||
assert.strictEqual(redirectedTo, '/pages/appointment-detail/index?id=61')
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
console.error(error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
Reference in New Issue
Block a user