重构:硬切商品来源并移除旧运维入口
This commit is contained in:
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import test from 'node:test'
|
||||
|
||||
import { costModelAppliesTo } from './cost-center-mappers.js'
|
||||
import { costModelAppliesTo, mapProduct } from './cost-center-mappers.js'
|
||||
import {
|
||||
normalizeMappingMatchType,
|
||||
normalizeProviderKey,
|
||||
@@ -288,8 +288,9 @@ test('接单模板改价必须在同一事务中同步成本版本与模板投
|
||||
test('成本模型与商品来源必须覆盖第三方卡券渠道', () => {
|
||||
assert.equal(costModelAppliesTo('third_party_voucher_cost', 'third_party_voucher'), true)
|
||||
assert.equal(costModelAppliesTo('third_party_voucher_cost', 'manual'), false)
|
||||
assert.ok(productSourceFilterSql(1).includes("'third_party_voucher'"))
|
||||
assert.ok(productSourceFilterSql(1).includes("'tpv:%'"))
|
||||
const sourceSql = productSourceFilterSql(1)
|
||||
assert.equal(sourceSql, 'p.source_kind = $1')
|
||||
assert.ok(!sourceSql.includes('canonical_sku'))
|
||||
const channelSql = productChannelFilterSql(1)
|
||||
assert.ok(channelSql.includes('active_primary_channel'))
|
||||
assert.ok(channelSql.includes("$1 = 'unrouted'"))
|
||||
@@ -351,11 +352,35 @@ test('运行期停止写入已废弃的 product_channel_capabilities', async ()
|
||||
}
|
||||
})
|
||||
|
||||
test('tpv: 商品来源归为第三方卡券', async () => {
|
||||
const { productSourceOf } = await import('./cost-center-mappers.js')
|
||||
const assert = (await import('node:assert/strict')).default
|
||||
assert.equal(productSourceOf('tpv:模拟卡券'), 'third_party_voucher')
|
||||
assert.equal(productSourceOf('man:模拟人工'), 'manual')
|
||||
test('商品来源只读 source_kind,不再按 canonical_sku 前缀回退', () => {
|
||||
const product = mapProduct({
|
||||
id: 1,
|
||||
canonical_sku: 'man:编码与来源故意不一致',
|
||||
canonical_name: '测试商品',
|
||||
category: '',
|
||||
unit_name: '件',
|
||||
status: 'active',
|
||||
root_category_id: null,
|
||||
root_category_name: '',
|
||||
sub_category_id: null,
|
||||
sub_category_name: '',
|
||||
attributes_json: {},
|
||||
created_at: '',
|
||||
updated_at: '',
|
||||
source_kind: 'third_party_voucher',
|
||||
})
|
||||
assert.equal(product.source, 'third_party_voucher')
|
||||
assert.equal(product.sourceKind, 'third_party_voucher')
|
||||
})
|
||||
|
||||
test('阶段 6 不再保留会写旧履约列的运维脚本', async () => {
|
||||
const packageJson = JSON.parse(
|
||||
await readFile(new URL('../../../package.json', import.meta.url), 'utf8'),
|
||||
) as { scripts?: Record<string, string> }
|
||||
assert.equal(packageJson.scripts?.['finance:sync'], undefined)
|
||||
assert.equal(packageJson.scripts?.['finance:rebuild-cutover'], undefined)
|
||||
assert.equal(packageJson.scripts?.['products:merge-duplicates'], undefined)
|
||||
assert.equal(packageJson.scripts?.['products:reclassify'], undefined)
|
||||
})
|
||||
|
||||
test('人工标准商品禁止绕过人工 SKU 配置手工创建', async () => {
|
||||
|
||||
Reference in New Issue
Block a user