Files
SupplierSystem/server/tests/bidPartialAllocOutsideScope.test.ts
Ubuntu deb3e72750
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s
chore: 以 AI 生鲜配送系统 当前版本作为 SupplierSystem 起点
来源仓库:jxc/ai-fresh-delivery
来源提交:f0b1a180e2deb7e4673b9d1c8542619f7bc0f73d
快照树:  09f679334ff38f0ff25e907961c94a8223bcaedd(与来源 HEAD 工作树逐字节一致,3801 个文件)

按约定本仓库不带任何历史提交:来源仓库的历史中含真实凭据
(生产 SSH 私钥 deploy/id_rsa_tencent、server/.env、.env.tencent/.env.production/.env.gitea、
deploy/小程序AppSecret.txt,其中 MP_APPSECRET / S3 AccessKey 经哈希比对与线上同值),
整包推送会把这些凭据永久带入本仓库,故只取「当前版本」的单提交快照。
供应商系统后续开发自本提交开始。
2026-10-08 17:35:43 +08:00

68 lines
2.9 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from 'vitest';
import { readFileSync } from 'fs';
import path from 'path';
describe('竞价 defer 时范围外商品仍分配', () => {
const allocSrc = readFileSync(
path.join(__dirname, '../src/services/orderAllocationService.ts'),
'utf8'
);
const submitSrc = readFileSync(
path.join(__dirname, '../src/services/customerOrderSubmitService.ts'),
'utf8'
);
const manageSrc = readFileSync(
path.join(__dirname, '../src/services/orderManageItemsService.ts'),
'utf8'
);
it('分配支持 excludeSkuCodes / deferredBidSkuCodes', () => {
expect(allocSrc).toMatch(/excludeSkuCodes\?:/);
expect(allocSrc).toMatch(/deferredBidSkuCodes/);
expect(allocSrc).toMatch(/skipSkuCodes: excludeSkuSet/);
expect(allocSrc).toMatch(/allocateOutsideBidScope/);
});
it('嵌套提交路径发标成功后按 excludeSkuCodes 做范围外分配', () => {
expect(submitSrc).toMatch(/excludeSkuCodes/);
expect(submitSrc).toMatch(/deferredBidSkuCodes/);
expect(manageSrc).toMatch(/excludeSkuCodes/);
expect(manageSrc).toMatch(/deferredBidSkuCodes/);
});
it('强制覆盖不会把竞价暂缓 SKU 转自采', () => {
expect(allocSrc).toMatch(/skipSkuCodes\.has\(sku\)/);
});
it('所有强制覆盖调用点都传入 excludeSkuSet', () => {
// 回归:曾有两处调用点漏传 skipSkuCodes,导致竞价中(供应商为空、无采购单)的行
// 被当成「未覆盖」强制生成空供应商自采单——订单列表/自采列表显示为「自采」,与竞价冲突。
const marker = 'await forceCoverUnfulfilledOrderItems(';
let idx = allocSrc.indexOf(marker);
let checked = 0;
while (idx !== -1) {
// 取该调用点之后足够长的一段,确认其 options 里带了 skipSkuCodes
const callBlock = allocSrc.slice(idx, idx + 1500);
expect(callBlock).toMatch(/skipSkuCodes: excludeSkuSet/);
checked += 1;
idx = allocSrc.indexOf(marker, idx + marker.length);
}
expect(checked).toBeGreaterThanOrEqual(4);
});
it('自采兜底循环同样跳过竞价范围内的 SKU', () => {
// 「分配兜底:未匹配供应商,转自采」这条 SQL 命中的正是竞价中行的特征
// (supplier_code 为空且无采购单),必须按 SKU 排除后才可建单。
const idx = allocSrc.indexOf('分配兜底:未匹配供应商,转自采');
expect(idx).toBeGreaterThan(-1);
const before = allocSrc.slice(Math.max(0, idx - 400), idx);
expect(before).toMatch(/if \(excludeSkuSet\.has\(String\(row\.sku_code/);
});
it('发标失败/catch 走 resolvePerOrderBidSkipGateAllocOptions', () => {
expect(submitSrc).toMatch(/resolvePerOrderBidSkipGateAllocOptions/);
expect(manageSrc).toMatch(/resolvePerOrderBidSkipGateAllocOptions/);
expect(allocSrc).toMatch(/resolvePerOrderBidSkipGateAllocOptions/);
});
});