refactor(shipping-notice): 重构货代发货通知状态管理,移除废弃的process_status字段
统一货代发货通知的业务阶段为四个标准阶段:接收解析、订单复核、发货准备、上传完成 设置 ui_state 为前端唯一状态数据源,不再依赖 process_status 驱动业务流程 删除 shipping_notices 表的废弃 process_status 列及对应复合索引,新增数据库迁移脚本 替换全栈代码中所有对 process_status 的引用为生命周期、上传状态等领域字段 更新相关文档、测试用例与前端展示逻辑适配新的状态管理规则
This commit is contained in:
1 parent
6684e7181a
commit
5ef8329bd8
178 files changed
+5091
-1734
No files matched your search
@@ -1,50 +1,49 @@
|
||||
/**
|
||||
* features/chat/shipping/shippingStepper.spec.ts
|
||||
* 用途:验证发货通知七步 Stepper 的本地兜底状态映射。
|
||||
* 用途:验证发货通知四阶段 Stepper 只消费后端 UI State 投影。
|
||||
* 依赖:shippingStepper 纯函数、vitest。
|
||||
* 逻辑:后端 UI State 缺失时,前端仍需把关键人工介入态渲染为 blocked。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
applyShippingProcessingStageToSteps,
|
||||
buildShippingWorkflowSteps,
|
||||
normalizeShippingWorkflowSteps,
|
||||
resolveShippingWorkflowSteps,
|
||||
} 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',
|
||||
it('renders exactly four stages from backend ui_state', () => {
|
||||
const steps = resolveShippingWorkflowSteps({
|
||||
ui_state: {
|
||||
steps: [
|
||||
{ id: 'shipping-stage-1', code: 'intake_parse', label: '接收解析', status: 'completed' },
|
||||
{ id: 'shipping-stage-2', code: 'order_review', label: '订单复核', status: 'completed' },
|
||||
{ id: 'shipping-stage-3', code: 'fulfillment_prep', label: '发货准备', status: 'blocked' },
|
||||
{ id: 'shipping-stage-4', code: 'upload_complete', label: '上传完成', status: 'pending' },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(steps).toHaveLength(4);
|
||||
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');
|
||||
it('fails closed when backend ui_state is missing', () => {
|
||||
expect(resolveShippingWorkflowSteps({ review_status: 'parse_review' } as never)).toEqual([]);
|
||||
expect(normalizeShippingWorkflowSteps(null)).toEqual([]);
|
||||
});
|
||||
|
||||
it('overlays unified processing stage onto base stepper steps', () => {
|
||||
const base = buildShippingWorkflowSteps({
|
||||
process_status: 'parsed',
|
||||
current_step: 'step2_parse_confirm',
|
||||
it('maps technical processing stages into the four business stages', () => {
|
||||
const base = normalizeShippingWorkflowSteps([
|
||||
{ code: 'intake_parse', status: 'pending' },
|
||||
{ code: 'order_review', status: 'pending' },
|
||||
{ code: 'fulfillment_prep', status: 'pending' },
|
||||
{ code: 'upload_complete', status: 'pending' },
|
||||
]);
|
||||
const steps = applyShippingProcessingStageToSteps(base, {
|
||||
stage: 'inventory_matching',
|
||||
status: 'running',
|
||||
});
|
||||
const overlaid = applyShippingProcessingStageToSteps(base, {
|
||||
status: 'waiting_review',
|
||||
stage: 'waiting_review',
|
||||
currentGate: { status: 'blocked' },
|
||||
});
|
||||
// 关键断言:统一投影 waiting_review 应把第 2 步标为 blocked,而非沿用旧 process_status。
|
||||
expect(overlaid[1]?.status).toBe('blocked');
|
||||
expect(overlaid[0]?.status).toBe('completed');
|
||||
expect(steps.map((step) => step.status)).toEqual(['completed', 'completed', 'current', 'pending']);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user