优化:规划日期快捷新增预约
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const assert = require('assert')
|
||||
const planningApi = require('../../api/planning')
|
||||
const dateUtil = require('../../utils/date')
|
||||
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
@@ -9,7 +10,8 @@ global.wx = {
|
||||
removeStorageSync: () => {},
|
||||
showToast: () => {},
|
||||
showModal: ({ success }) => success({ confirm: false }),
|
||||
switchTab: () => {}
|
||||
switchTab: () => {},
|
||||
navigateTo: () => {}
|
||||
}
|
||||
const appMock = { globalData: { userInfo: {} } }
|
||||
global.getApp = () => appMock
|
||||
@@ -41,6 +43,9 @@ function createPage(data = {}) {
|
||||
}
|
||||
|
||||
async function run() {
|
||||
assert.deepStrictEqual(definition.data.viewModes.map(item => item.value), ['month', 'week', 'day'])
|
||||
assert.strictEqual(definition.data.viewMode, 'month')
|
||||
|
||||
const page = createPage({ viewMode: 'week' })
|
||||
let monthBuilds = 0
|
||||
let weekBuilds = 0
|
||||
@@ -85,6 +90,36 @@ async function run() {
|
||||
assert.strictEqual(switched, true)
|
||||
assert.strictEqual(appMock.globalData.reviewNoticeShown, true)
|
||||
assert.strictEqual(appMock.globalData.openEmployeeReview, true)
|
||||
|
||||
const navigations = []
|
||||
const toasts = []
|
||||
global.wx.navigateTo = options => navigations.push(options.url)
|
||||
global.wx.showToast = options => toasts.push(options.title)
|
||||
|
||||
const quickCreatePage = createPage({ canCreateAppointment: true, selectedArtistId: '88' })
|
||||
const today = dateUtil.formatDate(new Date())
|
||||
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: today } } })
|
||||
assert.strictEqual(navigations.pop(), `/pages/appointment-form/index?date=${today}&artistId=88`)
|
||||
|
||||
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-12-31' } } })
|
||||
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2099-12-31&artistId=88')
|
||||
|
||||
quickCreatePage.data.selectedArtistId = ''
|
||||
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-11-30' } } })
|
||||
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2099-11-30')
|
||||
|
||||
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2000-01-01' } } })
|
||||
assert.strictEqual(navigations.length, 0)
|
||||
assert.strictEqual(toasts.pop(), '不能为历史日期新增预约')
|
||||
|
||||
const readonlyPage = createPage({ canCreateAppointment: false, selectedArtistId: '88' })
|
||||
readonlyPage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-12-31' } } })
|
||||
assert.strictEqual(navigations.length, 0)
|
||||
assert.strictEqual(toasts.pop(), '当前账号仅支持查看预约')
|
||||
|
||||
const fabPage = createPage({ canCreateAppointment: true, currentDateText: '2026-10-12', selectedArtistId: '99' })
|
||||
fabPage.createAppointment()
|
||||
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2026-10-12&artistId=99')
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user