feat(scheduler): 六个财务管道作业,模板改价即同步成本版本
- channel_assign / carrier_dispatch / product_normalize / cost_snapshot / sales_facts / ledger_post - 每个作业只写自己那一层,失败互不影响,可单独启停 - 接单模板保存后自动同步规则级成本版本,失败不阻塞模板保存
This commit is contained in:
@@ -43,3 +43,72 @@ test('normalizeScheduledJobsConfig ensures default jobs exist', () => {
|
||||
assert.ok(ids.includes('pdd_order_sync'))
|
||||
assert.ok(ids.includes('cost-finance-sync'))
|
||||
})
|
||||
|
||||
test('normalizeScheduledJobsConfig 收录 v2 六个管道作业并保持各自配置', () => {
|
||||
const config = normalizeScheduledJobsConfig({
|
||||
enabled: true,
|
||||
jobs: [
|
||||
{
|
||||
id: 'channel-assign',
|
||||
type: 'channel_assign',
|
||||
enabled: true,
|
||||
intervalSeconds: 60,
|
||||
config: { batchSize: 800, maxBatches: 5 },
|
||||
},
|
||||
{
|
||||
id: 'carrier-dispatch',
|
||||
type: 'carrier_dispatch',
|
||||
enabled: false,
|
||||
intervalSeconds: 60,
|
||||
config: { limit: 50 },
|
||||
},
|
||||
{
|
||||
id: 'product-normalize',
|
||||
type: 'product_normalize',
|
||||
enabled: true,
|
||||
intervalSeconds: 300,
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
id: 'cost-snapshot',
|
||||
type: 'cost_snapshot',
|
||||
enabled: true,
|
||||
intervalSeconds: 300,
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
id: 'sales-facts',
|
||||
type: 'sales_facts',
|
||||
enabled: true,
|
||||
intervalSeconds: 600,
|
||||
config: { days: 7 },
|
||||
},
|
||||
{
|
||||
id: 'ledger-post',
|
||||
type: 'ledger_post',
|
||||
enabled: true,
|
||||
intervalSeconds: 600,
|
||||
config: { days: 7 },
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const byType = new Map(config.jobs.map((item) => [item.type, item]))
|
||||
assert.equal(byType.get('channel_assign')?.config.batchSize, 800)
|
||||
assert.equal(byType.get('carrier_dispatch')?.enabled, false)
|
||||
assert.equal(byType.get('sales_facts')?.config.days, 7)
|
||||
assert.equal(byType.get('ledger_post')?.config.days, 7)
|
||||
assert.ok(byType.has('product_normalize'))
|
||||
assert.ok(byType.has('cost_snapshot'))
|
||||
})
|
||||
|
||||
test('normalizeScheduledJobsConfig 丢弃未知任务类型', () => {
|
||||
const config = normalizeScheduledJobsConfig({
|
||||
enabled: true,
|
||||
jobs: [{ id: 'nope', type: 'unknown_type', enabled: true, intervalSeconds: 60, config: {} }],
|
||||
})
|
||||
assert.equal(
|
||||
config.jobs.some((item) => item.type === 'unknown_type'),
|
||||
false,
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user