修复Salon注册预约客户流程

This commit is contained in:
2026-10-30 15:13:38 +08:00
parent 53b6fcaa11
commit 7b9a5e4d1c
20 changed files with 748 additions and 67 deletions
@@ -4,20 +4,18 @@ const path = require('path')
let pageDefinition
let currentProfile
let currentSettings
let savedSettings
let toastTitle
global.Page = definition => { pageDefinition = definition }
global.wx = { showToast: () => {} }
global.wx = { showToast: options => { toastTitle = options.title } }
const profileCache = require('../../utils/profile-cache')
profileCache.getProfile = async () => currentProfile
const shopApi = require('../../api/shop')
shopApi.appointmentSettings = async () => ({
shopName: '薄荷美甲',
businessHours: '09:30-21:30',
defaultAppointmentDurationMinutes: 75,
shopNameModerationStatus: 'PENDING',
pendingShopName: '薄荷指尖'
})
shopApi.appointmentSettings = async () => ({ ...currentSettings })
shopApi.saveAppointmentSettings = async settings => { savedSettings = settings }
require('./index')
async function loadProfile(profile) {
@@ -37,6 +35,13 @@ async function loadProfile(profile) {
}
async function run() {
currentSettings = {
shopName: '薄荷美甲',
businessHours: '09:30-21:30',
defaultAppointmentDurationMinutes: 75,
shopNameModerationStatus: 'PENDING',
pendingShopName: '薄荷指尖'
}
const empty = await loadProfile({
type: 2,
shopBusinessExpireTime: null,
@@ -64,17 +69,51 @@ async function run() {
assert.strictEqual(expired.businessExpiryStatusText, '已过期,暂不能新增预约')
assert.strictEqual(expired.form.startTime, '09:30')
assert.strictEqual(expired.form.endTime, '21:30')
assert.strictEqual(expired.businessHoursConfigured, true)
assert.strictEqual(expired.form.defaultDuration, 75)
assert.strictEqual(expired.nameModerationText, '名称审核中')
assert.strictEqual(expired.form.pendingShopName, '薄荷指尖')
const shopSettingsWxml = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
const accountSettingsWxml = fs.readFileSync(path.join(__dirname, '../account-settings/index.wxml'), 'utf8')
assert(shopSettingsWxml.includes('预约运营设置'))
assert(shopSettingsWxml.includes('营业时间'))
assert(shopSettingsWxml.includes('默认预约时长'))
assert(shopSettingsWxml.includes('catchtap="explainDefaultDuration"'))
assert(shopSettingsWxml.includes('wx:if="{{profile.type == 2}}" class="card business-expiry-card"'))
assert(!accountSettingsWxml.includes('business-expiry-card'))
assert(!shopSettingsWxml.includes('预约规则'))
assert(shopSettingsWxml.includes('提交名称审核'))
assert(shopSettingsWxml.includes('保存预约设置'))
assert(shopSettingsWxml.includes('设置开始时间'))
assert(shopSettingsWxml.includes('营业时间尚未设置'))
currentSettings = { shopName: '新门店', businessHours: null, defaultAppointmentDurationMinutes: 60 }
const unconfigured = await loadProfile({ type: 2 })
assert.strictEqual(unconfigured.form.startTime, '')
assert.strictEqual(unconfigured.form.endTime, '')
assert.strictEqual(unconfigured.businessHoursConfigured, false)
const savePage = {
data: { ...pageDefinition.data, businessHoursConfigured: false, form: { ...pageDefinition.data.form, startTime: '', endTime: '' } },
setData(values) {
Object.entries(values).forEach(([key, value]) => {
const parts = key.split('.')
if (parts.length === 1) this.data[key] = value
else this.data[parts[0]] = { ...this.data[parts[0]], [parts[1]]: value }
})
}
}
savedSettings = undefined
await pageDefinition.saveAppointmentSettings.call(savePage)
assert.strictEqual(savedSettings, undefined)
assert.strictEqual(toastTitle, '请设置完整有效的营业时间')
savePage.data.form.startTime = '09:00'
savePage.data.form.endTime = '21:30'
await pageDefinition.saveAppointmentSettings.call(savePage)
assert.deepStrictEqual(savedSettings, { businessHours: '09:00-21:30', defaultAppointmentDurationMinutes: 60 })
assert.strictEqual(savePage.data.businessHoursConfigured, true)
}
run().catch(error => {