feat(shipping-notice): 新增临时库存管理功能,支持创建会话、获取分析结果及字段映射建议
This commit is contained in:
1 parent
46eb63f5bb
commit
e9bdd81f1a
320 files changed
+28361
-10487
No files matched your search
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* 用途:验证货代发货通知业务域在四种语言中的文案键保持一致。
|
||||
* 依赖:admin/chat/workspace 四语言 JSON;只检查货代业务子树,不受其他历史业务域影响。
|
||||
* 逻辑:递归收集叶子键并比较集合,防止只在单一语言新增或删除货代文案。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import adminEn from '@/locales/en/admin.json';
|
||||
import adminTh from '@/locales/th/admin.json';
|
||||
import adminZhCn from '@/locales/zh-CN/admin.json';
|
||||
import adminZhTw from '@/locales/zh-TW/admin.json';
|
||||
import chatEn from '@/locales/en/chat.json';
|
||||
import chatTh from '@/locales/th/chat.json';
|
||||
import chatZhCn from '@/locales/zh-CN/chat.json';
|
||||
import chatZhTw from '@/locales/zh-TW/chat.json';
|
||||
import workspaceEn from '@/locales/en/workspace.json';
|
||||
import workspaceTh from '@/locales/th/workspace.json';
|
||||
import workspaceZhCn from '@/locales/zh-CN/workspace.json';
|
||||
import workspaceZhTw from '@/locales/zh-TW/workspace.json';
|
||||
|
||||
type LocaleTree = Record<string, unknown>;
|
||||
|
||||
const leafKeys = (value: unknown, prefix = ''): string[] => {
|
||||
if (!value || typeof value !== 'object' || Array.isArray(value)) return [prefix];
|
||||
return Object.entries(value as LocaleTree).flatMap(([key, child]) => (
|
||||
leafKeys(child, prefix ? `${prefix}.${key}` : key)
|
||||
));
|
||||
};
|
||||
|
||||
const expectSameKeys = (trees: LocaleTree[]) => {
|
||||
const expected = leafKeys(trees[0]).sort();
|
||||
trees.slice(1).forEach((tree) => expect(leafKeys(tree).sort()).toEqual(expected));
|
||||
};
|
||||
|
||||
describe('shipping notice i18n parity', () => {
|
||||
it('keeps admin inventory configuration keys aligned', () => {
|
||||
expectSameKeys([
|
||||
adminZhCn.shippingInventory as LocaleTree,
|
||||
adminZhTw.shippingInventory as LocaleTree,
|
||||
adminEn.shippingInventory as LocaleTree,
|
||||
adminTh.shippingInventory as LocaleTree,
|
||||
]);
|
||||
});
|
||||
|
||||
it('keeps chat shipping notice keys aligned', () => {
|
||||
expectSameKeys([
|
||||
chatZhCn.shippingNotice as LocaleTree,
|
||||
chatZhTw.shippingNotice as LocaleTree,
|
||||
chatEn.shippingNotice as LocaleTree,
|
||||
chatTh.shippingNotice as LocaleTree,
|
||||
]);
|
||||
});
|
||||
|
||||
it('keeps workspace shipping notice keys aligned', () => {
|
||||
expectSameKeys([
|
||||
workspaceZhCn.shippingNotice as LocaleTree,
|
||||
workspaceZhTw.shippingNotice as LocaleTree,
|
||||
workspaceEn.shippingNotice as LocaleTree,
|
||||
workspaceTh.shippingNotice as LocaleTree,
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user