feat(shipping-notice): 新增通用解析能力,优化性能并清理遗留废弃代码

This commit is contained in:
hugo committed 2026-08-23 00:27:18 +08:00
1 parent 935bf26fa6
commit 7cfd5d167e
230 files changed
+9337 -10989

No files matched your search

@@ -201,6 +201,42 @@ describe('useShippingNoticeWorkflow', () => {
ctl.stop();
});
it('uses summary PDF leaves as the minimal live work items for the batch center', async () => {
api.getShippingProcessing.mockResolvedValue({
conversation_id: 'conv-1',
work_items: [{
workItemType: 'order_task', workItemNo: 'DOCUMENT:1', rootOrderTaskNo: 'OT-1',
sourceType: 'direct_pdf', status: 'processing', stage: 'document_parsing',
sourceSummary: { documentId: 1, filename: 'po.pdf', documentCount: 1 },
}],
conversation_processing: buildProcessing(),
});
const ctl = useShippingNoticeWorkflow({ conversationId: ref('conv-1') });
await vi.advanceTimersByTimeAsync(0);
await Promise.resolve();
expect(ctl.processingWorkItems.value[0]?.sourceSummary.filename).toBe('po.pdf');
ctl.stop();
});
it('applies a current conversation response that completes after 10 seconds', async () => {
const pending = deferred<ReturnType<typeof buildUnifiedProcessing>>();
api.getShippingProcessing.mockImplementation(() => pending.promise);
const ctl = useShippingNoticeWorkflow({ conversationId: ref('conv-1') });
await vi.advanceTimersByTimeAsync(0);
// API 层拥有共享请求的 30 秒超时;10 秒后当前会话不能先把消费者标为取消。
await vi.advanceTimersByTimeAsync(10_001);
pending.resolve(buildUnifiedProcessing('conv-1'));
await Promise.resolve();
await nextTick();
expect(ctl.processing.value?.conversation_id).toBe('conv-1');
expect(ctl.initialLoading.value).toBe(false);
expect(ctl.error.value).toBeNull();
ctl.stop();
});
it('records recoverable error without throwing', async () => {
const conversationId = ref('conv-1');
const ctl = useShippingNoticeWorkflow({ conversationId });
@@ -243,7 +279,7 @@ describe('useShippingNoticeWorkflow', () => {
ctl.stop();
});
it('uses unified work_items as the sole processing read source', async () => {
it('does not rebuild conversation processing from work_items without status_groups', async () => {
api.getShippingProcessing.mockResolvedValue({
conversation_id: 'conv-1',
work_items: [buildOrderTaskWorkItem('OT-UNIFIED', {
@@ -265,12 +301,12 @@ describe('useShippingNoticeWorkflow', () => {
await Promise.resolve();
expect(api.getShippingProcessing).toHaveBeenCalled();
expect(ctl.processingWorkItems.value).toHaveLength(1);
expect(ctl.processing.value?.needs_action[0]?.user_task_no).toBe('OT-UNIFIED');
expect(ctl.processingWorkItems.value).toHaveLength(0);
expect(ctl.processing.value).toBeNull();
ctl.stop();
});
it('preserves previous order_task work_items when stabilizer keeps previous projection', async () => {
it('does not retain a legacy work_items-derived projection across sparse responses', async () => {
api.getShippingProcessing
.mockResolvedValueOnce({
conversation_id: 'conv-1',
@@ -310,21 +346,17 @@ describe('useShippingNoticeWorkflow', () => {
await nextTick();
await Promise.resolve();
expect(ctl.processing.value?.processing[0]?.user_task_no).toBe('OT-STABLE');
expect(ctl.processingWorkItems.value[0]?.workItemType).toBe('order_task');
expect(ctl.processing.value).toBeNull();
await vi.advanceTimersByTimeAsync(2000);
await nextTick();
await Promise.resolve();
expect(ctl.processing.value?.processing[0]?.user_task_no).toBe('OT-STABLE');
expect(ctl.processingWorkItems.value).toHaveLength(1);
expect(ctl.processingWorkItems.value[0]?.workItemType).toBe('order_task');
expect(ctl.processingWorkItems.value[0]?.workItemNo).toBe('OT-STABLE');
expect(ctl.processing.value).toBeNull();
ctl.stop();
});
it('aggregates sibling EML OT work_items into one highest-attention Intake card', async () => {
it('does not aggregate sibling work_items in the browser when status_groups is absent', async () => {
api.getShippingProcessing.mockResolvedValue({
conversation_id: 'conv-1',
work_items: [
@@ -409,15 +441,8 @@ describe('useShippingNoticeWorkflow', () => {
await nextTick();
await Promise.resolve();
expect(ctl.processing.value?.needs_action.map((t) => t.user_task_no)).toEqual(['OT-ROOT']);
expect(ctl.processing.value?.processing).toEqual([]);
expect(ctl.processing.value?.needs_action[0]?.aggregateSummary).toMatchObject({
intakeNo: 'SNI-1',
total: 2,
processing: 1,
});
expect(ctl.processing.value?.focused_task_no).toBe('OT-ROOT');
expect(ctl.processing.value?.recent_task_no).toBe('OT-SIBLING');
expect(ctl.processing.value).toBeNull();
expect(ctl.processingWorkItems.value).toEqual([]);
ctl.stop();
});
@@ -436,7 +461,7 @@ describe('useShippingNoticeWorkflow', () => {
await Promise.resolve();
expect(api.getShippingProcessing).toHaveBeenCalledTimes(2);
expect(ctl.processing.value?.needs_action[0]?.user_task_no).toBe('OT-conv-1');
expect(ctl.processing.value?.status_groups?.waiting_human[0]?.user_task_no).toBe('OT-conv-1');
expect(ctl.error.value).toBeNull();
ctl.stop();
});