feat(shipping-notice): 收敛复核状态隔离、STP 重试幂等与 XFA 合成预览标注

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-07 02:58:28 +08:00
1 parent 84a881b554
commit 74270adc22
149 files changed
+20111 -3871

No files matched your search

@@ -1,8 +1,9 @@
/**
* features/chat/components/shipping/ShippingConversationProcessingCard.spec.ts
* 用途:验收右侧任务分组卡——needs_action/processing 与短时反馈标签。
* 用途:验收右侧任务分组卡——needs_action / processing / 处理记录三子段与动作层级。
* 依赖:Vitest、Vue Test Utils、vue-i18n、ShippingConversationProcessingCard。
* 逻辑:构造 ConversationProcessingProjection;断言分组、焦点 emit;右侧不渲染 history。
* 逻辑:构造 ConversationProcessingProjection;断言分组文案、处理记录折叠与三类子段、
* UI-02 单一详情入口、UI-03 history 截断角标、有 workItem 时无任务级主/次按钮。
*/
import { mount, flushPromises } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
@@ -22,7 +23,7 @@ const i18n = createI18n({
function buildProjection(): ConversationProcessingProjection {
return {
summary: { total_tasks: 3, processing: 1, needs_action: 1, completed: 1, history: 0 },
summary: { total_tasks: 3, processing: 1, needs_action: 1, completed: 1, history: 2 },
focused_task_no: 'OT-PROC',
recent_task_no: 'OT-PROC',
needs_action: [{
@@ -55,15 +56,28 @@ function buildProjection(): ConversationProcessingProjection {
can_append: false,
available_actions: ['view_details'],
}],
history: [{
user_task_no: 'OT-HIST',
group: 'history',
status_label: 'completed',
file_count: 1,
run_no: 'RUN-HIST',
can_append: false,
viewed: true,
}],
history: [
{
user_task_no: 'OT-HIST',
group: 'history',
status_label: 'completed',
file_count: 1,
run_no: 'RUN-HIST',
can_append: false,
viewed: true,
available_actions: ['view_details'],
},
{
user_task_no: 'OT-CANCEL',
group: 'history',
status_label: 'cancelled',
file_count: 1,
run_no: 'RUN-CANCEL',
can_append: false,
viewed: true,
available_actions: ['view_details'],
},
],
};
}
@@ -103,7 +117,7 @@ function buildWorkItem(
}
describe('ShippingConversationProcessingCard', () => {
it('renders needs_action / processing / completed groups, hides history on the right panel', async () => {
it('renders needs_action / processing groups and collapsible processing records with three subsections', async () => {
const wrapper = mount(ShippingConversationProcessingCard, {
props: { projection: buildProjection() },
global: { plugins: [i18n] },
@@ -113,18 +127,88 @@ describe('ShippingConversationProcessingCard', () => {
expect(wrapper.find('[data-testid="shipping-conversation-processing-card"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-group-needs_action"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-group-processing"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-group-completed"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-PROC"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]').exists()).toBe(true);
expect(wrapper.text()).toContain('需要你处理 · 1 个任务');
expect(wrapper.text()).toContain('系统处理中 · 1 个任务');
expect(wrapper.text()).toContain('刚刚创建');
expect(wrapper.text()).toContain('已完成');
// UI-04:右侧不展示处理记录分组。
expect(wrapper.find('[data-testid="shipping-processing-group-history"]').exists()).toBe(false);
// 处理记录默认折叠;标题 count = completed + history 返回条数。
const historyGroup = wrapper.find('[data-testid="shipping-processing-group-history"]');
expect(historyGroup.exists()).toBe(true);
expect(historyGroup.text()).toContain('处理记录 · 3');
expect(wrapper.find('[data-testid="shipping-processing-history-body"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-HIST"]').exists()).toBe(false);
await wrapper.find('[data-testid="shipping-processing-history-toggle"]').trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-history-body"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-history-completed"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-history-versions"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-history-cancelled"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-HIST"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-CANCEL"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-history-completed"]').text()).toContain('已完成');
expect(wrapper.find('[data-testid="shipping-processing-history-versions"]').text()).toContain('历史版本');
expect(wrapper.find('[data-testid="shipping-processing-history-cancelled"]').text()).toContain('已取消');
});
it('renders multi-PDF task title instead of first filename', async () => {
it('shows history more badge when summary.history exceeds returned history length', async () => {
const projection = buildProjection();
projection.summary.history = 14;
const wrapper = mount(ShippingConversationProcessingCard, {
props: { projection },
global: { plugins: [i18n] },
});
await flushPromises();
// UI-03:折叠态即可看到「还有 N 条」。
expect(wrapper.find('[data-testid="shipping-processing-history-more"]').text()).toContain('还有 12 条');
await wrapper.find('[data-testid="shipping-processing-history-toggle"]').trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-history-truncated"]').text())
.toContain('仅展示最近 2 条,另有 12 条未显示');
});
it('falls back to generic truncated hint when hasMoreHistory but no reliable hidden count', async () => {
const wrapper = mount(ShippingConversationProcessingCard, {
props: {
projection: buildProjection(),
hasMoreHistory: true,
},
global: { plugins: [i18n] },
});
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-history-more"]').exists()).toBe(false);
await wrapper.find('[data-testid="shipping-processing-history-toggle"]').trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-history-truncated"]').text())
.toContain('列表已截断,仅展示最近任务');
});
it('keeps processing-record cards read-only without primary CTA or progress', async () => {
const wrapper = mount(ShippingConversationProcessingCard, {
props: {
projection: buildProjection(),
workItems: [
buildWorkItem('OT-DONE', { status: 'completed', stage: 'completed' }),
],
},
global: { plugins: [i18n] },
});
await flushPromises();
await wrapper.find('[data-testid="shipping-processing-history-toggle"]').trigger('click');
await flushPromises();
const doneCard = wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]');
expect(doneCard.find('[data-testid="sidebar-progress-inline"]').exists()).toBe(false);
expect(doneCard.find('[data-testid="shipping-processing-task-actions"]').exists()).toBe(false);
expect(doneCard.find('[data-testid="shipping-processing-action-view_details"]').exists()).toBe(true);
expect(doneCard.find('[data-testid="shipping-processing-action-cancel_task"]').exists()).toBe(false);
});
it('uses expand-files as the only detail entry when canExpandFileDetails', async () => {
const wrapper = mount(ShippingConversationProcessingCard, {
props: {
projection: {
@@ -151,12 +235,49 @@ describe('ShippingConversationProcessingCard', () => {
await flushPromises();
expect(wrapper.text()).toContain('订单识别任务');
expect(wrapper.text()).toContain('2 个 PDF');
expect(wrapper.text()).toContain('4518838152.pdf、4518838154.pdf');
expect(wrapper.text()).toContain('取消整个任务');
// 主标题不得单独伪装成首个 PDF 文件名任务。
expect(wrapper.text()).toContain('主文件:4518838152.pdf');
const titleEl = wrapper.find('[data-testid="shipping-processing-task-OT-MULTI"] .text-sm.font-semibold');
expect(titleEl.text()).toContain('订单识别任务');
expect(titleEl.text()).not.toContain('4518838152.pdf');
// UI-02:有文件对象时不双开「查看详情」与「展开文件详情」。
expect(wrapper.find('[data-testid="shipping-processing-expand-files"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-action-view_details"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-action-cancel_task"]').exists()).toBe(false);
await wrapper.find('[data-testid="shipping-processing-expand-files"]').trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-task-overflow-actions"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-action-cancel_task"]').text()).toContain('取消整个任务');
});
it('shows view_details when task cannot expand file details, and keeps cancel as overflow', async () => {
const wrapper = mount(ShippingConversationProcessingCard, {
props: {
projection: {
summary: { total_tasks: 1, processing: 0, needs_action: 1, completed: 0, history: 0 },
needs_action: [{
user_task_no: 'OT-SINGLE',
group: 'needs_action',
status_label: 'pending_review',
file_count: 1,
run_no: 'RUN-SINGLE',
can_append: false,
available_actions: ['view_details', 'cancel_task'],
objects: [],
}],
processing: [],
completed: [],
history: [],
},
},
global: { plugins: [i18n] },
});
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-expand-files"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-action-view_details"]').exists()).toBe(true);
// 无文件对象时取消可直接挂在卡上(低频文字链,非主 CTA)。
expect(wrapper.find('[data-testid="shipping-processing-task-overflow-actions"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-action-cancel_task"]').exists()).toBe(true);
});
it('shows multi-document title from authoritative projection without workflow fallback', async () => {
@@ -192,7 +313,7 @@ describe('ShippingConversationProcessingCard', () => {
expect(titleEl.text()).not.toContain('4518838152.pdf');
});
it('falls back to unnamed PDF instead of internal OT number', async () => {
it('uses unified order recognition title instead of internal OT number', async () => {
const wrapper = mount(ShippingConversationProcessingCard, {
props: {
projection: {
@@ -214,7 +335,7 @@ describe('ShippingConversationProcessingCard', () => {
global: { plugins: [i18n] },
});
await flushPromises();
expect(wrapper.text()).toContain('未命名 PDF');
expect(wrapper.text()).toContain('订单识别任务');
expect(wrapper.text()).not.toContain('20260803-A13F95D2');
});
@@ -242,7 +363,6 @@ describe('ShippingConversationProcessingCard', () => {
});
await flushPromises();
const needCard = wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]');
// 关键断言:待操作聚焦卡必须有用户可见 ring,不能只写 data-focused。
expect(needCard.attributes('data-focused')).toBe('1');
expect(needCard.classes().join(' ')).toContain('ring-brand-400');
const other = wrapper.find('[data-testid="shipping-processing-task-OT-PROC"]');
@@ -264,12 +384,10 @@ describe('ShippingConversationProcessingCard', () => {
global: { plugins: [i18n] },
});
await flushPromises();
const taskRoot = wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]');
const buttons = taskRoot.findAll('button');
// 最后一个按钮是展开/收起文件详情
await buttons[buttons.length - 1].trigger('click');
const expandBtn = wrapper.find('[data-testid="shipping-processing-expand-files"]');
await expandBtn.trigger('click');
expect(wrapper.emitted('expandFiles')?.[0]?.[0]).toMatchObject({ user_task_no: 'OT-NEED' });
await buttons[buttons.length - 1].trigger('click');
await expandBtn.trigger('click');
expect(wrapper.emitted('collapseFiles')).toBeTruthy();
});
@@ -294,7 +412,7 @@ describe('ShippingConversationProcessingCard', () => {
global: { plugins: [i18n] },
});
await flushPromises();
expect(wrapper.findAll('[data-testid^="shipping-processing-task-"]')).toHaveLength(20);
expect(wrapper.findAll('article[data-testid^="shipping-processing-task-"]')).toHaveLength(20);
expect(wrapper.findAll('[data-testid="shipping-conversation-processing-card"]')).toHaveLength(1);
});
@@ -344,7 +462,6 @@ describe('ShippingConversationProcessingCard', () => {
expect(wrapper.find('[data-testid="shipping-processing-group-order-intake"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-intake-SNI-1"]').exists()).toBe(true);
expect(wrapper.text()).toContain('po.pdf');
// 关键断言:失败恢复元信息(原因 / Attempt / 资产)出现在材料卡。
expect(wrapper.find('[data-testid="shipping-processing-intake-recovery"]').exists()).toBe(true);
expect(wrapper.text()).toContain('SHIPPING_NOTICE.INTAKE_PARSE_FAILED');
await wrapper.find('[data-testid="shipping-processing-intake-action-retry_parse"]').trigger('click');
@@ -354,7 +471,7 @@ describe('ShippingConversationProcessingCard', () => {
});
});
it('renders each PDF task with its own compact projection, including completed tasks', async () => {
it('hides task-level primary/secondary when workItem exists but keeps expand-files entry', async () => {
const projection = buildProjection();
const wrapper = mount(ShippingConversationProcessingCard, {
props: {
@@ -367,23 +484,19 @@ describe('ShippingConversationProcessingCard', () => {
buildWorkItem('OT-PROC', {
stage: 'inventory_matching',
}),
buildWorkItem('OT-DONE', {
status: 'completed',
stage: 'completed',
}),
],
},
global: { plugins: [i18n] },
});
await flushPromises();
// 未聚焦时:needs_action/processing 显示紧凑进度;已完成默认收起(UI-05)。
expect(wrapper.findAll('[data-testid="sidebar-progress-inline"]')).toHaveLength(2);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"] [data-testid="sidebar-progress-inline"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]').text()).toContain('待复核');
expect(wrapper.find('[data-testid="shipping-processing-task-OT-PROC"]').text()).toContain('库存匹配');
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]').text()).toContain('已完成');
expect(wrapper.findAll('[data-testid="shipping-processing-task-actions"]')).toHaveLength(0);
// UI-02:有 workItem 时仍保留展开文件详情(OT-NEED 为多文件)。
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"] [data-testid="shipping-processing-expand-files"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"] [data-testid="shipping-processing-action-view_details"]').exists()).toBe(false);
});
it('maps internal review_case_draft status to a user-facing review label', async () => {