把 shipping 侧 inventory/receipt 词根迁到 onhand/inbound,29 张表与 枚举/权限/前端/i18n 同步改名;在手与入站报表配置及文件改由 freight_rpa 持有,发货与调拨仅按 source_code 消费;ORM 类加 FreightRpa 前缀, 上传动作改为 freight_rpa_upload。含类名与上传动作改名规格文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
2.1 KiB
TypeScript
52 lines
2.1 KiB
TypeScript
/**
|
|
* features/chat/shipping/shippingStepper.spec.ts
|
|
* 用途:验证发货通知五阶段 Stepper 只消费后端 UI State 投影。
|
|
* 依赖:shippingStepper 纯函数、vitest。
|
|
* 逻辑:后端 UI State 缺失时,前端仍需把关键人工介入态渲染为 blocked。
|
|
*/
|
|
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
applyShippingProcessingStageToSteps,
|
|
normalizeShippingWorkflowSteps,
|
|
resolveShippingWorkflowSteps,
|
|
} from './shippingStepper';
|
|
|
|
describe('shippingStepper', () => {
|
|
it('renders exactly five 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: 'freight_upload', label: '货代上传', status: 'pending' },
|
|
{ id: 'shipping-stage-5', code: 'upload_complete', label: '通知完成', status: 'pending' },
|
|
],
|
|
},
|
|
});
|
|
|
|
expect(steps).toHaveLength(5);
|
|
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('maps technical processing stages into the five business stages', () => {
|
|
const base = normalizeShippingWorkflowSteps([
|
|
{ code: 'intake_parse', status: 'pending' },
|
|
{ code: 'order_review', status: 'pending' },
|
|
{ code: 'fulfillment_prep', status: 'pending' },
|
|
{ code: 'freight_upload', status: 'pending' },
|
|
{ code: 'upload_complete', status: 'pending' },
|
|
]);
|
|
const steps = applyShippingProcessingStageToSteps(base, {
|
|
stage: 'onhand_matching',
|
|
status: 'running',
|
|
});
|
|
expect(steps.map((step) => step.status)).toEqual(['completed', 'completed', 'current', 'pending', 'pending']);
|
|
});
|
|
});
|