- T1 资金/库存/报价/自采 P1(BIZ-1/2/3/4/10/13/14) - T2 主系统反向事件墓碑/改派/孤儿处理(BIZ-6/8/9) - T3 选分公司 ticket、trust proxy、角色权限收口(SEC-2/3/4) - T4 缺列/RLS/tenant 名单/FK/迁移执行器(DATA-1..8) - T5 401 登出/分页/映射口径/blob/ZIP 中文名(FE-1..4/BIZ-15) - T6 测试脚本目标守卫/config fail-fast/容器配置(OPS-2..8) - T7 前后端测试与 lint 门禁清零 - T8 应付卡片按关联订单日(口径 A) - T9 存储对象全链路归属校验、敏感列禁写、审计 target_id 超长修复
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import { describe, it } from 'vitest';
|
|
import {
|
|
chunkMarketPriceItems,
|
|
extractJsonArrayText,
|
|
parseAiMarketPriceQuotes,
|
|
MARKET_AI_PRICE_BATCH_SIZE,
|
|
} from '../src/services/marketAiPriceQuoteService';
|
|
|
|
function testChunk() {
|
|
const items = Array.from({ length: 250 }, (_, i) => i);
|
|
const batches = chunkMarketPriceItems(items, MARKET_AI_PRICE_BATCH_SIZE);
|
|
assert.equal(batches.length, 3);
|
|
assert.equal(batches[0].length, 100);
|
|
assert.equal(batches[1].length, 100);
|
|
assert.equal(batches[2].length, 50);
|
|
assert.equal(chunkMarketPriceItems([], 100).length, 0);
|
|
}
|
|
|
|
function testParse() {
|
|
const allowed = new Set(['SKU1', 'SKU2', 'SKU3']);
|
|
const raw = `废话
|
|
[{"sku_code":"SKU1","market_price":12.34},{"sku_code":"SKU9","market_price":9},{"sku_code":"SKU2","market_price":0},{"sku_code":"SKU3","market_price":"3.5"}]
|
|
尾巴`;
|
|
const map = parseAiMarketPriceQuotes(raw, allowed);
|
|
assert.equal(map.get('SKU1'), 12.34);
|
|
assert.equal(map.has('SKU9'), false);
|
|
assert.equal(map.has('SKU2'), false);
|
|
assert.equal(map.get('SKU3'), 3.5);
|
|
assert.equal(extractJsonArrayText('no array'), null);
|
|
}
|
|
|
|
describe('marketAiPriceQuoteService', () => {
|
|
it('chunk / parse 契约(原 assert 脚本迁移为 vitest 用例)', () => {
|
|
testChunk();
|
|
testParse();
|
|
});
|
|
});
|