feat(shipping-notice): 收敛复核状态隔离、STP 重试幂等与 XFA 合成预览标注
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
84a881b554
commit
74270adc22
149 files changed
+20111
-3871
No files matched your search
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* features/shipping-progress/gateReasonLabel.spec.ts
|
||||
* 用途:验收「当前需要」文案优先级 C(blockingReason → nextAction)。
|
||||
* 依赖:Vitest、gateReasonLabel。
|
||||
* 逻辑:有 reason 用 gateReasons;仅有 action 用 processGate.actions;均无则空串。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { resolveCurrentNeedLabel, resolveGateReasonLabel } from './gateReasonLabel';
|
||||
|
||||
function makeI18n(messages: Record<string, string>) {
|
||||
return {
|
||||
te: (key: string) => Object.prototype.hasOwnProperty.call(messages, key),
|
||||
t: (key: string) => messages[key] || key,
|
||||
};
|
||||
}
|
||||
|
||||
describe('gateReasonLabel', () => {
|
||||
it('resolveGateReasonLabel prefers shippingProcessing.gateReasons', () => {
|
||||
const i18n = makeI18n({
|
||||
'chat.shippingProcessing.gateReasons.customer_unresolved': '确认客户',
|
||||
'chat.shippingProcessing.gateReasons.generic': '需要处理',
|
||||
});
|
||||
expect(resolveGateReasonLabel('customer_unresolved', i18n)).toBe('确认客户');
|
||||
});
|
||||
|
||||
it('resolveCurrentNeedLabel uses blockingReasonCode first', () => {
|
||||
const i18n = makeI18n({
|
||||
'chat.shippingProcessing.gateReasons.customer_unresolved': '确认客户',
|
||||
'workspace.shippingNotice.processGate.actions.confirm_customer': '确认客户(动作)',
|
||||
'chat.shippingProcessing.gateReasons.generic': '需要处理',
|
||||
});
|
||||
expect(resolveCurrentNeedLabel({
|
||||
blockingReasonCode: 'customer_unresolved',
|
||||
nextActionCode: 'confirm_customer',
|
||||
}, i18n)).toBe('确认客户');
|
||||
});
|
||||
|
||||
it('resolveCurrentNeedLabel falls back to nextActionCode when reason missing', () => {
|
||||
const i18n = makeI18n({
|
||||
'workspace.shippingNotice.processGate.actions.retry_freight_upload_rpa': '重试货代上传',
|
||||
'chat.shippingProcessing.gateReasons.generic': '需要处理',
|
||||
});
|
||||
expect(resolveCurrentNeedLabel({
|
||||
blockingReasonCode: null,
|
||||
nextActionCode: 'retry_freight_upload_rpa',
|
||||
}, i18n)).toBe('重试货代上传');
|
||||
});
|
||||
|
||||
it('resolveCurrentNeedLabel returns empty when gate empty', () => {
|
||||
const i18n = makeI18n({
|
||||
'chat.shippingProcessing.gateReasons.generic': '需要处理',
|
||||
});
|
||||
expect(resolveCurrentNeedLabel(null, i18n)).toBe('');
|
||||
expect(resolveCurrentNeedLabel({ blockingReasonCode: '', nextActionCode: '' }, i18n)).toBe('');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user