更新
This commit is contained in:
@@ -10,6 +10,7 @@ const { parse, compileScript, compileTemplate } = require('@vue/compiler-sfc')
|
||||
const root = path.resolve(__dirname, '../src')
|
||||
const signature = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP4z8DwHwAFgAI/ScLbtAAAAABJRU5ErkJggg=='
|
||||
const oldSignature = 'data:image/png;base64,old-order-signature'
|
||||
const defaultSignature = 'https://gz-1349751149.cos.ap-guangzhou.myqcloud.com/uploads/images/20261117/202611171443119d5159658.png'
|
||||
const signedOrder = () => ({
|
||||
id: 42, prescription_id: 8, fulfillment_status: 1, prescription_audit_status: 1,
|
||||
prescription_audit_signature: signature, prescription_audit_signed_name: '本单药师',
|
||||
@@ -128,6 +129,7 @@ for (const page of ['order_list.vue', 'order_list_h5.vue']) {
|
||||
const html = await renderedSlip(state.prescriptionViewData.value, variant)
|
||||
assert.match(html, /<img[^>]*alt="药师签名"/)
|
||||
assert.ok(html.includes(`src="${signature}"`))
|
||||
assert.equal(html.includes(defaultSignature), false)
|
||||
assert.equal(html.includes('本单药师'), false)
|
||||
assert.ok(html.indexOf('开方医师') < html.indexOf('药师签名'))
|
||||
}
|
||||
@@ -145,7 +147,7 @@ for (const page of ['order_list.vue', 'order_list_h5.vue']) {
|
||||
assert.equal(html.includes(oldSignature), false)
|
||||
})
|
||||
|
||||
test(`${page}: pending, rejected, cancelled and refunded fresh orders remove stale pharmacist images from both slips`, async () => {
|
||||
test(`${page}: missing or invalid audit signatures show the default image without restoring stale signatures`, async () => {
|
||||
const stale = { ...basePrescription(), ...signedOrder(), id: 8 }
|
||||
for (const order of [
|
||||
{ ...signedOrder(), prescription_audit_status: 0 },
|
||||
@@ -159,7 +161,10 @@ for (const page of ['order_list.vue', 'order_list_h5.vue']) {
|
||||
assert.equal(state.prescriptionViewData.value.prescription_audit_signature, '')
|
||||
for (const variant of ['internal', 'user']) {
|
||||
const html = await renderedSlip(state.prescriptionViewData.value, variant)
|
||||
assert.equal(html.includes('alt="药师签名"'), false)
|
||||
assert.ok(html.includes(`src="${defaultSignature}"`))
|
||||
assert.ok(html.includes('alt="药师签名"'))
|
||||
assert.equal(html.includes(signature), false)
|
||||
assert.equal(html.includes(oldSignature), false)
|
||||
assert.equal(html.includes('本单药师'), false)
|
||||
}
|
||||
}
|
||||
@@ -179,7 +184,9 @@ for (const page of ['order_list.vue', 'order_list_h5.vue']) {
|
||||
setPrescription({ ...basePrescription(), ...signedOrder(), id: 8 })
|
||||
await state.confirmRevokeRxAudit({ id: 42 })
|
||||
assert.equal(state.prescriptionViewData.value.prescription_audit_signature, '')
|
||||
assert.equal((await renderedSlip(state.prescriptionViewData.value, 'user')).includes('alt="药师签名"'), false)
|
||||
const revokedHtml = await renderedSlip(state.prescriptionViewData.value, 'user')
|
||||
assert.ok(revokedHtml.includes(`src="${defaultSignature}"`))
|
||||
assert.equal(revokedHtml.includes(signature), false)
|
||||
})
|
||||
|
||||
test(`${page}: another order's detail and failed detail loads cannot borrow a cached signature`, async () => {
|
||||
|
||||
@@ -294,16 +294,21 @@ test('signature pad maps CSS coordinates once at high DPR and preserves strokes
|
||||
assert.equal(props.modelValue, signature)
|
||||
})
|
||||
|
||||
test('prescription slip only displays the pharmacist signature for the current signed approval', () => {
|
||||
test('prescription slip prefers the current signed approval and uses the default image when missing', () => {
|
||||
const source = fs.readFileSync(path.join(root, 'src/components/prescription-slip/utils.ts'), 'utf8')
|
||||
const { rxPharmacistSignature } = loadModule(source, () => { throw new Error('unexpected import') })
|
||||
const defaultSignature = 'https://gz-1349751149.cos.ap-guangzhou.myqcloud.com/uploads/images/20261117/202611171443119d5159658.png'
|
||||
const signed = { prescription_audit_status: 1, prescription_audit_signature: signature, prescription_audit_signed_name: ' 李药师 ', doctor_name: '王医生' }
|
||||
assert.equal(rxPharmacistSignature(signed), signature)
|
||||
assert.equal(rxPharmacistSignature({ ...signed, prescription_audit_status: '1' }), signature)
|
||||
for (const status of [0, 2, null, undefined]) assert.equal(rxPharmacistSignature({ ...signed, prescription_audit_status: status }), '')
|
||||
assert.equal(rxPharmacistSignature({ ...signed, prescription_audit_signature: '' }), '')
|
||||
for (const status of [0, 2, null, undefined]) assert.equal(rxPharmacistSignature({ ...signed, prescription_audit_status: status }), defaultSignature)
|
||||
for (const missing of ['', ' ', null, undefined]) {
|
||||
assert.equal(rxPharmacistSignature({ ...signed, prescription_audit_signature: missing }), defaultSignature)
|
||||
}
|
||||
assert.equal(rxPharmacistSignature({ ...signed, prescription_audit_signed_name: '' }), signature)
|
||||
assert.equal(rxPharmacistSignature({ doctor_name: '王医生' }), '')
|
||||
assert.equal(rxPharmacistSignature({ doctor_name: '王医生' }), defaultSignature)
|
||||
assert.equal(rxPharmacistSignature(null), '')
|
||||
assert.equal(rxPharmacistSignature(undefined), '')
|
||||
component('components/prescription-slip/index.vue')
|
||||
component('views/consumer/prescription/components/AuditSignatureRecord.vue')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user