feat(shipping-notice): 新增库存快照管理与RPA批量导出功能

This commit is contained in:
hugo committed 2026-07-08 08:59:08 +08:00
1 parent fc694a8f43
commit d54f51ddc3
48 files changed
+4970 -543

No files matched your search

@@ -0,0 +1,32 @@
/**
* features/chat/shipping/shippingStepper.spec.ts
* 用途:验证发货通知七步 Stepper 的本地兜底状态映射。
* 依赖:shippingStepper 纯函数、vitest。
* 逻辑:后端 UI State 缺失时,前端仍需把关键人工介入态渲染为 blocked。
*/
import { describe, expect, it } from 'vitest';
import { buildShippingWorkflowSteps } from './shippingStepper';
describe('shippingStepper', () => {
it('marks inventory step as blocked when RPA inventory is exhausted', () => {
// 关键断言:库存 RPA 获取失败是业务阻断态,不能在步骤条里继续显示为普通 current。
const steps = buildShippingWorkflowSteps({
process_status: 'waiting_inventory',
pending_human_reason: 'rpa_exhausted',
current_step: 'step3_inventory_prepare',
});
expect(steps[2]?.status).toBe('blocked');
});
it('marks inventory step as blocked when inventory source is unavailable', () => {
// 关键断言:库存触发失败需要用户上传库存或重试,同样应在第 3 步显示异常。
const steps = buildShippingWorkflowSteps({
process_status: 'waiting_inventory',
pending_human_reason: 'inv_unavail',
current_step: 'step3_inventory_prepare',
});
expect(steps[2]?.status).toBe('blocked');
});
});
@@ -160,6 +160,7 @@ export function buildShippingWorkflowSteps(
if (
(index === 1 && (reviewStatus === 'parse_review' || pendingReason === 'low_confidence' || pendingReason === 'rsv_required'))
|| (index === 2 && (pendingReason === 'inv_unavail' || pendingReason === 'rpa_exhausted'))
|| (index === 3 && (reviewStatus === 'align_review' || pendingReason === 'align_review'))
|| (index === 4 && (reviewStatus === 'shortage_review' || pendingReason === 'shortage_review' || pendingReason === 'shortage'))
|| (index === 6 && processStatus === 'upload_failed')
@@ -84,12 +84,11 @@ describe('shippingText', () => {
it('hides manual retry count in user-facing runtime copy', () => {
// 关键断言:前台状态文案不暴露“第几次重试”,只保留当前状态本身。
const result = sanitizeShippingConversationText(
'已手动重新触发 RPA 库存导出(手动第 2 次)。\n任务编号:SN-002',
'已重新触发库存获取(第 2 次)。\n任务编号:SN-002',
true,
);
expect(result).toContain('已重新触发库存获取。');
expect(result).not.toContain('手动第 2 次');
expect(result).not.toContain('第 2 次');
});
@@ -45,6 +45,14 @@ export function sanitizeShippingRuntimeStatusText(text: string): string {
/已手动重新触发\s*RPA\s*库存导出\s*[((]\s*(?:手动第\s*\d+\s*次(?:尝试)?|第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?)\s*[))]\s*[。.]?/gi,
'已重新触发库存获取。',
)
.replace(
/已重新触发库存获取\s*[((]\s*第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?\s*[))]\s*[。.]?/gi,
'已重新触发库存获取。',
)
.replace(
/已触发库存获取\s*[((]\s*第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?\s*[))]\s*[。.]?/gi,
'已触发库存获取。',
)
.replace(
/已触发\s*RPA\s*库存导出\s*[((]\s*第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?\s*[))]\s*[。.]?/gi,
'已触发库存获取。',