feat(shipping-notice): 新增发货通知自动上传功能与候选资格评估

- 在环境配置中新增 SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED 选项,默认关闭,需显式开启以支持自动上传。
- 引入新的 pytest.ini 文件,增加测试标记以支持自动化测试。
- 删除不再使用的 seed_shipping_notice_agents.py 文件,简化代码库。
- 更新相关 API,增强发货通知与候选资格评估功能,支持多种筛选条件。
- 增强文档与代码注释,反映新的业务逻辑与功能要求。
This commit is contained in:
hugo committed 2026-08-02 19:26:35 +08:00
1 parent cef3d5b26a
commit 3a9fbac2fc
226 files changed
+25010 -2098

No files matched your search

@@ -0,0 +1,87 @@
/**
* features/chat/shipping/conversationProcessingProjection.spec.ts
* 用途:验收「本次处理中」对象投影——Run/Candidate/Task/Gate 聚合与聚焦。
* 依赖:Vitest、conversationProcessingProjection。
* 逻辑:构造 WorkflowItem;断言去重、聚焦标记与 Gate 行。
*/
import { describe, expect, it } from 'vitest';
import {
mapLifecycleToNodeStatus,
projectConversationProcessingObjects,
} from './conversationProcessingProjection';
import type { ShippingWorkflowItem } from '@/features/chat/types/shipping.api.types';
function item(partial: Partial<ShippingWorkflowItem>): ShippingWorkflowItem {
return {
item_no: 'WI-1',
workflow_no: 'WF-1',
conversation_id: 'conv-1',
root_document_id: 1,
current_document_id: 1,
current_version_no: 1,
lifecycle_status: 'pending_review',
current_stage: 'pending_review',
lock_version: 1,
...partial,
};
}
describe('conversationProcessingProjection', () => {
it('maps lifecycle to node status without inventing percentages', () => {
expect(mapLifecycleToNodeStatus('inventory_matching')).toBe('running');
expect(mapLifecycleToNodeStatus('failed')).toBe('failed');
expect(mapLifecycleToNodeStatus('closed')).toBe('succeeded');
});
it('projects run / candidate / task / process_gate rows and focus', () => {
const rows = projectConversationProcessingObjects([
item({
item_no: 'WI-1',
current_run_no: 'RUN-1',
current_case_no: 'CASE-1',
current_task_no: 'SN-1',
lifecycle_status: 'pending_review',
process_gate: {
execution_no: 'EX-1',
status: 'blocked',
current_blocking_gate: {
gate_code: 'inventory_matching',
sequence_no: 1,
status: 'blocked_manual',
evaluation_version: 1,
},
task_no: 'SN-1',
},
}),
item({
item_no: 'WI-2',
current_run_no: 'RUN-1',
current_task_no: 'SN-1',
lifecycle_status: 'inventory_matching',
}),
], { focusTaskNo: 'SN-1', focusRunNo: 'RUN-1' });
// 关键断言:同 Run/Task 去重;聚焦 Task;含 Gate。
expect(rows.filter((row) => row.kind === 'run')).toHaveLength(1);
expect(rows.filter((row) => row.kind === 'task')).toHaveLength(1);
expect(rows.find((row) => row.kind === 'task')?.focused).toBe(true);
expect(rows.some((row) => row.kind === 'candidate')).toBe(true);
expect(rows.some((row) => row.kind === 'process_gate')).toBe(true);
});
it('prefers backend node_status over lifecycle mapping for tasks', () => {
const rows = projectConversationProcessingObjects([
item({
current_run_no: 'RUN-2',
current_task_no: 'SN-2',
lifecycle_status: 'inventory_matching',
node_status: 'manual_takeover',
progress_nodes: [
{ code: 'freight_upload', label: '货代上传', status: 'manual_takeover' },
],
}),
]);
// 关键断言:侧栏 Task 使用后端权威 node_status,不覆盖为 running。
expect(rows.find((row) => row.kind === 'task')?.node_status).toBe('manual_takeover');
});
});