Files
order_site/apps/frontend/tests/consignment-admin-dynamic-specs.test.ts
T
zhaoxing a5e877b2ff 统一寄卖仓库与提报审核规格展示
- 规格标签只显示值,0 璀璨不再显示「无」
- 仓库列表长规格文本改为纯值一行
- 列表物品名展示层清理历史 0 璀璨残留
- 补充规格展示回归测试
2026-11-14 14:23:09 +08:00

105 lines
4.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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('resolveConsignmentSpecTagItems(record.specs, record.specValues)'),
'提报列表必须按模板字段渲染规格标签',
)
assert.ok(
page.includes('resolveConsignmentDisplayItemName(record)'),
'提报列表物品名必须清掉历史 0 璀璨残留',
)
assert.ok(!page.includes('{item.label} {item.value}'), '提报列表规格标签只显示值')
assert.ok(
page.includes('title={`${item.label}:${item.value}`}'),
'提报列表规格标签悬浮显示字段名',
)
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('resolveConsignmentSpecTagItems(record.specs, record.specValues)'),
'仓库列表必须按模板字段渲染规格标签',
)
assert.ok(
page.includes('resolveConsignmentSpecValueText(record, { omitZeroBrilliance: true })'),
'仓库列表规格行必须只显示值并省略 0 璀璨',
)
assert.ok(
page.includes('resolveConsignmentDisplayItemName(record)'),
'仓库列表物品名必须清掉历史 0 璀璨残留',
)
assert.ok(!page.includes('{record.specText}'), '仓库列表不得再显示重复的长规格文本')
assert.ok(
page.includes('title={`${item.label}:${item.value}`}'),
'仓库列表规格标签悬浮显示字段名',
)
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('请填写「'), '动态必填字段必须在表单层校验')
})
test('物品详情的打手提报时间取来源提报创建时间', () => {
const inventoryPage = readPanel('ConsignmentInventoryPanel.tsx')
assert.ok(
inventoryPage.includes('viewingItem.sourceSubmissionCreatedAt || viewingItem.createdAt'),
'打手提报时间必须优先取来源提报创建时间',
)
const repo = readFileSync(
fileURLToPath(
new URL(
'../../backend/src/repositories/worker-platform/consignment-repo.ts',
import.meta.url,
),
),
'utf8',
)
assert.ok(
repo.includes('cs.created_at AS source_submission_created_at'),
'库存查询必须带来源提报创建时间',
)
})