feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-06 10:18:37 +08:00
1 parent 3a9fbac2fc
commit d2b3d74def
571 files changed
+78064 -24681

No files matched your search

@@ -0,0 +1,72 @@
/**
* features/chat/shipping/normalizeShippingProcessing.spec.ts
* 用途:验收 snake_case → camelCase 规范与缺字段安全默认。
* 依赖:Vitest、normalizeShippingProcessing。
*/
import { describe, expect, it } from 'vitest';
import {
normalizeShippingProcessingProjection,
normalizeShippingProcessingWorkItems,
} from './normalizeShippingProcessing';
describe('normalizeShippingProcessingProjection', () => {
it('maps snake_case backend payload to camelCase DTO', () => {
const normalized = normalizeShippingProcessingProjection({
work_item_type: 'order_task',
work_item_no: 'OT-1',
source_type: 'direct_pdf',
root_order_task_no: 'OT-1',
shipping_notice_no: null,
conversation_id: 'conv-1',
submission_no: 'SOS-1',
intake_no: 'SNI-1',
status: 'waiting_review',
stage: 'waiting_review',
progress_version: 3,
last_activity_at: '2026-08-04T12:00:00Z',
current_gate: {
gate_code: 'field_conflict_resolution',
status: 'blocked',
next_action_code: 'resolve_field_conflicts',
blocking_reason_code: 'pdf_preferred_critical_conflict',
attempt_no: 1,
},
available_actions: ['open_review'],
source_summary: {
email_subject: null,
filename: 'a.pdf',
document_count: 1,
parsed_document_count: 1,
candidate_count: 1,
customer_name: 'ACME',
po_number: 'PO-1',
failure_reason_code: null,
parse_attempt_count: 0,
asset_status: 'ready',
},
child_order_tasks: [],
});
expect(normalized).not.toBeNull();
expect(normalized!.workItemNo).toBe('OT-1');
expect(normalized!.sourceType).toBe('direct_pdf');
expect(normalized!.status).toBe('waiting_review');
expect(normalized!.currentGate?.gateCode).toBe('field_conflict_resolution');
expect(normalized!.currentGate?.attemptNo).toBe(1);
expect(normalized!.sourceSummary.filename).toBe('a.pdf');
expect(normalized!.sourceSummary.assetStatus).toBe('ready');
expect(normalized!.availableActions).toEqual(['open_review']);
});
it('returns null when work_item_no missing', () => {
expect(normalizeShippingProcessingProjection({ status: 'processing' })).toBeNull();
});
it('normalizes work_items arrays', () => {
const items = normalizeShippingProcessingWorkItems([
{ work_item_no: 'OT-A', work_item_type: 'order_task', status: 'processing', stage: 'document_parsing' },
{ status: 'processing' },
]);
expect(items).toHaveLength(1);
expect(items[0].workItemNo).toBe('OT-A');
});
});