fix(sync): drop local size-code column (P/M/G/GG) from SDS size charts

巴西/西语市场上游尺码表带一个名为「尺码」的列,值是本地尺码码
P/M/G/GG(=S/M/L/XL),与行首尺码重复且非测量值;解析时整列丢弃。
其他非数字参考列(身高/体重/建议体重)保留。存量 2 条详情已修复
并重算受影响族。
This commit is contained in:
yeuimu
2026-08-29 08:55:16 +08:00
parent ce283dff78
commit b5875d33b2
2 changed files with 57 additions and 1 deletions
@@ -33,6 +33,43 @@ describe('SDS product detail mapper', () => {
expect(chart.rows[0].measurements[0]).toEqual({ key: 'bodyLength', cm: '71', in: '27.95' });
});
it('drops the local size-code column (P/M/G/GG) named 尺码 when all values are non-numeric', () => {
// 巴西/西语市场的 SDS 上游在表头第二列再放一个「尺码」列,值是本地尺码码
// P/M/G/GG=S/M/L/XL),与行首尺码重复且非测量值,应整列丢弃
const raw = JSON.stringify([
['尺码', '尺码(cm/in)', '肩宽(cm/in)', '胸围(cm/in)'].map((content) => ({ content, remark: '' })),
['S', 'P', '52', '106'].map((content) => ({ content, remark: '' })),
['M', 'M', '55', '112'].map((content) => ({ content, remark: '' })),
['L', 'G', '58', '118'].map((content) => ({ content, remark: '' })),
['XL', 'GG', '61', '124'].map((content) => ({ content, remark: '' })),
]);
const chart = parseSizeChart(raw) as any;
expect(chart.columns.map((c: any) => c.name)).toEqual(['肩宽', '胸围']);
expect(chart.rows[0].measurements.map((m: any) => m.key)).toEqual(['shoulder', 'chest']);
expect(chart.rows[0].measurements[0]).toEqual({ key: 'shoulder', cm: '52', in: '20.47' });
});
it('keeps a 尺码-named column when its values are numeric', () => {
const raw = JSON.stringify([
['尺码', '尺码(cm/in)', '胸围(cm/in)'].map((content) => ({ content, remark: '' })),
['S', '1', '106'].map((content) => ({ content, remark: '' })),
['M', '2', '112'].map((content) => ({ content, remark: '' })),
]);
const chart = parseSizeChart(raw) as any;
expect(chart.columns).toHaveLength(2);
expect(chart.rows[0].measurements[0].cm).toBe('1');
});
it('keeps non-numeric reference columns like 身高/体重', () => {
const raw = JSON.stringify([
['尺码', '身高(cm/in)', '体重(cm/in)'].map((content) => ({ content, remark: '' })),
['S', '50-60', '3-4kg'].map((content) => ({ content, remark: '' })),
['M', '60-70', '4-5kg'].map((content) => ({ content, remark: '' })),
]);
const chart = parseSizeChart(raw) as any;
expect(chart.columns.map((c: any) => c.name)).toEqual(['身高', '体重']);
});
it('parses packaging dimensions and weights', () => {
const specs = parsePackageSpecs(packageTable) as any;
expect(specs.rows).toHaveLength(2);