test(shipping): 更新订单复核库存与通知流程测试
This commit is contained in:
1 parent
8ec028e6a3
commit
265a6e179a
168 files changed
+9420
-4613
No files matched your search
+297
-8
@@ -183,7 +183,7 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
|
||||
// 旧快照缺少会话级用户状态;candidate_ready 只能作为附件阶段,不能升格为顶层分组。
|
||||
expect(wrapper.text()).toContain('共 3 个文件');
|
||||
expect(wrapper.text()).toContain('0/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 已处理');
|
||||
@@ -300,12 +300,52 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
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()).toContain('当前步骤需要人工处理');
|
||||
// 通用兜底原因(当前步骤需要人工处理)与右侧状态芯片语义重复,统一隐藏。
|
||||
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',
|
||||
@@ -347,8 +387,8 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
});
|
||||
|
||||
expect(wrapper.text()).toContain('共 2 个文件');
|
||||
// 关键断言:待人工处理不是完成,聊天摘要必须与批次中心 completed_files 同口径。
|
||||
expect(wrapper.text()).toContain('0/2 已处理');
|
||||
// 关键断言:待人工处理不是完成,头部按状态计数显示"待人工",不显示完成的"已处理"。
|
||||
expect(wrapper.text()).toContain('待人工 2');
|
||||
expect(wrapper.text()).not.toContain('共 6 个文件');
|
||||
expect(wrapper.text()).not.toContain('stale.pdf');
|
||||
});
|
||||
@@ -407,7 +447,7 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
|
||||
// 关键断言:有权威会话投影时,只能显示附件总数,禁止回退历史邮件任务数。
|
||||
expect(wrapper.text()).toContain('共 30 个文件');
|
||||
expect(wrapper.text()).toContain('0/30 已处理');
|
||||
expect(wrapper.text()).toContain('待人工 30');
|
||||
expect(wrapper.text()).not.toContain('共 18 个文件');
|
||||
});
|
||||
|
||||
@@ -419,7 +459,8 @@ describe('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([]) } } },
|
||||
});
|
||||
expect(wrapper.text()).toContain('2 个文件');
|
||||
// 状态分组标题必须按两个 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', () => {
|
||||
@@ -598,7 +639,7 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
// 关键断言:对话卡只保留摘要标题与系统处理中状态。
|
||||
expect(wrapper.text()).toContain('订单识别任务');
|
||||
expect(wrapper.text()).toContain('本次订单文件处理');
|
||||
expect(wrapper.text()).toContain('3 个文件');
|
||||
expect(wrapper.text()).toContain('系统处理中');
|
||||
expect(wrapper.text()).toContain('处理时间偏长');
|
||||
@@ -612,6 +653,21 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
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: {
|
||||
@@ -635,7 +691,7 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.text()).toContain('订单识别任务');
|
||||
expect(wrapper.text()).toContain('本次订单文件处理');
|
||||
expect(wrapper.text()).toContain('已关联已有任务');
|
||||
expect(wrapper.text()).not.toContain('需人工处理');
|
||||
});
|
||||
@@ -876,4 +932,237 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user