- platformCode.js:预设编码加 SHOPIFY(名称 Shopify),别名 shopify / 独立站 → SHOPIFY - 前端 constants/platform.ts 同步(平台下拉、订单列表名称展示同源) - dxm 订单报文的 platform=shopify 不再落到 OTHER,重拉后 platform_type / source_platform_code = SHOPIFY - 测试:预设表 17→18,补 shopify 解析用例;dxm 单测平台编码断言同步 - 文档 5.0 补平台编码口径 - 本地已验证:重拉 60 单后 59 张待审核单 source_platform_code=SHOPIFY(name=Shopify),orders 60 行 platform_type=SHOPIFY Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
58 lines
2.2 KiB
JavaScript
58 lines
2.2 KiB
JavaScript
'use strict';
|
||
|
||
const { assert } = require('egg-mock/bootstrap');
|
||
const { resolvePlatform, resolvePlatformCode, platformNameOf, PLATFORM_PRESETS } = require('../../../app/lib/platformCode');
|
||
const DgjService = require('../../../app/lib/printPlatform/dgj');
|
||
|
||
describe('platformCode 预设平台编码', () => {
|
||
it('预设编码表覆盖 18 个平台且编码唯一', () => {
|
||
const codes = PLATFORM_PRESETS.map(item => item.code);
|
||
assert.strictEqual(codes.length, 18);
|
||
assert.strictEqual(new Set(codes).size, 18);
|
||
});
|
||
|
||
it('店管家 PlatformType 映射到预设编码', () => {
|
||
const cases = {
|
||
Pinduoduo: 'PDD',
|
||
TouTiao: 'DYXD',
|
||
WxVideo: 'SPH',
|
||
Alibaba: '1688',
|
||
Taobao: 'TB',
|
||
KuaiShou: 'KS',
|
||
Tmall: 'TM',
|
||
JingDong: 'JD',
|
||
XiaoHongShu: 'XHS',
|
||
DeWu: 'DW',
|
||
MeiTuan: 'MTYYJK',
|
||
Offline: 'OFFLINE',
|
||
};
|
||
for (const [ raw, expect ] of Object.entries(cases)) {
|
||
assert.strictEqual(DgjService.resolveOrderPlatform(raw).code, expect, raw);
|
||
}
|
||
});
|
||
|
||
it('预设编码/中文名/大小写都能解析', () => {
|
||
assert.strictEqual(resolvePlatformCode('pdd'), 'PDD');
|
||
assert.strictEqual(resolvePlatformCode('TB'), 'TB');
|
||
assert.strictEqual(resolvePlatformCode('拼多多'), 'PDD');
|
||
assert.strictEqual(resolvePlatformCode('抖音小店'), 'DYXD');
|
||
assert.strictEqual(resolvePlatformCode('视频号'), 'SPH');
|
||
// 店小秘等跨境平台:platform=shopify
|
||
assert.strictEqual(resolvePlatformCode('shopify'), 'SHOPIFY');
|
||
assert.deepStrictEqual(resolvePlatform('shopify'), { code: 'SHOPIFY', name: 'Shopify' });
|
||
});
|
||
|
||
it('未知平台落到 OTHER(其他)', () => {
|
||
assert.strictEqual(resolvePlatformCode('unknown-platform'), 'OTHER');
|
||
assert.strictEqual(resolvePlatformCode(''), 'OTHER');
|
||
assert.strictEqual(resolvePlatformCode(null), 'OTHER');
|
||
assert.deepStrictEqual(resolvePlatform('xyz'), { code: 'OTHER', name: '其他' });
|
||
});
|
||
|
||
it('名称反查与兜底', () => {
|
||
assert.strictEqual(platformNameOf('PDD'), '拼多多');
|
||
assert.strictEqual(platformNameOf('1688'), '阿里巴巴');
|
||
assert.strictEqual(platformNameOf('WHATEVER'), 'WHATEVER');
|
||
});
|
||
});
|