feat(admin): family-aware goods view - auto tags readonly, clean link names, config badges, locate highlight
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { sameOriginGroup, truncateToProcess } from './origin-name';
|
||||
import {
|
||||
cleanLinkName,
|
||||
deriveLinkTagNames,
|
||||
parseLinkName,
|
||||
sameOriginGroup,
|
||||
truncateToProcess,
|
||||
} from './origin-name';
|
||||
|
||||
describe('truncateToProcess', () => {
|
||||
it('keeps first 3 dash segments (drops warehouse)', () => {
|
||||
@@ -44,3 +50,59 @@ describe('sameOriginGroup', () => {
|
||||
expect(sameOriginGroup('', '')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseLinkName / cleanLinkName', () => {
|
||||
it('parses 国家(物流)品名-SKU-工艺 → 品名 + 型号', () => {
|
||||
expect(parseLinkName('美国(包邮)180g纯棉T恤成人款-DG001-单面印花')).toEqual({
|
||||
productName: '180g纯棉T恤成人款',
|
||||
skuCode: 'DG001',
|
||||
});
|
||||
expect(cleanLinkName('美国(包邮)180g纯棉T恤成人款-DG001-单面印花')).toBe(
|
||||
'180g纯棉T恤成人款 DG001',
|
||||
);
|
||||
});
|
||||
|
||||
it('handles half-width parens and warehouse suffix', () => {
|
||||
expect(
|
||||
cleanLinkName('美国(不包邮光板)180GT恤成人款-JSA002-不打印·美西洛杉矶二仓'),
|
||||
).toBe('180GT恤成人款 JSA002');
|
||||
});
|
||||
|
||||
it('returns null / raw fallback for manual names without the country(remark) structure', () => {
|
||||
expect(parseLinkName('180g纯棉T恤成人款')).toBeNull();
|
||||
expect(cleanLinkName('180g纯棉T恤成人款')).toBe('180g纯棉T恤成人款');
|
||||
expect(cleanLinkName(null)).toBe('');
|
||||
});
|
||||
|
||||
it('returns null when product name after parens is empty', () => {
|
||||
expect(parseLinkName('美国(包邮)-DG001-单面印花')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('deriveLinkTagNames', () => {
|
||||
it('单面印花 + 包邮 + 无工艺关键字 → 单面印花/烫画/包邮', () => {
|
||||
expect(deriveLinkTagNames('美国(包邮)180g纯棉T恤成人款-DG001-单面印花')).toEqual([
|
||||
'单面印花',
|
||||
'烫画',
|
||||
'包邮',
|
||||
]);
|
||||
});
|
||||
|
||||
it('不打印 + 光板 + 不包邮 → 两工艺标签 + 不包邮', () => {
|
||||
expect(
|
||||
deriveLinkTagNames('美国(不包邮光板)180GT恤成人款-JSA002-不打印·美西洛杉矶二仓'),
|
||||
).toEqual(['不打印', '光板', '不包邮']);
|
||||
});
|
||||
|
||||
it('双面印花 + 不包邮,且不误命中包邮', () => {
|
||||
expect(deriveLinkTagNames('美国(不包邮)T恤-DG001-双面印花·美东新泽西仓')).toEqual([
|
||||
'双面印花',
|
||||
'烫画',
|
||||
'不包邮',
|
||||
]);
|
||||
});
|
||||
|
||||
it('空名称返回空数组', () => {
|
||||
expect(deriveLinkTagNames(null)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user