重构:统一商品渠道投影并收敛权威文档

This commit is contained in:
yml2213
2026-11-08 19:44:27 +08:00
parent 0a595acfa9
commit 1634502363
67 changed files with 2147 additions and 444 deletions
@@ -0,0 +1,41 @@
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import test from 'node:test'
test('标准商品列表按当前渠道筛选,并单独展示来源、主渠道和兜底渠道', async () => {
const source = await readFile(
new URL('../src/pages/admin/cost-center/ProductCatalogPanel.tsx', import.meta.url),
'utf8',
)
assert.ok(source.includes('channel: channelFilter'))
assert.ok(!source.includes('carrierType: productSourceFilter'))
assert.ok(source.includes("title: '来源'"))
assert.ok(source.includes("title: '当前履约'"))
assert.ok(source.includes('row.activePrimaryChannel'))
assert.ok(source.includes('row.fallbackChannels'))
assert.ok(source.includes('未路由'))
})
test('渠道映射的统计、目录、队列和商品下拉都使用当前渠道', async () => {
const [panel, catalog, queue] = await Promise.all([
readFile(
new URL('../src/pages/admin/cost-center/ChannelMappingPanel.tsx', import.meta.url),
'utf8',
),
readFile(
new URL('../src/pages/admin/cost-center/ChannelMappingCatalog.tsx', import.meta.url),
'utf8',
),
readFile(
new URL('../src/pages/admin/cost-center/ChannelMappingQueue.tsx', import.meta.url),
'utf8',
),
])
assert.ok(panel.includes('channel: channelFilter'))
assert.ok(panel.includes('item.activePrimaryChannel === channelFilter'))
assert.ok(!panel.includes('carrierType: productSourceFilter'))
assert.ok(catalog.includes('channelLabel'))
assert.ok(queue.includes('channelLabel'))
})
@@ -52,7 +52,7 @@ test('人工商品不再允许手工创建或执行旧批量归档', async () =>
assert.ok(!productSource.includes('归档跨渠道重复商品'))
assert.ok(!productSource.includes('归档纯历史人工商品'))
assert.ok(productSource.includes("productSourceFilter === 'manual'"))
assert.ok(productSource.includes("channelFilter === 'manual'"))
assert.ok(productSource.includes('manualNew=1'))
assert.ok(productSource.includes('人工标准商品由人工 SKU 配置自动创建'))
assert.ok(serviceSource.includes('cost_manual_product_managed_by_config'))
@@ -43,6 +43,6 @@ test('第三方卡券新增 SKU 一次完成商品、规则和采购价', async
assert.ok(service.includes("'/api/v1/admin/cost-center/voucher-products'"))
assert.ok(!service.includes('/voucher-products/ensure-rules'))
assert.ok(panel.includes("searchParams.get('voucherNew')"))
assert.ok(productCatalog.includes("productSourceFilter === 'third_party_voucher'"))
assert.ok(productCatalog.includes("channelFilter === 'third_party_voucher'"))
assert.ok(productCatalog.includes('voucherNew=1'))
})