chore(shipping-notice): 统一货代发货生命周期阶段命名并优化全链路业务逻辑
This commit is contained in:
1 parent
5ef8329bd8
commit
4ec4e57005
183 files changed
+14653
-3936
No files matched your search
+311
-3
@@ -117,6 +117,210 @@ function buildWorkItem(
|
||||
}
|
||||
|
||||
describe('ShippingConversationProcessingCard', () => {
|
||||
it('only exposes file cancellation when the backend explicitly authorizes cancel_unit', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
user_task_no: 'OT-CANCEL-UNIT', group: 'processing', status_label: 'extracting',
|
||||
file_count: 1, run_no: 'RUN-CANCEL-UNIT', can_append: false,
|
||||
objects: [{ kind: 'document', object_key: 'DOC-9', label: 'cancel.pdf', filename: 'cancel.pdf',
|
||||
document_id: 9, root_document_id: 9, status_label: 'extracting' }],
|
||||
}];
|
||||
const workItem = buildWorkItem('OT-CANCEL-UNIT', {
|
||||
availableActions: ['cancel_unit'],
|
||||
sourceSummary: { ...buildWorkItem('OT-CANCEL-UNIT').sourceSummary, documentId: 9 },
|
||||
uiState: {
|
||||
status: 'running',
|
||||
stage: 'document_parsing',
|
||||
blocking_reason: null,
|
||||
primary_action: null,
|
||||
secondary_actions: [{ code: 'cancel_unit', enabled: true }],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [workItem], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
await wrapper.find('summary').trigger('click');
|
||||
await wrapper.find('[data-testid="shipping-processing-file-cancel"]').trigger('click');
|
||||
expect(wrapper.emitted('fileAction')?.[0]?.[0]).toMatchObject({
|
||||
action: 'cancel_unit', projection: { workItemNo: 'OT-CANCEL-UNIT' },
|
||||
});
|
||||
});
|
||||
|
||||
it('does not fall back to legacy cancellation when ui_state revokes it', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
user_task_no: 'OT-CANCEL-REVOKED', group: 'processing', status_label: 'extracting',
|
||||
file_count: 1, run_no: 'RUN-CANCEL-REVOKED', can_append: false,
|
||||
objects: [{ kind: 'document', object_key: 'DOC-10', label: 'revoked.pdf', filename: 'revoked.pdf',
|
||||
document_id: 10, root_document_id: 10, status_label: 'extracting' }],
|
||||
}];
|
||||
const workItem = buildWorkItem('OT-CANCEL-REVOKED', {
|
||||
availableActions: ['cancel_unit'],
|
||||
sourceSummary: { ...buildWorkItem('OT-CANCEL-REVOKED').sourceSummary, documentId: 10 },
|
||||
uiState: {
|
||||
status: 'running',
|
||||
stage: 'document_parsing',
|
||||
blocking_reason: null,
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [workItem], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
// ui_state 已出现即表示后端完成了正式动作裁决;遗留 availableActions 不得重新授权。
|
||||
expect(wrapper.find('[data-testid="shipping-processing-file-cancel"]').exists()).toBe(false);
|
||||
expect(wrapper.emitted('fileAction')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('does not render legacy document_names as a batch file row without a live leaf projection', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
user_task_no: 'OT-HISTORICAL-SNAPSHOT', group: 'processing', status_label: 'extracting',
|
||||
title: 'legacy-run.pdf', document_names: ['legacy-run.pdf'], file_count: 1,
|
||||
run_no: 'RUN-HISTORICAL-SNAPSHOT', can_append: false,
|
||||
}];
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
// 批次中心没有实时叶子投影时不得由历史 Run 快照补造文件行或操作入口。
|
||||
expect(wrapper.find('[data-testid="shipping-processing-file-OT-HISTORICAL-SNAPSHOT-document-0"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).not.toContain('legacy-run.pdf');
|
||||
});
|
||||
|
||||
it('uses the live leaf summary instead of a stale task object in batch mode', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
user_task_no: 'OT-LIVE-LEAF', group: 'processing', status_label: 'extracting',
|
||||
title: 'snapshot-old-name.pdf', file_count: 1, run_no: 'RUN-LIVE-LEAF', can_append: false,
|
||||
objects: [{
|
||||
kind: 'document', object_key: 'DOC-88', label: 'snapshot-old-name.pdf',
|
||||
filename: 'snapshot-old-name.pdf', document_id: 88, root_document_id: 88,
|
||||
status_label: 'pending_review',
|
||||
}],
|
||||
}];
|
||||
const live = buildWorkItem('OT-LIVE-LEAF', {
|
||||
runNo: 'RUN-LIVE-LEAF',
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'realtime-name.pdf', documentId: 88,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-REALTIME',
|
||||
},
|
||||
uiState: {
|
||||
status: 'running', stage: 'order_review', lifecycleStage: 'order_review',
|
||||
lifecycleEntries: [{ code: 'order_review', state: 'current', targetSurface: 'order_lifecycle_workbench' }],
|
||||
blocking_reason: null, primary_action: null, secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [live], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const row = wrapper.get('[data-testid="shipping-processing-file-DOC-88"]');
|
||||
expect(row.text()).toContain('realtime-name.pdf');
|
||||
expect(row.text()).toContain('PO:PO-REALTIME');
|
||||
expect(row.text()).not.toContain('snapshot-old-name.pdf');
|
||||
});
|
||||
|
||||
it('expands EML files only from the live aggregate work item', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
user_task_no: 'INTAKE:EML-LIVE', group: 'processing', status_label: 'extracting',
|
||||
title: 'snapshot-mail.eml', document_names: ['snapshot-attachment.pdf'],
|
||||
file_count: 1, run_no: 'RUN-EML-LIVE', can_append: false,
|
||||
aggregateChildren: [],
|
||||
}];
|
||||
const liveChild = buildWorkItem('DOCUMENT:77', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-EML-LIVE', runNo: 'RUN-EML-LIVE',
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'live-attachment.pdf', documentId: 77,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-EML-LIVE',
|
||||
},
|
||||
uiState: {
|
||||
status: 'running', stage: 'order_review', lifecycleStage: 'order_review',
|
||||
lifecycleEntries: [{ code: 'order_review', state: 'current', targetSurface: 'order_lifecycle_workbench' }],
|
||||
blocking_reason: null, primary_action: null, secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const liveEmlRoot = buildWorkItem('INTAKE:EML-LIVE', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-EML-LIVE', runNo: 'RUN-EML-LIVE',
|
||||
sourceSummary: {
|
||||
emailSubject: 'Live mail', filename: 'live-mail.eml', documentId: null,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: null,
|
||||
},
|
||||
aggregateChildren: [liveChild],
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [liveEmlRoot], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const row = wrapper.get('[data-testid="shipping-processing-file-DOC-77"]');
|
||||
expect(row.text()).toContain('live-attachment.pdf');
|
||||
expect(row.text()).toContain('PO:PO-EML-LIVE');
|
||||
expect(wrapper.text()).not.toContain('snapshot-attachment.pdf');
|
||||
});
|
||||
|
||||
it('keeps an EML attachment when it has a linked child order task', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
user_task_no: 'INTAKE:EML-WITH-CHILD-OT', group: 'processing', status_label: 'extracting',
|
||||
title: 'mail.eml', file_count: 2, run_no: 'RUN-EML-WITH-CHILD-OT', can_append: false,
|
||||
}];
|
||||
const firstAttachment = buildWorkItem('OT-EML-WITH-CHILD-OT', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-EML-WITH-CHILD-OT',
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'first.pdf', documentId: 266,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-FIRST',
|
||||
},
|
||||
childOrderTasks: [{
|
||||
orderTaskNo: 'OT-EML-WITH-CHILD-OT-C1', status: 'blocked', stage: 'inventory_matching',
|
||||
customerName: null, poNumber: 'PO-SECOND', lastActivityAt: null,
|
||||
}],
|
||||
});
|
||||
const secondAttachment = buildWorkItem('OT-EML-WITH-CHILD-OT-C1', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-EML-WITH-CHILD-OT',
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'second.pdf', documentId: 267,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-SECOND',
|
||||
},
|
||||
});
|
||||
const liveEmlRoot = buildWorkItem('INTAKE:EML-WITH-CHILD-OT', {
|
||||
sourceType: 'eml', rootOrderTaskNo: 'OT-EML-WITH-CHILD-OT',
|
||||
sourceSummary: {
|
||||
emailSubject: 'Mail', filename: 'mail.eml', documentId: null,
|
||||
documentCount: 2, parsedDocumentCount: 2, candidateCount: 2,
|
||||
customerName: null, poNumber: null,
|
||||
},
|
||||
aggregateChildren: [firstAttachment, secondAttachment],
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [liveEmlRoot], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-processing-file-DOC-266"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-file-DOC-267"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('处理中 · 2 个文件');
|
||||
});
|
||||
|
||||
it('renders needs_action / processing groups and collapsible processing records with three subsections', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection: buildProjection() },
|
||||
@@ -127,8 +331,9 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
expect(wrapper.find('[data-testid="shipping-conversation-processing-card"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-failed"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-processing"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('异常 / 失败 · 1 个任务');
|
||||
expect(wrapper.text()).toContain('系统处理中 · 1 个任务');
|
||||
// 批次中心统一按文件计数;旧任务数文案不再是页面统计口径。
|
||||
expect(wrapper.text()).toContain('异常 · 0 个文件');
|
||||
expect(wrapper.text()).toContain('处理中 · 0 个文件');
|
||||
expect(wrapper.text()).toContain('刚刚创建');
|
||||
|
||||
// 处理记录默认折叠;标题 count = completed + history 返回条数。
|
||||
@@ -559,7 +764,110 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.text()).toContain('待复核');
|
||||
// 旧聚合卡不再显示内部 Case 状态;工作台文件行才展示后端 ui_state。
|
||||
expect(wrapper.text()).not.toContain('review_case_draft');
|
||||
expect(wrapper.text()).not.toContain('review_case_draft');
|
||||
});
|
||||
|
||||
it('renders a compact V3 file row with named lifecycle entries', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
...projection.processing[0],
|
||||
user_task_no: 'OT-LIFECYCLE',
|
||||
run_no: 'RUN-LIFECYCLE',
|
||||
file_count: 1,
|
||||
}];
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection,
|
||||
workbenchMode: true,
|
||||
workItems: [buildWorkItem('OT-LIFECYCLE', {
|
||||
runNo: 'RUN-LIFECYCLE',
|
||||
caseNo: 'CASE-LIFECYCLE',
|
||||
sourceSummary: {
|
||||
emailSubject: null,
|
||||
filename: 'lifecycle.pdf',
|
||||
documentId: 9,
|
||||
documentCount: 1,
|
||||
parsedDocumentCount: 1,
|
||||
candidateCount: 1,
|
||||
customerName: null,
|
||||
poNumber: 'PO-LIFECYCLE',
|
||||
},
|
||||
uiState: {
|
||||
status: 'running',
|
||||
stage: 'inventory_match',
|
||||
lifecycleStage: 'fulfillment_prep',
|
||||
lifecycleEntries: [
|
||||
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
|
||||
{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' },
|
||||
{ code: 'upload_complete', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
|
||||
],
|
||||
blocking_reason: null,
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
})],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const row = wrapper.find('[data-testid="shipping-processing-file-DOC-9"]');
|
||||
expect(row.exists()).toBe(true);
|
||||
expect(row.text()).toContain('lifecycle.pdf');
|
||||
expect(row.text()).toContain('PO:PO-LIFECYCLE');
|
||||
expect(row.text()).toContain('通知准备');
|
||||
expect(row.text()).toContain('订单复核 · 可进入');
|
||||
expect(row.text()).toContain('通知准备 · 当前可处理');
|
||||
expect(row.text()).toContain('通知完成 · 前置未完成');
|
||||
});
|
||||
|
||||
it('fails closed when a lifecycle entry has an unknown backend state', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.processing = [{
|
||||
...projection.processing[0],
|
||||
user_task_no: 'OT-LIFECYCLE-UNKNOWN',
|
||||
run_no: 'RUN-LIFECYCLE-UNKNOWN',
|
||||
file_count: 1,
|
||||
}];
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection,
|
||||
workbenchMode: true,
|
||||
workItems: [buildWorkItem('OT-LIFECYCLE-UNKNOWN', {
|
||||
runNo: 'RUN-LIFECYCLE-UNKNOWN',
|
||||
sourceSummary: {
|
||||
emailSubject: null,
|
||||
filename: 'unknown-entry.pdf',
|
||||
documentId: 10,
|
||||
documentCount: 1,
|
||||
parsedDocumentCount: 1,
|
||||
candidateCount: 1,
|
||||
customerName: null,
|
||||
poNumber: 'PO-UNKNOWN',
|
||||
},
|
||||
uiState: {
|
||||
status: 'running',
|
||||
stage: 'inventory_match',
|
||||
lifecycleStage: 'fulfillment_prep',
|
||||
lifecycleEntries: [
|
||||
{ code: 'order_review', state: 'paused', targetSurface: 'order_lifecycle_workbench' },
|
||||
] as unknown as ShippingProcessingProjection['uiState']['lifecycleEntries'],
|
||||
blocking_reason: null,
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
})],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const row = wrapper.find('[data-testid="shipping-processing-file-DOC-10"]');
|
||||
const orderReview = row.findAll('button').find((button) => button.text().includes('订单复核'));
|
||||
expect(orderReview?.attributes('disabled')).toBeDefined();
|
||||
await orderReview?.trigger('click');
|
||||
expect(wrapper.emitted('openLifecycleStage')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user