feat(shipping-notice): 新增通用解析能力,优化性能并清理遗留废弃代码
This commit is contained in:
1 parent
935bf26fa6
commit
7cfd5d167e
230 files changed
+9337
-10989
No files matched your search
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* features/chat/shipping-review/showReviewResumeOutcome.spec.ts
|
||||
* 用途:验证复核保存后的后端入队结果会被明确展示,避免用户误以为校验后没有推进。
|
||||
* 依赖:Vitest、showReviewResumeOutcome。
|
||||
* 逻辑:队列状态统一提示已入队;其他结果保持既有自动建单和兜底提示。
|
||||
*/
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { showReviewResumeOutcome } from './showReviewResumeOutcome';
|
||||
|
||||
const translate = (key: string, values?: Record<string, unknown>) => (
|
||||
values?.taskNo ? `${key}:${values.taskNo}` : key
|
||||
);
|
||||
|
||||
describe('showReviewResumeOutcome', () => {
|
||||
it.each(['auto_create_enqueued', 'already_queued', 'already_running'])(
|
||||
'shows the queued progression message for %s',
|
||||
(outcome) => {
|
||||
const success = vi.fn();
|
||||
showReviewResumeOutcome({ outcome }, { success }, translate);
|
||||
|
||||
// 关键断言:用户必须看到后端已接收自动建单,而非泛化的保存成功。
|
||||
expect(success).toHaveBeenCalledWith('chat.shippingOrderReview.resume.autoCreateEnqueued');
|
||||
},
|
||||
);
|
||||
|
||||
it('keeps the explicit auto-created message for synchronous creation', () => {
|
||||
const success = vi.fn();
|
||||
showReviewResumeOutcome({ outcome: 'auto_created', task_no: 'OT-1' }, { success }, translate);
|
||||
expect(success).toHaveBeenCalledWith('chat.shippingOrderReview.resume.autoCreated:OT-1');
|
||||
});
|
||||
|
||||
it.each(['waiting_manual_confirm', 'blocked'])('uses warning for non-success outcome %s', (outcome) => {
|
||||
const success = vi.fn();
|
||||
const warning = vi.fn();
|
||||
showReviewResumeOutcome({ outcome }, { success, warning }, translate, '保存成功');
|
||||
|
||||
// 关键断言:保存完成不等于自动建单完成,阻断状态不得显示绿色成功。
|
||||
expect(success).not.toHaveBeenCalled();
|
||||
expect(warning).toHaveBeenCalledWith(`chat.shippingOrderReview.resume.${outcome === 'blocked' ? 'blocked' : 'waitingManualConfirm'}`);
|
||||
});
|
||||
|
||||
it('uses fallback success only when backend has no resume outcome', () => {
|
||||
const success = vi.fn();
|
||||
const warning = vi.fn();
|
||||
showReviewResumeOutcome(null, { success, warning }, translate, '保存成功');
|
||||
expect(success).toHaveBeenCalledWith('保存成功');
|
||||
expect(warning).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user