1169 lines
56 KiB
TypeScript
1169 lines
56 KiB
TypeScript
/**
|
|
* features/chat/components/shipping/ShippingOrderExtractionCard.spec.ts
|
|
* 用途:覆盖对话区订单识别摘要卡——标题、状态行、handling 一行摘要、唯一主 CTA、查看详情。
|
|
* 依赖:Vitest、Vue Test Utils、vue-i18n、本域组件与 DTO 类型。
|
|
* 逻辑:断言不再渲染进度列表/刷新取消/完整 handling 卡片;失败重试与需处理继续处理互斥。
|
|
*/
|
|
import { mount } from '@vue/test-utils';
|
|
import { ref } from 'vue';
|
|
import { describe, expect, it } from 'vitest';
|
|
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 { SHIPPING_WORKFLOW_KEY } from '../../shipping/useShippingNoticeWorkflow';
|
|
|
|
const i18n = createI18n({
|
|
legacy: false,
|
|
locale: 'zh-CN',
|
|
messages: {
|
|
'zh-CN': {
|
|
chat: chatZhCn,
|
|
},
|
|
},
|
|
});
|
|
|
|
const buildState = (patch: Partial<ShippingOrderExtractionState> = {}): ShippingOrderExtractionState => ({
|
|
status: 'processing',
|
|
summary: {
|
|
totalDocuments: 3,
|
|
pendingDocuments: 0,
|
|
processingDocuments: 1,
|
|
completedDocuments: 1,
|
|
reviewRequiredDocuments: 1,
|
|
failedDocuments: 0,
|
|
cancelledDocuments: 0,
|
|
candidateCount: 2,
|
|
},
|
|
currentActivity: {
|
|
unitId: 12,
|
|
fileName: 'PO-450003.pdf',
|
|
eventCode: 'extracting',
|
|
userVisibleStage: 'extracting',
|
|
elapsedSeconds: 75,
|
|
},
|
|
availableActions: ['refresh_status', 'cancel_run', 'view_details'],
|
|
healthTips: [{ code: 'processing_slow', thresholdSeconds: 60, idleOrElapsedSeconds: 90 }],
|
|
terminal: false,
|
|
refreshFailed: false,
|
|
errorCode: null,
|
|
startedAt: null,
|
|
finishedAt: null,
|
|
...patch,
|
|
});
|
|
|
|
describe('ShippingOrderExtractionCard', () => {
|
|
it('opens the authoritative conversation batch even when no single run number is available', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState() },
|
|
global: {
|
|
plugins: [i18n],
|
|
provide: {
|
|
[SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({
|
|
status_groups: {
|
|
failed: [], waiting_human: [], processing: [{
|
|
user_task_no: 'INTAKE:SNI-BATCH', title: 'batch.eml', file_count: 1,
|
|
userGroup: 'processing', group: 'processing', aggregateChildren: [],
|
|
}], completed: [], cancelled: [], archived: [],
|
|
},
|
|
}),
|
|
processingWorkItems: ref([]),
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
|
|
});
|
|
|
|
it('does not present historical handling items or CTA as current work when the live projection exists', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
status: 'review_required',
|
|
availableActions: ['review_candidate'],
|
|
primaryNotice: 'candidate_confirmation',
|
|
handlingItems: [{
|
|
category: 'candidate_confirmation', count: 2, reasonCodes: [],
|
|
affectedRefs: [], primaryAction: 'review_candidate',
|
|
}],
|
|
}),
|
|
},
|
|
global: {
|
|
plugins: [i18n],
|
|
provide: {
|
|
[SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({
|
|
ui_state: { status: 'running' },
|
|
summary: { total_files: 1, completed_files: 0, waiting_human_files: 0, failed_files: 0 },
|
|
status_groups: {
|
|
failed: [], waiting_human: [], processing: [{
|
|
user_task_no: 'OT-LIVE', title: 'live.pdf', file_count: 1,
|
|
userGroup: 'processing', group: 'processing', aggregateChildren: [],
|
|
}], completed: [], cancelled: [], archived: [],
|
|
},
|
|
}),
|
|
processingWorkItems: ref([]),
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(wrapper.text()).not.toContain('候选待人工确认');
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-handling-summary"]').exists()).toBe(false);
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
|
|
});
|
|
|
|
it('collapses file-level progress when the batch workbench is open', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState(), runNo: 'SNER-COMPACT', compactProgress: true },
|
|
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processingWorkItems: ref([]) } } },
|
|
});
|
|
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-status-groups"]').exists()).toBe(false);
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
|
|
});
|
|
|
|
it('uses unified EML aggregation and keeps candidate creation out of completed', async () => {
|
|
const aggregate = {
|
|
workItemType: 'order_task', workItemNo: 'INTAKE:SNI-1', sourceType: 'eml', rootOrderTaskNo: 'OT-1',
|
|
shippingNoticeNo: null, runNo: 'SNER-EML', caseNo: null, conversationId: 'conv-1', submissionNo: 'SOS-1', intakeNo: 'SNI-1',
|
|
status: 'processing', stage: 'candidate_creating', progressVersion: 1, lastActivityAt: '', currentGate: null, availableActions: [],
|
|
sourceSummary: { emailSubject: null, filename: 'forwarder.eml', documentCount: 3, parsedDocumentCount: 3, candidateCount: 2, customerName: null, poNumber: null }, childOrderTasks: [],
|
|
userStatus: 'running', userStage: 'candidate_creating', facts: { uploadState: 'not_created' },
|
|
aggregateSummary: { intakeNo: 'SNI-1', total: 3, completed: 1, processing: 1, needsAction: 0, failed: 1, stages: ['completed', 'candidate_creating'], reasonCodes: ['upload_rpa_failed'] },
|
|
aggregateChildren: [
|
|
{ workItemType: 'order_task', workItemNo: 'OT-1', sourceType: 'eml', rootOrderTaskNo: 'OT-1', shippingNoticeNo: null, runNo: 'SNER-EML', caseNo: null, conversationId: 'conv-1', submissionNo: 'SOS-1', intakeNo: 'SNI-1', status: 'completed', stage: 'completed', progressVersion: 1, lastActivityAt: '', currentGate: null, availableActions: [], sourceSummary: { emailSubject: null, filename: 'done.pdf', documentCount: 1, parsedDocumentCount: 1, candidateCount: 1, customerName: null, poNumber: null }, childOrderTasks: [], userStatus: 'completed', userStage: 'completed', facts: { uploadState: 'succeeded' } },
|
|
{ workItemType: 'order_task', workItemNo: 'OT-2', sourceType: 'eml', rootOrderTaskNo: 'OT-1', shippingNoticeNo: null, runNo: 'SNER-EML', caseNo: null, conversationId: 'conv-1', submissionNo: 'SOS-1', intakeNo: 'SNI-1', status: 'processing', stage: 'candidate_creating', progressVersion: 1, lastActivityAt: '', currentGate: null, availableActions: [], sourceSummary: { emailSubject: null, filename: 'candidate.pdf', documentCount: 1, parsedDocumentCount: 1, candidateCount: 1, customerName: null, poNumber: null }, childOrderTasks: [], userStatus: 'running', userStage: 'candidate_creating', facts: { uploadState: 'not_created' } },
|
|
],
|
|
} as any;
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState(), runNo: 'SNER-EML' },
|
|
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processingWorkItems: ref([aggregate]) } } },
|
|
});
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-eml-aggregate"]').text()).toContain('已上传完成 1 · 处理中 1 · 异常 1');
|
|
expect(wrapper.text()).not.toContain('已生成候选 3 个文件');
|
|
await wrapper.get('[data-testid="shipping-order-extraction-eml-aggregate"] button').trigger('click');
|
|
expect(wrapper.text()).toContain('candidate.pdf');
|
|
expect(wrapper.text()).toContain('处理中 1');
|
|
});
|
|
|
|
it('keeps historical candidate-ready attachments under their EML instead of creating a candidate group', () => {
|
|
const currentPdfRows = ['4210020274.pdf', '4210020272.pdf', '4210020273.pdf'].map((fileName, index) => ({
|
|
unitId: index + 1,
|
|
documentId: index + 101,
|
|
intakeId: 1,
|
|
documentType: 'attachment',
|
|
fileName,
|
|
status: 'candidate_ready' as const,
|
|
userVisibleStage: 'candidate_ready',
|
|
reasonCode: null,
|
|
}));
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
runNo: 'SNER-STALE-COUNTS',
|
|
state: buildState({
|
|
// 历史 Run/Case 累计不能污染当前邮件的三份有效 PDF 统计。
|
|
summary: {
|
|
totalDocuments: 20,
|
|
pendingDocuments: 0,
|
|
processingDocuments: 0,
|
|
completedDocuments: 2,
|
|
reviewRequiredDocuments: 21,
|
|
failedDocuments: 0,
|
|
cancelledDocuments: 0,
|
|
candidateCount: 3,
|
|
},
|
|
documents: currentPdfRows,
|
|
}),
|
|
},
|
|
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processingWorkItems: ref([]) } } },
|
|
});
|
|
|
|
// 旧快照缺少会话级用户状态;candidate_ready 只能作为附件阶段,不能升格为顶层分组。
|
|
expect(wrapper.text()).toContain('共 3 个文件');
|
|
expect(wrapper.text()).not.toContain('已处理');
|
|
expect(wrapper.text()).not.toContain('已生成候选 3 个文件');
|
|
expect(wrapper.text()).toContain('4210020274.pdf');
|
|
expect(wrapper.text()).not.toContain('23/20 已处理');
|
|
expect(wrapper.text()).not.toContain('100% 完成');
|
|
});
|
|
|
|
it('keeps its matched EML card when the side-panel poll temporarily omits the intake', async () => {
|
|
const workItems = ref<any[]>([{
|
|
workItemType: 'order_task', workItemNo: 'INTAKE:SNI-STABLE', sourceType: 'eml', rootOrderTaskNo: 'OT-STABLE',
|
|
shippingNoticeNo: null, runNo: 'SNER-STABLE', caseNo: null, conversationId: 'conv-1', submissionNo: 'SOS-1', intakeNo: 'SNI-STABLE',
|
|
status: 'processing', stage: 'candidate_creating', progressVersion: 1, lastActivityAt: '', currentGate: null, availableActions: [],
|
|
sourceSummary: { emailSubject: null, filename: 'stable.eml', documentCount: 2, parsedDocumentCount: 2, candidateCount: 0, customerName: null, poNumber: null },
|
|
childOrderTasks: [], userStatus: 'running', userStage: 'candidate_creating', facts: { uploadState: 'not_created' },
|
|
aggregateSummary: { intakeNo: 'SNI-STABLE', total: 2, completed: 0, processing: 2, needsAction: 0, failed: 0, stages: ['candidate_creating'], reasonCodes: [] },
|
|
aggregateChildren: [],
|
|
}]);
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState(), runNo: 'SNER-STABLE' },
|
|
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processingWorkItems: workItems } } },
|
|
});
|
|
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-eml-aggregate"]').text()).toContain('stable.eml');
|
|
// 关键断言:右侧轮询暂时省略本 Intake 时,中间消息卡仍保留其自身的 EML 形态。
|
|
workItems.value = [];
|
|
await wrapper.vm.$nextTick();
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-eml-aggregate"]').text()).toContain('stable.eml');
|
|
});
|
|
|
|
it('does not render a historical EML snapshot while the authoritative conversation projection is loading', () => {
|
|
const historicalAggregate = {
|
|
workItemType: 'order_task', workItemNo: 'INTAKE:SNI-HISTORY', sourceType: 'eml', intakeNo: 'SNI-HISTORY',
|
|
sourceSummary: { filename: 'historical.eml', documentCount: 3 },
|
|
aggregateSummary: { intakeNo: 'SNI-HISTORY', total: 3, completed: 0, processing: 3, needsAction: 0, failed: 0, stages: [], reasonCodes: [] },
|
|
aggregateChildren: [],
|
|
} as any;
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState(), runNo: 'SNER-HISTORY' },
|
|
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref(null),
|
|
processingWorkItems: ref([historicalAggregate]),
|
|
initialLoading: ref(true),
|
|
loading: ref(true),
|
|
} } },
|
|
});
|
|
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-eml-aggregate"]').exists()).toBe(false);
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-projection-loading"]').exists()).toBe(true);
|
|
expect(wrapper.text()).not.toContain('historical.eml');
|
|
expect(wrapper.text()).not.toContain('系统处理中');
|
|
});
|
|
|
|
it('does not fall back to one Run file when the authoritative conversation projection has not returned', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState({ summary: { ...buildState().summary, totalDocuments: 1 } }), runNo: 'SNER-SINGLE' },
|
|
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
// 真实会话工作流已建立但读取超时/失败时,不能将最近 Run 的单文件当作整个批次。
|
|
processing: ref(null),
|
|
processingWorkItems: ref([]),
|
|
initialLoading: ref(false),
|
|
} } },
|
|
});
|
|
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-projection-loading"]').exists()).toBe(true);
|
|
expect(wrapper.text()).not.toContain('共 1 个文件');
|
|
});
|
|
|
|
it('does not render message document rows while the authoritative projection is loading', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState({
|
|
documents: [{
|
|
unitId: 91,
|
|
documentId: 191,
|
|
documentType: 'attachment',
|
|
fileName: 'message-snapshot.pdf',
|
|
status: 'review_required',
|
|
}],
|
|
}) },
|
|
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref(null),
|
|
processingWorkItems: ref([]),
|
|
initialLoading: ref(true),
|
|
loading: ref(true),
|
|
} } },
|
|
});
|
|
|
|
expect(wrapper.text()).not.toContain('message-snapshot.pdf');
|
|
expect(wrapper.text()).not.toContain('系统处理中');
|
|
});
|
|
|
|
it('expands an EML inside its status group and shows every child attachment state', async () => {
|
|
const child = {
|
|
workItemType: 'order_task', workItemNo: 'OT-CHILD-1', sourceType: 'eml', rootOrderTaskNo: 'OT-ROOT',
|
|
shippingNoticeNo: null, runNo: 'SNER-DETAIL', caseNo: null, conversationId: 'conv-1', submissionNo: 'SOS-1', intakeNo: 'SNI-DETAIL',
|
|
status: 'failed', stage: 'document_parsing', progressVersion: 1, lastActivityAt: '', currentGate: null, availableActions: [],
|
|
sourceSummary: { emailSubject: null, filename: 'failed.pdf', documentCount: 1, parsedDocumentCount: 0, candidateCount: 0, customerName: null, poNumber: null },
|
|
childOrderTasks: [], userStatus: 'running', userStage: 'document_parsing', facts: { uploadState: 'not_created' },
|
|
// 后端新裁决与旧 userStatus 冲突时,摘要卡必须使用 ui_state,不能显示成“处理中”。
|
|
uiState: { status: 'failed', stage: 'document_parsing', blocking_reason: { code: 'PARSE_FAILED' }, primary_action: null, secondary_actions: [] },
|
|
blockingReason: { code: 'PARSE_FAILED' },
|
|
} as any;
|
|
const task = { user_task_no: 'INTAKE:SNI-DETAIL', title: 'mail.eml', file_count: 1, userGroup: 'failed', group: 'needs_action', aggregateChildren: [child], aggregateSummary: { intakeNo: 'SNI-DETAIL', total: 1, completed: 0, processing: 0, needsAction: 0, failed: 1, stages: ['document_parsing'], reasonCodes: ['PARSE_FAILED'] } } as any;
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState(), runNo: 'SNER-DETAIL' },
|
|
global: {
|
|
plugins: [i18n],
|
|
provide: {
|
|
[SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({ status_groups: { failed: [task], waiting_human: [], processing: [], completed: [], cancelled: [], archived: [] } }),
|
|
processingWorkItems: ref([]),
|
|
},
|
|
},
|
|
},
|
|
});
|
|
await wrapper.get('[data-testid="shipping-order-extraction-eml-failed-INTAKE:SNI-DETAIL"] button').trigger('click');
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-eml-children"]').text()).toContain('failed.pdf');
|
|
expect(wrapper.text()).toContain('异常 1');
|
|
// 通用兜底原因(当前步骤需要人工处理)与右侧状态芯片语义重复,统一隐藏。
|
|
expect(wrapper.text()).not.toContain('当前步骤需要人工处理');
|
|
expect(wrapper.text()).not.toContain('PARSE_FAILED');
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-child-status-OT-CHILD-1"]')
|
|
.classes()).toContain('text-rose-600');
|
|
});
|
|
|
|
it('splits a mixed-status EML into its matching status sections', async () => {
|
|
const completedA = {
|
|
workItemNo: 'DOCUMENT:4210022658', sourceSummary: { filename: '4210022658.pdf', documentId: 2658 },
|
|
userStatus: 'completed', status: 'completed', uiState: { status: 'completed', stage: 'completed' },
|
|
} as any;
|
|
const completedB = {
|
|
workItemNo: 'DOCUMENT:4210022657', sourceSummary: { filename: '4210022657.pdf', documentId: 2657 },
|
|
userStatus: 'completed', status: 'completed', uiState: { status: 'completed', stage: 'completed' },
|
|
} as any;
|
|
const processing = {
|
|
workItemNo: 'DOCUMENT:4210022656', sourceSummary: { filename: '4210022656.pdf', documentId: 2656 },
|
|
userStatus: 'running', status: 'processing', uiState: { status: 'processing', stage: 'freight_upload' },
|
|
} as any;
|
|
// 模拟热更新前/兼容后端仍把三份 PDF 放在 completed EML 根行的真实输入。
|
|
const mixedTask = {
|
|
user_task_no: 'INTAKE:SNI-HOXIN', title: 'NEW PO HOXIN.eml', file_count: 3,
|
|
userGroup: 'completed', group: 'completed',
|
|
aggregateChildren: [completedA, completedB, processing],
|
|
aggregateSummary: { intakeNo: 'SNI-HOXIN', total: 3, completed: 2, processing: 1, needsAction: 0, failed: 0, stages: [], reasonCodes: [] },
|
|
} as any;
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState() },
|
|
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({ status_groups: { failed: [], waiting_human: [], processing: [], completed: [mixedTask], cancelled: [], archived: [] } }),
|
|
processingWorkItems: ref([]),
|
|
} } },
|
|
});
|
|
|
|
const completedSection = wrapper.findAll('[data-testid="shipping-order-extraction-status-groups"] section')
|
|
.find((section) => section.text().includes('已完成'))!;
|
|
await completedSection.get('button').trigger('click');
|
|
await wrapper.get('[data-testid="shipping-order-extraction-eml-completed-INTAKE:SNI-HOXIN"] button').trigger('click');
|
|
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-eml-completed-INTAKE:SNI-HOXIN"]').text()).toContain('2 个文件');
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-eml-completed-INTAKE:SNI-HOXIN"]').text()).toContain('4210022658.pdf');
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-eml-completed-INTAKE:SNI-HOXIN"]').text()).not.toContain('4210022656.pdf');
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-eml-processing-INTAKE:SNI-HOXIN"]').text()).toContain('4210022656.pdf');
|
|
});
|
|
|
|
it('does not supplement an authoritative EML group from a second work-item snapshot', async () => {
|
|
const child = {
|
|
workItemType: 'order_task', workItemNo: 'OT-FALLBACK-1', sourceType: 'eml', rootOrderTaskNo: 'OT-FALLBACK',
|
|
shippingNoticeNo: null, runNo: 'SNER-FALLBACK', caseNo: null, conversationId: 'conv-1', submissionNo: 'SOS-1', intakeNo: 'SNI-FALLBACK',
|
|
status: 'processing', stage: 'document_parsing', progressVersion: 1, lastActivityAt: '', currentGate: null, availableActions: [],
|
|
sourceSummary: { emailSubject: null, filename: 'inside.eml.pdf', documentCount: 1, parsedDocumentCount: 1, candidateCount: 0, customerName: null, poNumber: null },
|
|
childOrderTasks: [], userStatus: 'running', userStage: 'document_parsing', facts: { uploadState: 'not_created' },
|
|
} as any;
|
|
const task = { user_task_no: 'INTAKE:SNI-FALLBACK', title: 'inside.eml', file_count: 1, userGroup: 'processing', group: 'processing', aggregateChildren: [], aggregateSummary: { intakeNo: 'SNI-FALLBACK', total: 1, completed: 0, processing: 1, needsAction: 0, failed: 0, stages: ['document_parsing'], reasonCodes: [] } } as any;
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState(), runNo: 'SNER-FALLBACK' },
|
|
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({ status_groups: { failed: [], waiting_human: [], processing: [task], completed: [], cancelled: [], archived: [] } }),
|
|
processingWorkItems: ref([{ workItemType: 'order_intake', workItemNo: 'INTAKE:SNI-FALLBACK', sourceType: 'eml', intakeNo: 'SNI-FALLBACK', aggregateChildren: [child] } as any]),
|
|
} } },
|
|
});
|
|
await wrapper.get('[data-testid="shipping-order-extraction-eml-processing-INTAKE:SNI-FALLBACK"] button').trigger('click');
|
|
// 状态组出现后,子文件必须完全来自该组;不能用另一份 work_items 补数。
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-eml-children"]').exists()).toBe(false);
|
|
expect(wrapper.text()).not.toContain('inside.eml.pdf');
|
|
});
|
|
|
|
it('uses the conversation projection total instead of the message Run snapshot total', () => {
|
|
const task = {
|
|
user_task_no: 'INTAKE:SNI-TOTAL', title: 'mail-total.eml', file_count: 2,
|
|
userGroup: 'waiting_human', group: 'needs_action', aggregateChildren: [],
|
|
aggregateSummary: { intakeNo: 'SNI-TOTAL', total: 2, completed: 0, processing: 0, needsAction: 2, failed: 0, stages: ['order_review'], reasonCodes: [] },
|
|
} as any;
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState({ summary: { ...buildState().summary, totalDocuments: 6 } }), runNo: 'SNER-TOTAL' },
|
|
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({
|
|
summary: { total_files: 2, completed_files: 0, waiting_human_files: 2, failed_files: 0 },
|
|
ui_state: { status: 'waiting_human' },
|
|
status_groups: { failed: [], waiting_human: [task], processing: [], completed: [], cancelled: [], archived: [] },
|
|
}),
|
|
processingWorkItems: ref([{ sourceType: 'eml', intakeNo: 'SNI-TOTAL', aggregateChildren: [{ sourceSummary: { filename: 'stale.pdf' } }] }]),
|
|
} } },
|
|
});
|
|
|
|
expect(wrapper.text()).toContain('共 2 个文件');
|
|
// 关键断言:待人工处理不是完成,头部按状态计数显示"待人工",不显示完成的"已处理"。
|
|
expect(wrapper.text()).toContain('待人工 2');
|
|
expect(wrapper.text()).not.toContain('共 6 个文件');
|
|
expect(wrapper.text()).not.toContain('stale.pdf');
|
|
});
|
|
|
|
it('renders a completed non-order attachment without a spinner', async () => {
|
|
const child = {
|
|
workItemNo: 'DOCUMENT:NON-ORDER', sourceSummary: { filename: 'not-an-order.pdf', documentId: 1 },
|
|
status: 'completed', stage: 'completed', userStatus: 'completed', userStage: 'completed',
|
|
facts: { uploadState: 'not_created' }, uiState: { status: 'completed', stage: 'completed' },
|
|
} as any;
|
|
const task = {
|
|
user_task_no: 'INTAKE:SNI-NON-ORDER', title: 'mail.eml', file_count: 1,
|
|
userGroup: 'completed', group: 'completed', aggregateChildren: [child],
|
|
aggregateSummary: { intakeNo: 'SNI-NON-ORDER', total: 1, completed: 1, processing: 0, needsAction: 0, failed: 0, stages: ['completed'], reasonCodes: [] },
|
|
} as any;
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState({ status: 'completed' }) },
|
|
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({
|
|
ui_state: { status: 'completed' },
|
|
summary: { total_files: 1, completed_files: 1, waiting_human_files: 0, failed_files: 0 },
|
|
status_groups: { failed: [], waiting_human: [], processing: [], completed: [task], cancelled: [], archived: [] },
|
|
}),
|
|
processingWorkItems: ref([]),
|
|
} } },
|
|
});
|
|
|
|
await wrapper.get('[data-testid="shipping-order-extraction-status-groups"] section button').trigger('click');
|
|
await wrapper.get('[data-testid="shipping-order-extraction-eml-completed-INTAKE:SNI-NON-ORDER"] button').trigger('click');
|
|
|
|
expect(wrapper.findAll('.animate-spin')).toHaveLength(0);
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-child-status-DOCUMENT:NON-ORDER"]').text()).not.toContain('处理中');
|
|
});
|
|
|
|
it('uses the authoritative attachment total when a historical message only carries the EML task count', () => {
|
|
const task = {
|
|
user_task_no: 'INTAKE:SNI-MAILS', title: 'mail-batch.eml', file_count: 30,
|
|
userGroup: 'waiting_human', group: 'needs_action', aggregateChildren: [],
|
|
aggregateSummary: { intakeNo: 'SNI-MAILS', total: 30, completed: 0, processing: 0, needsAction: 30, failed: 0, stages: ['order_review'], reasonCodes: [] },
|
|
} as any;
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
// 历史聊天消息记录的是 18 封 EML;不能把它当成 18 个业务附件。
|
|
state: buildState({ summary: { ...buildState().summary, totalDocuments: 18 } }),
|
|
runNo: 'SNER-ATTACHMENT-TOTAL',
|
|
},
|
|
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({
|
|
summary: { total_files: 30, completed_files: 0, waiting_human_files: 30, failed_files: 0 },
|
|
ui_state: { status: 'waiting_human' },
|
|
status_groups: { failed: [], waiting_human: [task], processing: [], completed: [], cancelled: [], archived: [] },
|
|
}),
|
|
processingWorkItems: ref([]),
|
|
} } },
|
|
});
|
|
|
|
// 关键断言:有权威会话投影时,只能显示附件总数,禁止回退历史邮件任务数。
|
|
expect(wrapper.text()).toContain('共 30 个文件');
|
|
expect(wrapper.text()).toContain('待人工 30');
|
|
expect(wrapper.text()).not.toContain('共 18 个文件');
|
|
});
|
|
|
|
it('counts unique EML attachment children instead of task rows', async () => {
|
|
const childA = { workItemType: 'order_task', workItemNo: 'OT-A', sourceType: 'eml', intakeNo: 'SNI-COUNT', sourceSummary: { filename: 'a.pdf', documentId: 101, documentCount: 1 }, status: 'processing', stage: 'document_parsing', userStatus: 'running', facts: { uploadState: 'not_created' } } as any;
|
|
const childB = { ...childA, workItemNo: 'OT-B', sourceSummary: { filename: 'b.pdf', documentId: 102, documentCount: 1 } } as any;
|
|
const task = { user_task_no: 'INTAKE:SNI-COUNT', title: 'count.eml', file_count: 2, userGroup: 'processing', group: 'processing', aggregateChildren: [childA, childB], aggregateSummary: { intakeNo: 'SNI-COUNT', total: 2, completed: 0, processing: 2, needsAction: 0, failed: 0, stages: [], reasonCodes: [] } } as any;
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState(), runNo: 'SNER-COUNT' },
|
|
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processing: ref({ status_groups: { failed: [], waiting_human: [], processing: [task], completed: [], cancelled: [], archived: [] } }), processingWorkItems: ref([]) } } },
|
|
});
|
|
// 状态分组标题必须按两个 PDF 附件计数,不能按一个 EML 容器计为“1 个任务”。
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-status-groups"]').text()).toContain('系统处理中 · 2 个文件');
|
|
});
|
|
|
|
it('renders every projected file when the batch has two documents', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
summary: {
|
|
totalDocuments: 2,
|
|
pendingDocuments: 0,
|
|
processingDocuments: 0,
|
|
completedDocuments: 0,
|
|
reviewRequiredDocuments: 2,
|
|
failedDocuments: 0,
|
|
candidateCount: 0,
|
|
},
|
|
documents: [
|
|
{ unitId: 1, documentId: 11, fileName: '4518838154.pdf', status: 'review_required' },
|
|
{ unitId: 2, documentId: 12, fileName: '4518838152.pdf', status: 'review_required' },
|
|
],
|
|
availableActions: ['enter_manual_review'],
|
|
healthTips: [],
|
|
}),
|
|
runNo: 'SNER-2',
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.text()).toContain('4518838154.pdf');
|
|
expect(wrapper.text()).toContain('4518838152.pdf');
|
|
});
|
|
|
|
it('keeps candidate-ready attachments under their EML instead of mixing unrelated files', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
documents: [
|
|
{ unitId: 1, documentId: 11, intakeId: 7, documentType: 'email_body', fileName: 'Forwarder_A.eml', status: 'processing' },
|
|
{ unitId: 2, documentId: 12, intakeId: 7, documentType: 'attachment', fileName: 'Packing_List.pdf', status: 'candidate_ready' },
|
|
{ unitId: 3, documentId: 13, intakeId: 8, documentType: 'attachment', fileName: 'Customs_Form.pdf', status: 'processing' },
|
|
],
|
|
healthTips: [],
|
|
}),
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
const text = wrapper.text();
|
|
expect(text.indexOf('Forwarder_A.eml')).toBeLessThan(text.indexOf('Packing_List.pdf'));
|
|
expect(text).toContain('Customs_Form.pdf');
|
|
expect(text.match(/Packing_List\.pdf/g)?.length).toBe(1);
|
|
});
|
|
|
|
it('groups by email_body document type and renders parse failure as failed', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
status: 'failed',
|
|
summary: {
|
|
totalDocuments: 2,
|
|
pendingDocuments: 0,
|
|
processingDocuments: 0,
|
|
completedDocuments: 0,
|
|
reviewRequiredDocuments: 0,
|
|
failedDocuments: 1,
|
|
candidateCount: 0,
|
|
},
|
|
documents: [
|
|
{ unitId: -7, documentId: 7, intakeId: 7, documentType: 'email_body', fileName: 'forwarder-message', status: 'failed', reasonCode: 'intake_parse_failed' },
|
|
{ unitId: 8, documentId: 8, intakeId: 7, documentType: 'attachment', fileName: 'po.pdf', status: 'failed', reasonCode: 'intake_parse_failed' },
|
|
],
|
|
healthTips: [],
|
|
currentActivity: null,
|
|
}),
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
const text = wrapper.text();
|
|
expect(text).toContain('forwarder-message');
|
|
expect(text).toContain('po.pdf');
|
|
expect(text).toContain('异常');
|
|
expect(wrapper.findAll('.animate-spin').length).toBe(0);
|
|
});
|
|
|
|
it('renders candidate-ready standalone files once without creating a candidate group', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
summary: {
|
|
totalDocuments: 2,
|
|
pendingDocuments: 0,
|
|
processingDocuments: 0,
|
|
completedDocuments: 2,
|
|
reviewRequiredDocuments: 0,
|
|
failedDocuments: 0,
|
|
candidateCount: 2,
|
|
},
|
|
documents: [
|
|
{ unitId: 1, documentId: 11, fileName: '4518838152.pdf', status: 'candidate_ready' },
|
|
{ unitId: 2, documentId: 12, fileName: '4518838154.pdf', status: 'candidate_ready' },
|
|
],
|
|
healthTips: [],
|
|
}),
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.text().match(/4518838152\.pdf/g)?.length).toBe(1);
|
|
expect(wrapper.text()).not.toContain('已生成候选 2 个文件');
|
|
});
|
|
|
|
it('keeps an all-candidate EML in the system-processing fallback group', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
summary: {
|
|
totalDocuments: 2,
|
|
pendingDocuments: 0,
|
|
processingDocuments: 0,
|
|
completedDocuments: 2,
|
|
reviewRequiredDocuments: 0,
|
|
failedDocuments: 0,
|
|
candidateCount: 2,
|
|
},
|
|
documents: [
|
|
{ unitId: -7, documentId: 7, intakeId: 7, documentType: 'email_body', fileName: 'forwarder.eml', status: 'processing' },
|
|
{ unitId: 8, documentId: 8, intakeId: 7, documentType: 'attachment', fileName: 'packing.pdf', status: 'candidate_ready' },
|
|
],
|
|
healthTips: [],
|
|
}),
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.text()).toContain('forwarder.eml');
|
|
expect(wrapper.text()).toContain('packing.pdf');
|
|
expect(wrapper.text().match(/forwarder\.eml/g)?.length).toBe(1);
|
|
expect(wrapper.text().match(/packing\.pdf/g)?.length).toBe(1);
|
|
expect(wrapper.text()).toContain('已提取');
|
|
});
|
|
|
|
it('keeps a mixed-stage EML in the system-processing fallback group', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
documents: [
|
|
{ unitId: -7, documentId: 7, intakeId: 7, documentType: 'email_body', fileName: 'forwarder.eml', status: 'processing' },
|
|
{ unitId: 8, documentId: 8, intakeId: 7, documentType: 'attachment', fileName: 'packing.pdf', status: 'candidate_ready' },
|
|
{ unitId: 9, documentId: 9, intakeId: 7, documentType: 'attachment', fileName: 'invoice.pdf', status: 'processing' },
|
|
],
|
|
healthTips: [],
|
|
}),
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.text()).toContain('forwarder.eml');
|
|
expect(wrapper.text()).toContain('invoice.pdf');
|
|
expect(wrapper.text().match(/packing\.pdf/g)?.length).toBe(1);
|
|
});
|
|
|
|
it('shows an EML as exception when a child failed even if the parent status is processing', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
documents: [
|
|
{ unitId: -7, documentId: 7, intakeId: 7, documentType: 'email_body', fileName: 'forwarder.eml', status: 'processing' },
|
|
{ unitId: 8, documentId: 8, intakeId: 7, documentType: 'attachment', fileName: 'packing.pdf', status: 'failed', reasonCode: 'intake_parse_failed' },
|
|
],
|
|
healthTips: [],
|
|
}),
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.text()).toContain('异常');
|
|
expect(wrapper.text()).not.toContain('解析附件中');
|
|
});
|
|
|
|
it('renders summary title, file count, system processing and no progress/refresh/cancel', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState(), runNo: 'SNER-1' },
|
|
global: { plugins: [i18n] },
|
|
});
|
|
// 关键断言:对话卡只保留摘要标题与系统处理中状态。
|
|
expect(wrapper.text()).toContain('本次订单文件处理');
|
|
expect(wrapper.text()).toContain('3 个文件');
|
|
expect(wrapper.text()).toContain('系统处理中');
|
|
expect(wrapper.text()).toContain('处理时间偏长');
|
|
expect(wrapper.text()).toContain('打开批次进度中心');
|
|
expect(wrapper.text()).not.toContain('刷新状态');
|
|
expect(wrapper.text()).not.toContain('取消本次识别');
|
|
expect(wrapper.text()).not.toContain('PO-450003.pdf');
|
|
expect(wrapper.text()).not.toContain('提取订单字段中');
|
|
expect(wrapper.findAll('[data-testid="chat-progress-summary-list"]').length).toBe(0);
|
|
expect(wrapper.findAll('[data-testid="shipping-order-extraction-summary"]').length).toBe(0);
|
|
expect(wrapper.findAll('[data-testid="shipping-order-document-result"]').length).toBe(0);
|
|
}, 30_000);
|
|
|
|
it('keeps file row copy identical when routed through the shared stage key', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
documents: [
|
|
{ unitId: 21, documentId: 21, intakeId: 21, documentType: 'attachment', fileName: 'layout.pdf', status: 'processing', userVisibleStage: 'layout_parsing_started' },
|
|
],
|
|
}),
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
// 输出不变契约:rowStatusLabel 改走共享 key 出口后,文案仍为 UserStage 短语。
|
|
expect(wrapper.text()).toContain('正在解析版面');
|
|
}, 30_000);
|
|
|
|
it('renders duplicate-linked notice when only open_existing results remain', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
status: 'review_required',
|
|
summary: {
|
|
totalDocuments: 2,
|
|
pendingDocuments: 0,
|
|
processingDocuments: 0,
|
|
completedDocuments: 0,
|
|
reviewRequiredDocuments: 0,
|
|
failedDocuments: 0,
|
|
candidateCount: 0,
|
|
openedExistingCount: 2,
|
|
},
|
|
availableActions: ['view_details'],
|
|
healthTips: [],
|
|
currentActivity: null,
|
|
}),
|
|
runNo: 'SNER-DUP',
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.text()).toContain('本次订单文件处理');
|
|
expect(wrapper.text()).toContain('已关联已有任务');
|
|
expect(wrapper.text()).not.toContain('需人工处理');
|
|
});
|
|
|
|
it('renders candidate confirmation as status notice with continue CTA', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
status: 'review_required',
|
|
summary: {
|
|
totalDocuments: 2,
|
|
pendingDocuments: 0,
|
|
processingDocuments: 0,
|
|
completedDocuments: 2,
|
|
reviewRequiredDocuments: 0,
|
|
failedDocuments: 0,
|
|
candidateCount: 2,
|
|
},
|
|
availableActions: ['view_details', 'review_candidate'],
|
|
primaryNotice: 'candidate_confirmation',
|
|
handlingItems: [{
|
|
category: 'candidate_confirmation',
|
|
count: 2,
|
|
reasonCodes: [],
|
|
affectedRefs: [],
|
|
primaryAction: 'review_candidate',
|
|
}],
|
|
healthTips: [],
|
|
currentActivity: null,
|
|
}),
|
|
runNo: 'SNER-CANDIDATES',
|
|
},
|
|
global: {
|
|
plugins: [i18n],
|
|
stubs: { 'router-link': true },
|
|
},
|
|
});
|
|
expect(wrapper.text()).toContain('订单候选已生成');
|
|
expect(wrapper.text()).toContain('候选待人工确认 · 2 项');
|
|
expect(wrapper.text()).toContain('打开批次进度中心');
|
|
expect(wrapper.text()).not.toContain('部分附件需人工处理');
|
|
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(0);
|
|
});
|
|
|
|
it('renders one handling summary line without per-item actions or affected refs', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
status: 'partially_completed',
|
|
summary: {
|
|
totalDocuments: 3,
|
|
pendingDocuments: 0,
|
|
processingDocuments: 0,
|
|
completedDocuments: 1,
|
|
reviewRequiredDocuments: 1,
|
|
failedDocuments: 1,
|
|
candidateCount: 1,
|
|
},
|
|
availableActions: ['enter_manual_review', 'retry_failed_attachments', 'view_details'],
|
|
primaryNotice: 'technical_failure',
|
|
handlingItems: [
|
|
{
|
|
category: 'technical_failure',
|
|
count: 1,
|
|
reasonCodes: ['document_unreadable'],
|
|
affectedRefs: [],
|
|
primaryAction: 'retry_failed_attachments',
|
|
},
|
|
{
|
|
category: 'candidate_missing_info',
|
|
count: 1,
|
|
reasonCodes: ['required_field_missing'],
|
|
affectedRefs: [],
|
|
primaryAction: 'review_candidate',
|
|
},
|
|
{
|
|
category: 'auto_freeze_blocked',
|
|
count: 1,
|
|
reasonCodes: ['profile_manual_confirmation_required'],
|
|
affectedRefs: [{ type: 'task', task_no: 'ST-88', candidate_no: 'C-9' }],
|
|
primaryAction: 'view_details',
|
|
},
|
|
],
|
|
healthTips: [],
|
|
currentActivity: null,
|
|
terminal: true,
|
|
}),
|
|
runNo: 'SNER-MIXED',
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.text()).toContain('部分附件处理失败');
|
|
expect(wrapper.text()).toContain('附件处理失败 · 3 项');
|
|
expect(wrapper.text()).not.toContain('订单待补信息');
|
|
expect(wrapper.text()).not.toContain('影响对象:');
|
|
expect(wrapper.text()).not.toContain('ST-88');
|
|
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(0);
|
|
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-primary-action"]').length).toBe(0);
|
|
// 当前原型将执行入口统一收敛到批次进度中心,旧消息卡不再保留重试 CTA。
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
|
|
});
|
|
|
|
it('keeps only the batch workbench CTA for review-required without retry', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
status: 'review_required',
|
|
availableActions: ['enter_manual_review', 'view_details'],
|
|
primaryNotice: 'candidate_confirmation',
|
|
handlingItems: [{
|
|
category: 'candidate_confirmation',
|
|
count: 1,
|
|
reasonCodes: [],
|
|
affectedRefs: [],
|
|
primaryAction: 'review_candidate',
|
|
}],
|
|
healthTips: [],
|
|
currentActivity: null,
|
|
summary: {
|
|
totalDocuments: 1,
|
|
pendingDocuments: 0,
|
|
processingDocuments: 0,
|
|
completedDocuments: 1,
|
|
reviewRequiredDocuments: 1,
|
|
failedDocuments: 0,
|
|
candidateCount: 1,
|
|
},
|
|
}),
|
|
runNo: 'SNER-REVIEW',
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-view-details"]').exists()).toBe(false);
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
|
|
});
|
|
|
|
it('does not render multi-OT ChatProgressSummary list', () => {
|
|
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',
|
|
}],
|
|
healthTips: [],
|
|
currentActivity: null,
|
|
summary: {
|
|
totalDocuments: 1,
|
|
pendingDocuments: 0,
|
|
processingDocuments: 0,
|
|
completedDocuments: 1,
|
|
reviewRequiredDocuments: 1,
|
|
failedDocuments: 0,
|
|
candidateCount: 1,
|
|
},
|
|
}),
|
|
runNo: 'SNER-UI01',
|
|
processingProjection: projection,
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.findAll('[data-testid="chat-progress-summary-list"]').length).toBe(0);
|
|
expect(wrapper.text()).not.toContain('PO.pdf');
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
|
|
});
|
|
|
|
it('keeps retry actions out of the bottom action bar', async () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
availableActions: ['retry_failed_attachments'],
|
|
summary: {
|
|
totalDocuments: 2,
|
|
pendingDocuments: 0,
|
|
processingDocuments: 0,
|
|
completedDocuments: 1,
|
|
reviewRequiredDocuments: 0,
|
|
failedDocuments: 1,
|
|
candidateCount: 0,
|
|
},
|
|
healthTips: [],
|
|
}),
|
|
runNo: 'SNER-1',
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
|
|
});
|
|
|
|
it('does not render the removed view details link', () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: {
|
|
state: buildState({
|
|
availableActions: ['view_details'],
|
|
healthTips: [],
|
|
}),
|
|
runNo: 'SNER-1',
|
|
},
|
|
global: { plugins: [i18n] },
|
|
});
|
|
const details = wrapper.find('[data-testid="shipping-order-extraction-view-details"]');
|
|
expect(details.exists()).toBe(false);
|
|
expect(wrapper.findAll('[data-testid="shipping-order-extraction-primary-action"]').length).toBe(0);
|
|
});
|
|
|
|
it('uses the submitted_files (batch-size) count for the header chip, not the recognized total', () => {
|
|
// [回归] 提交基主计数 submitted_files=1 优先于已识别 total_files=3 作为「共 N 个文件」。
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState() },
|
|
global: {
|
|
plugins: [i18n],
|
|
provide: {
|
|
[SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({
|
|
ui_state: { status: 'running' },
|
|
summary: { total_files: 3, submitted_files: 1 },
|
|
status_groups: {
|
|
failed: [], waiting_human: [], processing: [
|
|
{ user_task_no: 'INTAKE:SNI-BATCH', title: 'batch.eml', file_count: 3,
|
|
userGroup: 'processing', group: 'processing', aggregateChildren: [] },
|
|
], completed: [], cancelled: [], archived: [],
|
|
},
|
|
}),
|
|
processingWorkItems: ref([]),
|
|
},
|
|
},
|
|
},
|
|
});
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
|
|
expect(wrapper.text()).toContain('共 1 个文件');
|
|
});
|
|
|
|
it('shows the recognized count inside the file-count chip during the pre-materialization window', () => {
|
|
// [回归] 识别进度必须与「共 N 个文件」同一标签展示,不能单独占一行。
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState() },
|
|
global: {
|
|
plugins: [i18n],
|
|
provide: {
|
|
[SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({
|
|
ui_state: { status: 'running' },
|
|
summary: { total_files: 0, submitted_files: 1 },
|
|
status_groups: {
|
|
failed: [], waiting_human: [], processing: [], completed: [], cancelled: [], archived: [],
|
|
},
|
|
}),
|
|
processingWorkItems: ref([]),
|
|
},
|
|
},
|
|
},
|
|
});
|
|
expect(wrapper.get('[data-testid="shipping-order-extraction-recognizing-placeholder"]').text()).toContain('正在识别附件');
|
|
expect(wrapper.text()).toContain('共 1 个文件 · 已识别 0/1');
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-recognized-hint"]').exists()).toBe(false);
|
|
});
|
|
|
|
it('renders an unrecognized plan attachment as a distinct pending row inside the EML task', async () => {
|
|
// [回归] 批次「已识别 1/2」时 EML 列表须展示全部计划附件(含未识别行),
|
|
// 未识别行标记为「待识别」,便于排查「为什么这份没识别」。
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState() },
|
|
global: {
|
|
plugins: [i18n],
|
|
provide: {
|
|
[SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({
|
|
ui_state: { status: 'running' },
|
|
summary: { total_files: 1, submitted_files: 2 },
|
|
status_groups: {
|
|
failed: [], waiting_human: [], processing: [{
|
|
user_task_no: 'INTAKE:SNI-UNRECOGNIZED', title: 'batch.eml', file_count: 2,
|
|
userGroup: 'processing', group: 'processing',
|
|
aggregateChildren: [
|
|
{
|
|
workItemNo: 'DOC-10', sourceType: 'eml', intakeNo: 'SNI-UNRECOGNIZED',
|
|
sourceSummary: { filename: 'F91D1.pdf', documentId: 10 },
|
|
userStatus: 'waiting_human', userStage: 'order_review', status: 'waiting_human',
|
|
},
|
|
{
|
|
workItemNo: 'PLAN:SNI-UNRECOGNIZED:f92', sourceType: 'eml', intakeNo: 'SNI-UNRECOGNIZED',
|
|
sourceSummary: { filename: 'F92.pdf' },
|
|
userStatus: 'processing', userStage: 'intake_parse', status: 'processing',
|
|
facts: { recognized: false, planState: 'selected_pending' },
|
|
},
|
|
],
|
|
}], completed: [], cancelled: [], archived: [],
|
|
},
|
|
}),
|
|
processingWorkItems: ref([]),
|
|
},
|
|
},
|
|
},
|
|
});
|
|
await wrapper.get('[data-testid="shipping-order-extraction-eml-processing-INTAKE:SNI-UNRECOGNIZED"] button').trigger('click');
|
|
const status = wrapper.find('[data-testid="shipping-order-extraction-child-status-PLAN:SNI-UNRECOGNIZED:f92"]');
|
|
expect(status.exists()).toBe(true);
|
|
expect(status.text()).toContain('待识别');
|
|
expect(wrapper.text()).toContain('F92.pdf');
|
|
expect(wrapper.text()).toContain('尚未识别');
|
|
});
|
|
|
|
it('marks unrecognized Excel attachments as ignored instead of pending recognition', async () => {
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState() },
|
|
global: {
|
|
plugins: [i18n],
|
|
provide: {
|
|
[SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({
|
|
ui_state: { status: 'running' },
|
|
summary: { total_files: 1, submitted_files: 2 },
|
|
status_groups: {
|
|
failed: [], waiting_human: [], processing: [{
|
|
user_task_no: 'INTAKE:SNI-EXCEL', title: 'batch.eml', file_count: 2,
|
|
userGroup: 'processing', group: 'processing',
|
|
aggregateChildren: [
|
|
{
|
|
workItemNo: 'DOC-11', sourceType: 'eml', intakeNo: 'SNI-EXCEL',
|
|
sourceSummary: { filename: 'order.pdf', documentId: 11 },
|
|
userStatus: 'processing', userStage: 'intake_parse', status: 'processing',
|
|
},
|
|
{
|
|
workItemNo: 'PLAN:SNI-EXCEL:report', sourceType: 'eml', intakeNo: 'SNI-EXCEL',
|
|
sourceSummary: { filename: 'report.xlsx' },
|
|
userStatus: 'processing', userStage: 'intake_parse', status: 'processing',
|
|
facts: { recognized: false, planState: 'selected_pending' },
|
|
},
|
|
],
|
|
}], completed: [], cancelled: [], archived: [],
|
|
},
|
|
}),
|
|
processingWorkItems: ref([]),
|
|
},
|
|
},
|
|
},
|
|
});
|
|
await wrapper.get('[data-testid="shipping-order-extraction-eml-processing-INTAKE:SNI-EXCEL"] button').trigger('click');
|
|
|
|
const processingCard = wrapper.get('[data-testid="shipping-order-extraction-eml-processing-INTAKE:SNI-EXCEL"]');
|
|
expect(processingCard.text()).toContain('order.pdf');
|
|
expect(processingCard.text()).not.toContain('report.xlsx');
|
|
expect(wrapper.find('[data-testid="shipping-order-extraction-eml-ignored-INTAKE:SNI-EXCEL"]').exists()).toBe(false);
|
|
const ignoredSection = wrapper.findAll('[data-testid="shipping-order-extraction-status-groups"] section')
|
|
.find((section) => section.text().includes('已忽略'))!;
|
|
await ignoredSection.get('button').trigger('click');
|
|
const ignoredCard = wrapper.get('[data-testid="shipping-order-extraction-eml-ignored-INTAKE:SNI-EXCEL"]');
|
|
const status = ignoredCard.get('[data-testid="shipping-order-extraction-child-status-PLAN:SNI-EXCEL:report"]');
|
|
expect(status.text()).toContain('已忽略');
|
|
expect(ignoredCard.text()).toContain('非订单 PDF,不参与订单识别');
|
|
expect(status.text()).not.toContain('待识别');
|
|
});
|
|
|
|
it('completes the header when only ignored Excel attachments remain', () => {
|
|
const completedPdf = {
|
|
workItemNo: 'DOC-COMPLETED', sourceType: 'eml', intakeNo: 'SNI-HEADER-COMPLETE',
|
|
sourceSummary: { filename: 'order.pdf', documentId: 12 },
|
|
userStatus: 'completed', userStage: 'intake_parse', status: 'completed',
|
|
};
|
|
const ignoredExcel = {
|
|
workItemNo: 'PLAN:SNI-HEADER-COMPLETE:excel', sourceType: 'eml', intakeNo: 'SNI-HEADER-COMPLETE',
|
|
sourceSummary: { filename: 'PO_INFO.xlsx' },
|
|
userStatus: 'processing', userStage: 'intake_parse', status: 'processing',
|
|
facts: { recognized: false, planState: 'selected_pending' },
|
|
};
|
|
const task = (children: unknown[]) => ({
|
|
user_task_no: 'INTAKE:SNI-HEADER-COMPLETE', title: 'batch.eml', file_count: 1,
|
|
userGroup: 'processing', group: 'processing', aggregateChildren: children,
|
|
});
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState() },
|
|
global: {
|
|
plugins: [i18n],
|
|
provide: {
|
|
[SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({
|
|
ui_state: { status: 'running', lifecycleStage: 'intake_parse' },
|
|
summary: { total_files: 1, submitted_files: 2 },
|
|
status_groups: {
|
|
failed: [], waiting_human: [], processing: [task([ignoredExcel])],
|
|
completed: [task([completedPdf])], cancelled: [], archived: [],
|
|
},
|
|
}),
|
|
processingWorkItems: ref([]),
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(wrapper.text()).toContain('本次订单文件处理');
|
|
expect(wrapper.text()).toContain('订单文件 1 个已完成 · 1 个已忽略');
|
|
expect(wrapper.text()).toContain('处理完成');
|
|
expect(wrapper.text()).not.toContain('系统处理中');
|
|
expect(wrapper.text()).not.toContain('当前阶段:');
|
|
expect(wrapper.findAll('.animate-spin')).toHaveLength(0);
|
|
});
|
|
|
|
it('keeps the header processing when an unrecognized PDF remains', () => {
|
|
const unrecognizedPdf = {
|
|
workItemNo: 'PLAN:SNI-HEADER-PENDING:pdf', sourceType: 'eml', intakeNo: 'SNI-HEADER-PENDING',
|
|
sourceSummary: { filename: 'PO_INFO.pdf' },
|
|
userStatus: 'processing', userStage: 'intake_parse', status: 'processing',
|
|
facts: { recognized: false, planState: 'selected_pending' },
|
|
};
|
|
const ignoredExcel = {
|
|
workItemNo: 'PLAN:SNI-HEADER-PENDING:excel', sourceType: 'eml', intakeNo: 'SNI-HEADER-PENDING',
|
|
sourceSummary: { filename: 'PO_INFO.xlsx' },
|
|
userStatus: 'processing', userStage: 'intake_parse', status: 'processing',
|
|
facts: { recognized: false, planState: 'selected_pending' },
|
|
};
|
|
const wrapper = mount(ShippingOrderExtractionCard, {
|
|
props: { state: buildState() },
|
|
global: {
|
|
plugins: [i18n],
|
|
provide: {
|
|
[SHIPPING_WORKFLOW_KEY as symbol]: {
|
|
processing: ref({
|
|
ui_state: { status: 'running', lifecycleStage: 'intake_parse' },
|
|
summary: { total_files: 1, submitted_files: 2 },
|
|
status_groups: {
|
|
failed: [], waiting_human: [], processing: [{
|
|
user_task_no: 'INTAKE:SNI-HEADER-PENDING', title: 'batch.eml', file_count: 1,
|
|
userGroup: 'processing', group: 'processing', aggregateChildren: [unrecognizedPdf, ignoredExcel],
|
|
}], completed: [], cancelled: [], archived: [],
|
|
},
|
|
}),
|
|
processingWorkItems: ref([]),
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(wrapper.text()).toContain('系统处理中');
|
|
expect(wrapper.text()).toContain('共 2 个文件 · 已识别 1/2 · 1 个已忽略');
|
|
expect(wrapper.text()).not.toContain('当前阶段:');
|
|
expect(wrapper.findAll('.animate-spin')).toHaveLength(1);
|
|
});
|
|
});
|