feat(shipping-notice): 落地 XFA 统一视觉拆分确认门禁与处理投影收敛

闭合拆分预览令牌单次消费、样本 checksum 绑定与确认审计;正式提取改为 bindings-only。
同步统一标注工作台交互,并补齐进度投影/任务中心与迁移文档。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-06 10:21:25 +08:00
1 parent d2b3d74def
commit 84a881b554
195 files changed
+20269 -3463

No files matched your search

@@ -6,10 +6,13 @@
*/
import { mount } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
import { ref } from 'vue';
import { createI18n } from 'vue-i18n';
import chatZhCn from '@/locales/zh-CN/chat.json';
import ShippingOrderExtractionCard from './ShippingOrderExtractionCard.vue';
import type { ShippingOrderExtractionState } from '../../types/chat.types';
import type { ShippingProcessingProjection } from '../../types/shipping.api.types';
import { SHIPPING_WORKFLOW_KEY } from '../../shipping/useShippingNoticeWorkflow';
const i18n = createI18n({
legacy: false,
@@ -52,6 +55,7 @@ const buildState = (patch: Partial<ShippingOrderExtractionState> = {}): Shipping
describe('ShippingOrderExtractionCard', () => {
it('renders batch summary, current stage, health tip and action buttons', () => {
// 冷启动 transform 较慢时放宽超时,避免首测误伤。
const wrapper = mount(ShippingOrderExtractionCard, {
props: { state: buildState(), runNo: 'SNER-1' },
global: { plugins: [i18n] },
@@ -62,7 +66,7 @@ describe('ShippingOrderExtractionCard', () => {
expect(wrapper.text()).toContain('刷新状态');
expect(wrapper.text()).toContain('取消本次识别');
expect(wrapper.findAll('[data-testid="shipping-order-document-result"]').length).toBe(0);
});
}, 30_000);
it('renders duplicate-linked notice when only open_existing results remain', () => {
const wrapper = mount(ShippingOrderExtractionCard, {
@@ -185,6 +189,149 @@ describe('ShippingOrderExtractionCard', () => {
expect(wrapper.text()).toContain('影响对象:');
expect(wrapper.text()).toContain('ST-88');
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(3);
// 无统一投影时仍允许 handlingItems 主按钮(过渡兜底)。
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-primary-action"]').length).toBeGreaterThan(0);
});
it('hides handling primary actions when unified processing projection is present (UI-01)', () => {
const projection = {
workItemType: 'order_task' as const,
workItemNo: 'OT-UI01',
sourceType: 'direct_pdf' as const,
rootOrderTaskNo: 'OT-UI01',
shippingNoticeNo: null,
conversationId: null,
submissionNo: 'SUB-1',
intakeNo: 'INT-1',
status: 'waiting_review' as const,
stage: 'waiting_review' as const,
progressVersion: 1,
lastActivityAt: '2026-08-05T00:00:00Z',
stageNodes: [],
currentGate: null,
availableActions: ['open_order_review'],
sourceSummary: {
emailSubject: null,
filename: 'PO.pdf',
documentCount: 1,
parsedDocumentCount: 1,
candidateCount: 1,
customerName: null,
poNumber: null,
},
childOrderTasks: [],
};
const wrapper = mount(ShippingOrderExtractionCard, {
props: {
state: buildState({
status: 'review_required',
userTaskNo: 'OT-UI01',
availableActions: ['review_candidate', 'view_details'],
primaryNotice: 'candidate_confirmation',
handlingItems: [
{
category: 'candidate_confirmation',
count: 1,
reasonCodes: [],
affectedRefs: [],
primaryAction: 'review_candidate',
},
{
category: 'parse_failed',
count: 1,
reasonCodes: ['layout_failed'],
affectedRefs: [],
primaryAction: 'retry_failed_documents',
},
],
healthTips: [],
currentActivity: null,
}),
runNo: 'SNER-UI01',
processingProjection: projection,
},
global: {
plugins: [i18n],
stubs: {
ChatProgressSummary: true,
ProcessGateRecoveryCard: true,
'router-link': true,
},
},
});
// 主操作只来自投影 Presenter;已被 Gate/进度表达的 handling 项不重复列出。
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-primary-action"]').length).toBe(0);
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(1);
});
it('renders one unified progress summary for each PDF under the same root task', () => {
const buildWorkItem = (
taskNo: string,
filename: string,
documentId: number,
): ShippingProcessingProjection => ({
workItemType: 'order_task',
workItemNo: taskNo,
sourceType: 'direct_pdf',
rootOrderTaskNo: 'OT-ROOT',
shippingNoticeNo: null,
conversationId: 'conv-1',
submissionNo: 'SUB-1',
intakeNo: 'INT-1',
status: 'processing',
stage: 'document_parsing',
progressVersion: 1,
lastActivityAt: '2026-08-06T00:00:00Z',
currentGate: null,
availableActions: ['view_details'],
sourceSummary: {
emailSubject: null,
filename,
documentId,
documentCount: 1,
parsedDocumentCount: 1,
candidateCount: 1,
customerName: null,
poNumber: null,
},
childOrderTasks: [],
});
const workItems = [
buildWorkItem('OT-ROOT', 'PO-001.pdf', 1),
buildWorkItem('OT-CHILD', 'PO-002.pdf', 2),
];
const wrapper = mount(ShippingOrderExtractionCard, {
props: {
state: buildState({ userTaskNo: 'OT-ROOT' }),
runNo: 'SNER-MULTI-PDF',
},
global: {
plugins: [i18n],
provide: {
[SHIPPING_WORKFLOW_KEY as symbol]: {
processing: ref(null),
processingWorkItems: ref(workItems),
loading: ref(false),
error: ref(null),
refresh: async () => undefined,
focusConversationTask: async () => undefined,
markConversationTaskViewed: async () => undefined,
stop: () => undefined,
},
},
stubs: {
ChatProgressSummary: {
props: ['projection'],
template: '<div data-testid="chat-progress-summary">{{ projection.workItemNo }}</div>',
},
ProcessGateRecoveryCard: true,
},
},
});
expect(wrapper.findAll('[data-testid="chat-progress-summary"]')).toHaveLength(2);
expect(wrapper.text()).toContain('PO-001.pdf');
expect(wrapper.text()).toContain('PO-002.pdf');
});
it('emits cancel after confirmation', async () => {