@@ -333,12 +333,87 @@ test('installer requests are public, deduplicated across notices, cached, and re
|
||||
assert.equal(transport[1].withToken, false)
|
||||
})
|
||||
|
||||
test('the actual reception, diagnosis and both appointment list entries compile with the shared notice', () => {
|
||||
test('consultation entries retain the shared notice while the patient list compiles without it', () => {
|
||||
for (const name of ['views/patient/reception/index.vue', 'views/tcm/diagnosis/index.vue', 'views/tcm/appointment/list.vue', 'views/tcm/appointment/list_h5.vue']) {
|
||||
const { descriptor, errors } = parse(read(name), { filename: name })
|
||||
assert.deepEqual(errors, [])
|
||||
const script = compileScript(descriptor, { id: name })
|
||||
assert.equal(script.bindings.DoctorWebConsultationNotice, 'setup-const')
|
||||
assert.equal(script.bindings.DoctorWebConsultationNotice, name === 'views/tcm/diagnosis/index.vue' ? undefined : 'setup-const')
|
||||
assert.deepEqual(compileTemplate({ source: descriptor.template.content, filename: name, id: name, compilerOptions: { bindingMetadata: script.bindings } }).errors, [])
|
||||
}
|
||||
})
|
||||
|
||||
test('reception makes doctor cutoff visible and blocks calls while preserving administrator and assistant access', async () => {
|
||||
const { descriptor } = parse(read('views/patient/reception/index.vue'))
|
||||
const script = compileScript(descriptor, { id: 'reception-cutoff' })
|
||||
const template = compileTemplate({ source: descriptor.template.content, filename: 'reception.vue', id: 'reception-cutoff', compilerOptions: { bindingMetadata: script.bindings } })
|
||||
assert.deepEqual(template.errors, [])
|
||||
const render = moduleFrom(template.code).render
|
||||
const passthrough = { setup: (_, { slots }) => () => vue.h('div', slots.default?.()) }
|
||||
const lifecycle = { ...vue, onMounted() {}, onUnmounted() {}, defineAsyncComponent: () => passthrough }
|
||||
let clock = cutoff - 1
|
||||
const store = vue.reactive({ userInfo: { ...doctor, web_consultation_policy: schedule }, serverTimeOffsetMs: 0 })
|
||||
const warnings = [], requests = [], opened = []
|
||||
const feedback = { msgWarning: message => warnings.push(message) }
|
||||
const hook = moduleFrom(read('hooks/useDoctorWebConsultation.ts'), name => {
|
||||
if (name === 'vue') return lifecycle
|
||||
if (name === '@/stores/modules/user') return { default: () => store }
|
||||
if (name === '@/api/app') return {}
|
||||
if (name === '@/utils/feedback') return { default: feedback }
|
||||
if (name === '@/utils/doctor-web-consultation') return policy
|
||||
throw new Error(name)
|
||||
}, { Date: { now: () => clock } })
|
||||
let onSignature = () => ({})
|
||||
const state = moduleFrom(script.content, name => {
|
||||
if (name === 'vue') return lifecycle
|
||||
if (name === '@/hooks/useDoctorWebConsultation') return hook
|
||||
if (name === '@/api/patient' || name === '@/api/doctor') return {}
|
||||
if (name === '@/api/tcm') return { getCallSignature: async params => { requests.push(params); return onSignature() } }
|
||||
if (name === '@/utils/feedback') return { default: feedback }
|
||||
if (name === '@/utils/diag-display') return { formatGender: () => '男' }
|
||||
if (name === '@/utils/diabetes-discovery-display') return {}
|
||||
if (name === '@element-plus/icons-vue') return Object.fromEntries(['Phone', 'Search', 'ChatDotRound', 'Loading'].map(key => [key, passthrough]))
|
||||
if (name.endsWith('.vue')) return { default: passthrough }
|
||||
throw new Error(name)
|
||||
}, { ref: vue.ref, computed: vue.computed, watch: vue.watch }).default.setup({}, { expose() {} })
|
||||
const row = { id: 90, patient_id: 50, source_patient_id: 50, diagnosis_id: 70, patient_name: '测试患者', appointment_type: 'video' }
|
||||
state.queue.value = [row]
|
||||
state.chatDialogRef.value = { open: value => opened.push(value) }
|
||||
async function markup() {
|
||||
const app = vue.createSSRApp({ render: () => render({}, [], {}, vue.proxyRefs(state)) })
|
||||
app.config.warnHandler = () => {}
|
||||
for (const name of ['el-input', 'el-icon', 'el-tag', 'el-empty', 'el-dialog', 'el-button']) app.component(name, passthrough)
|
||||
app.component('el-tooltip', { props: ['content'], setup: (props, { slots }) => () => vue.h('div', { 'data-tooltip': props.content }, slots.default?.()) })
|
||||
for (const name of ['loading', 'perms']) app.directive(name, { getSSRProps: () => ({}) })
|
||||
return renderToString(app)
|
||||
}
|
||||
|
||||
assert.match(await markup(), /class="row-icon-btn call" aria-label="发起通话"/)
|
||||
await state.handleCall(row)
|
||||
assert.equal(requests.length, 1)
|
||||
assert.equal(opened.length, 1)
|
||||
|
||||
// A signature that returns after the deadline must never open the calling window.
|
||||
onSignature = () => { clock = cutoff; return {} }
|
||||
await state.handleCall(row)
|
||||
assert.equal(requests.length, 2)
|
||||
assert.equal(opened.length, 1)
|
||||
const expired = await markup()
|
||||
assert.match(expired, /class="row-icon-btn call" disabled aria-label="[^"]*桌面应用/)
|
||||
assert.match(expired, /<span>已停用<\/span>/)
|
||||
assert.match(expired, /data-tooltip="[^"]*桌面应用/)
|
||||
assert.doesNotMatch(expired, /class="row-icon-btn notify" disabled/)
|
||||
await state.handleCall(row)
|
||||
assert.equal(requests.length, 2)
|
||||
assert.equal(opened.length, 1)
|
||||
assert.equal(warnings.length, 2)
|
||||
|
||||
for (const identity of [{ root: 1, role_ids: [1] }, { root: 0, role_ids: [2] }]) {
|
||||
Object.assign(store.userInfo, identity)
|
||||
assert.match(await markup(), /class="row-icon-btn call" aria-label="发起通话"/)
|
||||
assert.doesNotMatch(await markup(), /<span>已停用<\/span>/)
|
||||
await state.handleCall(row)
|
||||
}
|
||||
assert.equal(requests.length, 4)
|
||||
assert.equal(opened.length, 3)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user