feat(consignment): 寄售仓库按寄卖分类筛选并支持动态规格过滤
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import test from 'node:test'
|
||||
|
||||
function readSource(relativePath: string) {
|
||||
// Windows 检出为 CRLF,多行断言里的 \n 会匹配失败,先统一换行
|
||||
return readFileSync(new URL(relativePath, import.meta.url).pathname, 'utf8').replace(
|
||||
/\r\n/g,
|
||||
'\n',
|
||||
)
|
||||
}
|
||||
|
||||
const panelSource = readSource('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx')
|
||||
const configSource = readSource('../src/pages/admin/panels/ConsignmentConfigPanel.tsx')
|
||||
const serviceSource = readSource('../src/services/admin/consignment.ts')
|
||||
|
||||
test('寄售仓库:分类下拉只来自寄卖配置,默认苏尔南手枪', () => {
|
||||
assert.ok(
|
||||
panelSource.includes('fetchAdminConsignmentInventoryFilterOptions'),
|
||||
'必须调用寄卖配置下发的筛选项接口',
|
||||
)
|
||||
assert.ok(panelSource.includes("categoryKey === 'shouqiang'"), '默认选中苏尔南手枪')
|
||||
assert.ok(panelSource.includes('categoryId: categoryId ?? undefined'), '分类必须透传给库存查询')
|
||||
assert.ok(
|
||||
!panelSource.includes('options={SYSTEM_OPTIONS}') &&
|
||||
!panelSource.includes('options={DIAMOND_OPTIONS}'),
|
||||
'旧的写死四筛必须移除',
|
||||
)
|
||||
})
|
||||
|
||||
test('寄售仓库:筛选项按配置动态渲染,切换分类会清空旧规格', () => {
|
||||
assert.ok(panelSource.includes('dynamicFilters.map'), '筛选项必须由配置动态渲染')
|
||||
assert.ok(panelSource.includes('setSpecFilters({})'), '切换分类必须清空上一个分类的规格筛选')
|
||||
assert.ok(panelSource.includes('specFilters: specFilterParams'), '规格筛选必须透传给库存查询')
|
||||
assert.ok(panelSource.includes('match: field.match'), '文本规格要带 contains,选项规格走 exact')
|
||||
})
|
||||
|
||||
test('寄售仓库:表格新增「寄卖分类」列', () => {
|
||||
assert.ok(panelSource.includes("title: '寄卖分类'"), '缺少寄卖分类列')
|
||||
assert.ok(panelSource.includes('record.categoryName'), '分类列必须展示分类名称')
|
||||
})
|
||||
|
||||
test('寄售仓库:统计卡片跟随分类与规格筛选联动', () => {
|
||||
assert.ok(
|
||||
panelSource.includes(
|
||||
'categoryId: categoryId ?? undefined,\n specFilters: specFilterParams',
|
||||
),
|
||||
'统计查询必须带分类与规格筛选',
|
||||
)
|
||||
})
|
||||
|
||||
test('寄卖配置:规格字段提供「支持筛选」开关并随配置保存', () => {
|
||||
assert.ok(configSource.includes('支持筛选'), '缺少支持筛选开关')
|
||||
assert.ok(configSource.includes('filterable: checked'), '开关必须写回配置')
|
||||
assert.ok(configSource.includes('filterable: false,'), '新建字段默认不参与筛选')
|
||||
})
|
||||
|
||||
test('筛选选项接口:按已开启寄卖的分类返回', () => {
|
||||
assert.ok(
|
||||
serviceSource.includes('/worker-platform/consignment/inventory-filter-options'),
|
||||
'缺少筛选选项接口',
|
||||
)
|
||||
})
|
||||
|
||||
test('一键查询待匹配订单:按当前寄卖分类查询', () => {
|
||||
const modalSource = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
|
||||
|
||||
assert.ok(modalSource.includes('categoryId: categoryId ?? undefined'), '必须把分类传给待匹配接口')
|
||||
assert.ok(modalSource.includes('分类:{categoryName}'), '弹窗要标明当前分类')
|
||||
assert.ok(panelSource.includes('categoryId={categoryId}'), '仓库面板必须把当前分类传给弹窗')
|
||||
})
|
||||
Reference in New Issue
Block a user