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,87 @@
/**
* features/chat/e2e/shipping-conversation-multiple-runs.spec.ts
* 用途:会话多任务聚合阶段 3–5 契约冒烟——发送无确认框、任务分组主路径、WF 非主标题。
* 依赖:Vitest、conversationProcessingProjection、shippingSubmissionFeedback。
* 逻辑:不启浏览器;用投影/反馈纯函数断言产品契约,避免 e2e 环境依赖。
*/
import { describe, expect, it } from 'vitest';
import {
classifyConversationProcessingGroup,
groupConversationProcessingTasks,
projectConversationProcessingTasks,
} from '@/features/chat/shipping/conversationProcessingProjection';
import { buildShippingSubmissionFeedback } from '@/features/chat/shipping/shippingSubmissionFeedback';
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: 'queued',
current_stage: 'queued',
lock_version: 1,
...partial,
};
}
describe('shipping conversation multiple runs e2e contract', () => {
it('maps backend decisions to non-blocking feedback without dialog keys', () => {
const appended = buildShippingSubmissionFeedback({
decision: 'appended',
user_task_no: 'OT-1',
run_no: 'RUN-1',
created_new: false,
}, 2);
const created = buildShippingSubmissionFeedback({
decision: 'created',
user_task_no: 'OT-2',
run_no: 'RUN-2',
created_new: true,
}, 1);
// 关键断言:仅两种决策;短时标签供右侧卡,不依赖确认弹窗。
expect(appended.decision).toBe('appended');
expect(created.decision).toBe('created');
expect([appended.badgeCode, created.badgeCode]).toEqual(['just_appended', 'just_created']);
});
it('keeps WF/run ids as secondary while grouping by user-visible tasks', () => {
const tasks = projectConversationProcessingTasks([
item({
item_no: 'WI-A',
workflow_no: 'WF-AAA',
current_run_no: 'SNER-A',
lifecycle_status: 'pending_review',
}),
item({
item_no: 'WI-B',
workflow_no: 'WF-BBB',
current_run_no: 'SNER-B',
lifecycle_status: 'extracting',
}),
]);
const projection = groupConversationProcessingTasks(tasks);
expect(projection.summary.total_tasks).toBe(2);
expect(projection.needs_action).toHaveLength(1);
expect(projection.processing).toHaveLength(1);
// 关键断言:主对象是 OT-;WF 仅挂在任务上供诊断。
expect(projection.needs_action[0]?.user_task_no.startsWith('OT-')).toBe(true);
expect(projection.needs_action[0]?.workflow_no).toBe('WF-AAA');
expect(classifyConversationProcessingGroup('failed')).toBe('needs_action');
});
it('scales to twenty user-visible tasks without inventing progress percent', () => {
const items = Array.from({ length: 20 }, (_, index) => item({
item_no: `WI-${index}`,
current_run_no: `SNER-${index}`,
lifecycle_status: index % 2 === 0 ? 'extracting' : 'closed',
}));
const projection = groupConversationProcessingTasks(projectConversationProcessingTasks(items));
expect(projection.summary.total_tasks).toBe(20);
expect(projection.summary.processing + projection.summary.history).toBe(20);
expect(JSON.stringify(projection).includes('percent')).toBe(false);
});
});