Files
inkreach-official-website/apps/api/src/sync/category-name.spec.ts
T
yeuimu 814f45c5a3 fix(categories): 分类名去括号——同步入库整段删除括号段
左侧分类树/官网分类名的括号段(型号限定词(JSA002)与内容性括号
(黑+卡其)/(短裤 & 长裤))整段删除。分类名每小时被 SDS 同步覆盖,
清洗落在 syncCategories 入库路径(cleanCategoryDisplayName,款号 token
保留,剥空守卫),另附幂等存量脚本 fix:category-names。

已执行:V1/V2 各 33 条分类名去括号,复跑幂等 0。注意 api 容器重建
部署前旧镜像的下一轮同步会把名称写回原文,部署后自动恢复干净。

Tests: api 23 suites/206 passed(含新增 category-name.spec 7 例),tsc clean
2026-09-03 01:20:17 +08:00

47 lines
1.7 KiB
TypeScript
Raw 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 { cleanCategoryDisplayName } from './sync.service';
describe('cleanCategoryDisplayName(分类名去括号,同步入库清洗)', () => {
it('删除型号限定词括号段(含名称后带空格的形态)', () => {
expect(cleanCategoryDisplayName('DG001 180G纯棉T恤 JSA002')).toBe(
'DG001 180G纯棉T恤',
);
expect(cleanCategoryDisplayName('DG004 230G水洗T恤(JSA003')).toBe(
'DG004 230G水洗T恤',
);
});
it('删除内容性括号段(整段删除)', () => {
expect(cleanCategoryDisplayName('YSM02 全棉斜纹拼色帽子(黑+卡其)')).toBe(
'YSM02 全棉斜纹拼色帽子',
);
expect(cleanCategoryDisplayName('下装(短裤 & 长裤)')).toBe('下装');
});
it('多个括号段一并删除并折叠空白', () => {
expect(cleanCategoryDisplayName('T恤(短袖)(男款)成人')).toBe('T恤 成人');
});
it('半角括号同样处理', () => {
expect(cleanCategoryDisplayName('DG001 180G纯棉T恤 (JSA002)')).toBe(
'DG001 180G纯棉T恤',
);
});
it('无括号名称原样返回', () => {
expect(cleanCategoryDisplayName('PLTK016 童装纯色插肩短袖T恤')).toBe(
'PLTK016 童装纯色插肩短袖T恤',
);
});
it('剥空守卫:名称仅剩括号段时原样返回', () => {
expect(cleanCategoryDisplayName('JSA002')).toBe('JSA002');
expect(cleanCategoryDisplayName('(短裤 & 长裤)')).toBe('(短裤 & 长裤)');
});
it('空/null 输入容错', () => {
expect(cleanCategoryDisplayName('')).toBe('');
expect(cleanCategoryDisplayName(null)).toBe(null);
expect(cleanCategoryDisplayName(undefined)).toBe(undefined);
});
});