style(home): 预约卡片补充医院并允许长内容换行
首行集中日期、就诊人、服务与状态,医院单独成行;服务、医院与姓名超长时 换行展示而不是截断,详情箭头独立包裹。同步更新首页 UI 测试断言与缺省文案。
This commit is contained in:
+58
-5
@@ -5,16 +5,48 @@ const path = require('node:path')
|
||||
const vm = require('node:vm')
|
||||
const root = path.resolve(__dirname, '..')
|
||||
|
||||
test('当前预约使用紧凑三行摘要,时间、服务及状态共用首行', () => {
|
||||
test('当前预约使用两行摘要,日期、姓名、服务及状态共用首行,不显示时间', () => {
|
||||
const wxml = fs.readFileSync(path.join(root, 'pages/home/index.wxml'), 'utf8')
|
||||
assert.match(wxml, /pending-heading">当前预约/)
|
||||
assert.doesNotMatch(wxml, /pending-service-row/)
|
||||
const summary = /<view class="pending-summary">([\s\S]*?)<\/view>/.exec(wxml)[1]
|
||||
for (const field of ['whenText', 'timeText', 'serviceName', 'statusText']) {
|
||||
const match = /<view class="pending-summary">([\s\S]*?)<\/view>/.exec(wxml)
|
||||
assert.ok(match, '预约卡片应包含首行摘要')
|
||||
const summary = match[1]
|
||||
for (const field of ['whenText', 'patientName', 'serviceName', 'statusText']) {
|
||||
assert.ok(summary.includes(`item.${field}`))
|
||||
}
|
||||
assert.match(wxml, /pending-hospital">{{item.hospitalName}}/)
|
||||
assert.match(wxml, /pending-patient">就诊人:{{item.patientName}}/)
|
||||
assert.match(summary, /pending-when">{{item.whenText}}/)
|
||||
assert.match(summary, /pending-patient">{{item.patientName}}/)
|
||||
assert.ok(summary.indexOf('item.whenText') < summary.indexOf('item.patientName'))
|
||||
assert.ok(summary.indexOf('item.patientName') < summary.indexOf('item.serviceName'))
|
||||
assert.doesNotMatch(wxml, /item\.timeText/)
|
||||
assert.equal((wxml.match(/class="pending-patient"/g) || []).length, 1)
|
||||
const afterSummary = wxml.slice(wxml.indexOf('</view>', wxml.indexOf('class="pending-summary"')))
|
||||
assert.doesNotMatch(afterSummary, /class="pending-patient"/)
|
||||
})
|
||||
|
||||
test('预约卡片长内容可换行,保留详情入口和完整无障碍摘要', () => {
|
||||
const wxml = fs.readFileSync(path.join(root, 'pages/home/index.wxml'), 'utf8')
|
||||
const wxss = fs.readFileSync(path.join(root, 'pages/home/index.wxss'), 'utf8')
|
||||
const rule = (name) => {
|
||||
const match = new RegExp(`\\.${name}\\s*\\{([^}]+)\\}`).exec(wxss)
|
||||
assert.ok(match, `缺少 ${name} 样式`)
|
||||
return match[1]
|
||||
}
|
||||
assert.match(rule('pending-summary'), /flex-wrap:\s*wrap/)
|
||||
for (const name of ['pending-service', 'pending-hospital', 'pending-patient']) {
|
||||
assert.match(rule(name), /word-break:\s*break-all/)
|
||||
assert.doesNotMatch(rule(name), /ellipsis|nowrap|overflow:\s*hidden/)
|
||||
}
|
||||
assert.match(rule('pending-content'), /min-width:\s*0/)
|
||||
assert.match(rule('pending-arrow'), /flex-shrink:\s*0/)
|
||||
const card = /<view class="pending-card"[^>]+>/.exec(wxml)[0]
|
||||
assert.match(card, /data-id="{{item.id}}" bindtap="goToRecordDetail"/)
|
||||
const label = /aria-label="([^"]+)"/.exec(card)[1]
|
||||
for (const field of ['whenText', 'serviceName', 'statusText', 'hospitalName', 'patientName']) {
|
||||
assert.ok(label.includes(`item.${field}`))
|
||||
}
|
||||
})
|
||||
|
||||
function createHome(wx = {}) {
|
||||
@@ -56,7 +88,7 @@ test('导航信息不可用时保留默认布局,视图就绪恢复深色文
|
||||
assert.equal(restored(), 1)
|
||||
})
|
||||
|
||||
test('预约预览显示具体时间、状态和完整医院名,缺值使用可读提示', () => {
|
||||
test('预约预览保留时间数据、状态和完整医院名,缺值使用可读提示', () => {
|
||||
const { page } = createHome()
|
||||
const result = page.formatPendingRecord({
|
||||
_id: '1', status: 'pending',
|
||||
@@ -69,9 +101,30 @@ test('预约预览显示具体时间、状态和完整医院名,缺值使用
|
||||
assert.equal(result.hospitalName, '中国人民解放军总医院第九医学中心')
|
||||
const empty = page.formatPendingRecord({})
|
||||
assert.equal(empty.timeText, '时间待定')
|
||||
assert.equal(empty.whenText, '日期待定')
|
||||
assert.equal(empty.hospitalName, '医院待定')
|
||||
assert.equal(empty.serviceName, '陪诊服务')
|
||||
assert.equal(empty.patientName, '待补充')
|
||||
})
|
||||
|
||||
test('预约预览保留完整长文本,取消申请状态优先展示', () => {
|
||||
const { page } = createHome()
|
||||
const item = {
|
||||
_id: 'long-record',
|
||||
status: 'confirmed',
|
||||
cancelStatus: 'requested',
|
||||
hospital: { name: '中国人民解放军总医院第九医学中心门诊部' },
|
||||
patient: { name: '阿依古丽·阿卜杜拉' },
|
||||
escort: { serviceName: '全天陪诊与出入院手续代办服务' }
|
||||
}
|
||||
const result = page.formatPendingRecord(item)
|
||||
assert.equal(result.hospitalName, item.hospital.name)
|
||||
assert.equal(result.patientName, item.patient.name)
|
||||
assert.equal(result.serviceName, item.escort.serviceName)
|
||||
assert.equal(result.statusText, '待取消')
|
||||
assert.equal(result.statusTone, 'doing')
|
||||
})
|
||||
|
||||
test('预约预览按日期时间排序、最多三条,不修改原数组', () => {
|
||||
const { page } = createHome()
|
||||
const records = ['15:00', '08:00', '13:00', '10:00'].map((startTime, index) => ({
|
||||
|
||||
Reference in New Issue
Block a user