feat(consignment): 后台寄卖规格按分类模板动态渲染
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import test from 'node:test'
|
||||
|
||||
function readPanel(name: string) {
|
||||
return readFileSync(
|
||||
fileURLToPath(new URL(`../src/pages/admin/panels/${name}`, import.meta.url)),
|
||||
'utf8',
|
||||
)
|
||||
}
|
||||
|
||||
test('提报审核:规格按寄卖模板渲染,有模板时不再写死旧字段', () => {
|
||||
const page = readPanel('ConsignmentSubmissionsPanel.tsx')
|
||||
|
||||
assert.ok(
|
||||
page.includes('resolveConsignmentSpecDisplayItems(record.specs, record.specValues)'),
|
||||
'提报列表必须按模板字段渲染规格',
|
||||
)
|
||||
assert.ok(
|
||||
page.includes('resolveConsignmentSpecText(viewingSubmission)'),
|
||||
'提报详情必须使用模板规格文本',
|
||||
)
|
||||
assert.ok(
|
||||
page.includes('{approveModalItem?.specs?.length ? null : ('),
|
||||
'有模板规格时审核弹窗必须隐藏系统/区服/系列/钻级/璀璨旧字段',
|
||||
)
|
||||
assert.ok(
|
||||
page.includes('const hasDynamicSpecs = Boolean(approveModalItem.specs?.length)'),
|
||||
'提交前必须判断该分类是否有模板规格',
|
||||
)
|
||||
assert.ok(page.includes('...(hasDynamicSpecs'), '有模板规格时不得再提交旧规格字段')
|
||||
assert.ok(page.includes('规格(按寄卖分类模板)'), '审核弹窗需要标明规格来自寄卖模板')
|
||||
assert.ok(page.includes('请填写「'), '动态必填字段必须在表单层校验')
|
||||
})
|
||||
|
||||
test('寄售仓库:列表/详情按模板渲染,编辑不再写死旧字段', () => {
|
||||
const page = readPanel('ConsignmentInventoryPanel.tsx')
|
||||
|
||||
assert.ok(!page.includes("title: '和平精英规格'"), '仓库列表列名不得写死和平精英')
|
||||
assert.ok(page.includes("title: '寄卖规格'"), '仓库列表列名应为通用「寄卖规格」')
|
||||
assert.ok(
|
||||
page.includes('resolveConsignmentSpecDisplayItems(record.specs, record.specValues)'),
|
||||
'仓库列表必须按模板字段渲染规格',
|
||||
)
|
||||
assert.ok(
|
||||
page.includes('resolveConsignmentSpecText(viewingItem)'),
|
||||
'仓库详情必须使用模板规格文本',
|
||||
)
|
||||
assert.ok(
|
||||
page.includes('{editingItem?.specs?.length ? null : ('),
|
||||
'有模板规格时编辑弹窗必须隐藏旧规格字段',
|
||||
)
|
||||
assert.ok(
|
||||
page.includes('const hasDynamicSpecs = Boolean(editingItem.specs?.length)'),
|
||||
'保存前必须判断该分类是否有模板规格',
|
||||
)
|
||||
assert.ok(page.includes('...(hasDynamicSpecs'), '有模板规格时不得再提交旧规格字段')
|
||||
assert.ok(page.includes('请填写「'), '动态必填字段必须在表单层校验')
|
||||
})
|
||||
Reference in New Issue
Block a user