Files
JayuCloud/JC-Salon-WeChat/pages/appointment-detail/index.test.js
T
xiaowang 88589e2575
自动发布开发环境 Nacos 配置 / publish (push) Successful in 23s
feat(salon): 支持散客预约拨号并发布协议新版本强制重新同意
2026-11-04 23:38:42 +08:00

102 lines
3.3 KiB
JavaScript

const assert = require('assert')
const fs = require('fs')
const path = require('path')
global.wx = {
showToast: () => {},
showModal: options => options.success({ confirm: false }),
navigateTo: () => {},
navigateBack: () => {}
}
let definition
global.Page = value => { definition = value }
require('./index')
function createPage() {
return {
...definition,
data: { ...definition.data },
setData(values) { Object.assign(this.data, values) }
}
}
const page = createPage()
page.applyAppointment({
orderId: 1,
orderNo: 'SALON-001',
customerName: '到店客户',
customerPhone: null,
productTitle: null,
artistName: null,
artistId: null,
assignmentStatus: 'UNASSIGNED',
startTime: null,
endTime: null,
durationMinutes: null,
amount: null,
remark: null,
status: 0,
statusText: '待确认',
canEdit: true,
canCancel: true
})
assert.strictEqual(page.data.appointment.customerPhoneText, '未留手机号')
assert.strictEqual(page.data.appointment.productTitleText, '未记录')
assert.strictEqual(page.data.appointment.artistNameText, '待分配')
assert.strictEqual(page.data.appointment.amountText, '未记录')
assert.strictEqual(page.data.appointment.remarkText, '暂无备注')
assert.strictEqual(page.data.appointment.orderNoText, 'SALON-001')
assert.strictEqual(page.data.showTransfer, true)
assert.strictEqual(page.data.showConfirm, false)
assert.strictEqual(page.data.showComplete, false)
assert.strictEqual(page.data.showCancel, true)
assert.strictEqual([
page.data.appointment.customerNameText,
page.data.appointment.customerPhoneText,
page.data.appointment.orderNoText,
page.data.appointment.productTitleText,
page.data.appointment.artistNameText,
page.data.appointment.durationText,
page.data.appointment.amountText,
page.data.appointment.remarkText
].some(value => String(value).includes('null')), false)
page.applyAppointment({
artistId: 9,
assignmentStatus: 'ASSIGNED',
status: 3,
statusText: '已取消',
canEdit: false,
canCancel: false,
cancelReason: '客户临时调整时间'
})
assert.strictEqual(page.data.appointment.cancelReasonText, '客户临时调整时间')
assert.strictEqual(page.data.showTransfer, false)
assert.strictEqual(page.data.showConfirm, false)
assert.strictEqual(page.data.showComplete, false)
assert.strictEqual(page.data.showCancel, false)
page.applyAppointment({
artistId: 9,
assignmentStatus: 'ASSIGNED',
status: 4,
statusText: '服务中',
historicalBackfill: true,
canEdit: false,
canCancel: true
})
assert.strictEqual(page.data.showTransfer, false)
assert.strictEqual(page.data.showComplete, true)
assert.strictEqual(page.data.showCancel, true)
const markup = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
const styles = fs.readFileSync(path.join(__dirname, 'index.wxss'), 'utf8')
;['订单编号', '服务项目', '美甲师', '时长', '成交金额', '取消原因', 'remarkText', 'customerPhoneText'].forEach(text => assert(markup.includes(text)))
assert.match(markup, /class="primary-btn transfer-action"/)
assert.match(markup, /class="danger-btn"/)
assert.match(markup, /appointment\.customerPhoneAvailable && appointment\.orderId/)
assert.strictEqual(markup.includes('appointment.customerId && appointment.orderId'), false)
assert.match(styles, /\.transfer-action\s*\{[^}]*box-shadow/)
assert.match(styles, /\.call-btn\s*\{/)