优化
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { createSSRApp } from 'vue'
|
||||
import { renderToString } from 'vue/server-renderer'
|
||||
import { parse } from 'vue/compiler-sfc'
|
||||
|
||||
const source = readFileSync(new URL('./ReviewRejectionNotice.vue', import.meta.url), 'utf8')
|
||||
const template = parse(source).descriptor.template.content
|
||||
const render = (status, reason) => renderToString(createSSRApp({ template, props: ['status', 'reason'] }, { status, reason }))
|
||||
|
||||
test('rejected documents display the actual reason safely', async () => {
|
||||
const html = await render('REJECTED', '箱数不符\n请核对 <SKU>')
|
||||
assert.match(html, /驳回原因/)
|
||||
assert.match(html, /箱数不符\n请核对 <SKU>/)
|
||||
assert.match(html, /role="alert"/)
|
||||
})
|
||||
|
||||
test('non-rejected documents do not show an old rejection reason', async () => {
|
||||
for (const status of ['PENDING_REVIEW', 'APPROVED', 'COMPLETED', undefined]) {
|
||||
assert.doesNotMatch(await render(status, '旧审核原因'), /旧审核原因|驳回原因/)
|
||||
}
|
||||
})
|
||||
|
||||
test('legacy rejection without a reason has an explicit fallback', async () => {
|
||||
for (const reason of [undefined, '', ' ']) {
|
||||
assert.match(await render('REJECTED', reason), /暂未记录驳回原因/)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user