| null }) {
const { t, te } = useI18n();
const stageLabel = computed(() => {
const projection = props.processingProjection;
if (!projection) return '';
return resolveShippingProcessingStageLabel(
String(projection.stage || ''),
te,
t,
projection.stageLabelKey != null
? String(projection.stageLabelKey)
: null,
);
});
return { stageLabel };
},
template:
''
+ '{{ stageLabel }}'
+ '
',
},
};
});
/**
* 挂载复核工作台视图并注入最小 Chat 上下文。
*/
async function mountView() {
const i18n = createI18n({
legacy: false,
locale: 'zh-CN',
messages: {
'zh-CN': {
chat: {
shippingOrderReview: {
title: '订单人工复核',
run: '识别批次 {runNo}',
workItemHeader: '{itemNo} {version}',
backToSession: '返回',
readOnly: '只读',
loading: '加载中',
unavailable: '不可用',
retryLoad: '重试',
caseSwitchLoading: '正在加载当前 PDF…',
caseSwitchFailed: '当前 PDF 加载失败,可重试',
caseSwitchRetry: '重试',
documentNavigation: 'PDF 导航',
documents: 'PDF',
unnamedDocument: '未命名',
caseStatus: '{status} · {count}',
caseStatuses: { draft: '草稿', unknown: '未知' },
previewTitle: 'PDF 预览',
previewLoading: '加载 PDF',
previewUnavailable: '无预览',
locateSource: '定位 {field}',
locateUnavailableHint: '无可靠坐标,点击查看诊断',
locateCandidateHint: '候选位置',
dblclickLocateHint: '双击定位',
exceptionNav: {
prev: '上一异常',
next: '下一异常',
prevHint: '上一异常',
nextHint: '下一异常',
},
issues: '问题',
highlightQuality: {
verified: '已验证',
candidate: '候选',
unavailable: '无坐标',
invalid: '无效',
},
orderFields: '订单字段',
schemaVersion: 'V{version}',
lines: '明细',
line: '行 {index}',
noLines: '无明细',
noMachineOrder: '无订单',
createManualDraft: '手工建草稿',
markNonOrder: '非订单',
markQualityIssue: '质量异常',
reparse: '重新识别',
uploadReplacement: '替换 PDF',
saveNow: '保存并校验',
confirmCreate: '确认并建单',
restoreMachine: '恢复',
moreFields: '更多 {count}',
moreLineFields: '更多列 {count}',
collapseFields: '收起',
addLine: '新增行',
copyLine: '复制行',
deleteLine: '删除行',
emptyValue: '空',
valueSources: { machine: '系统' },
primaryBlockTitle: '阻断',
primaryBlockParty: '{party}',
versionHistory: { title: '版本历史' },
auditTrail: { open: '查看审计' },
customerResolution: {
title: '客户确认',
unresolved: '未确认',
confirmed: '已确认',
select: '选择客户',
search: '搜索',
empty: '无候选',
confirm: '确认',
cancel: '取消',
},
workbench: {
mode: {
standard: '标准复核',
evidence: '证据核对',
inventory: '库存处理',
reparse: '重新识别',
confirm_progress: '建单进度',
},
moreStatus: '更多状态',
enterInventory: '查看库存问题',
returnStandard: '返回标准复核',
openPdf: '打开 PDF',
closePdf: '关闭 PDF',
pinPdf: '退出后保留',
unpinPdf: '退出后关闭',
pinPdfHint: '退出证据模式后仍保留 PDF 打开(不会固定在视口)',
unpinPdfHint: '退出证据模式时关闭 PDF',
openVersionHistory: '版本历史',
auditFailed: '审计记录失败,敏感面板未打开,请重试',
summaryRail: '摘要',
actionSuccess: '已完成',
resultNotReady: '结果未就绪',
},
evidenceAt: 'PDF 第 {page} 页',
evidenceNoHighlight: '无坐标',
evidenceDrawer: {
title: '证据核对',
pageUnknown: '页码未知',
prevEvidence: '上一证据',
nextEvidence: '下一证据',
field: '字段:{field}',
currentValue: '当前值',
machineValue: '机器值',
source: '来源',
},
llmSuggestion: { request: '请求 AI' },
restoreMachine: '恢复机器值',
saving: '保存中',
saved: '已保存',
saveFailed: '失败',
versionConflict: { badge: '冲突' },
statusBanner: { unknown: '未知' },
reparseFailedVersion: {
notice: 'V{failedVersion} 重新识别失败,失败阶段:{stage}。当前展示并可继续复核:V{displayedVersion}。',
unknownStage: '未知阶段',
stages: { layout_parsing: '解析 PDF 页面与表格' },
},
reparseProgress: {
title: '重识别',
subtitle: '',
polling: '',
refreshFailed: '',
failed: '',
retry: '',
stages: {
submitted: '1',
layout_parsing: '2',
extracting: '3',
draft_ready: '4',
},
},
autoProgress: {
status: { unknown: '', needs_retry: '待重试', needs_human: '需要人工处理' },
result: '{status}',
checkpoint: '{checkpoint}',
viewTask: '返回对话查看进度',
returnToChat: '返回对话查看进度',
retry: '重试自动推进',
retryObject: '重试',
retrySuccess: '已重新触发',
retryStp: '重试自动推进',
retryStpSuccess: '已重新入队自动建单',
},
conversationRetry: {
title: '对话重试结果',
retried: '已重试',
skipped: '已跳过',
failed: '失败',
closeAndRefresh: '关闭并刷新',
},
currentProcessing: {
title: '当前处理状态',
status: '状态',
formalOt: '正式 OT',
waitingStart: '等待系统启动',
taskMissing: '正式任务关联异常',
taskMissingHint: '正式任务关联异常,请联系管理员',
stateInconsistent: '状态同步中',
statusRunning: '系统处理中',
statusFailedRetryable: '失败可重试',
statusCompleted: '已完成',
statusIdle: '待机',
statusTaskMissing: '关联异常',
stages: {
waiting_system_start: '等待系统启动',
waiting_to_start: '等待系统启动',
order_creating: '等待系统启动',
inventory_matching: '库存匹配',
},
},
automation: {
waitingPreOt: '等待自动建单',
waitingPostOt: '等待系统启动自动推进',
},
buildEligibility: {
confirmBlocked: '不可建单',
autoGateWaitingHint: '资格已达标,等待系统自动建单',
autoGateRunningHint: '系统正在自动推进',
},
fulfillmentDecision: {
actions: '操作',
availableQty: '可用',
shortage: '缺口',
},
lineOps: {
retry: '重试',
moreActions: '更多操作',
inventorySource: '库存源',
},
workflowProgress: {
automatingFooterHint: '系统自动推进中',
},
confirmSuccess: '{taskNo}',
confirmAutoProgress: '{taskNo}',
confirmProgressFailed: '已创建任务 {taskNo},但自动推进失败,请重试推进',
jumpToCurrentVersion: '跳转',
currentVersionUnavailable: '不可用',
},
shippingProcessing: {
stage: {
order_creating: '创建正式订单',
inventory_matching: '库存匹配',
},
stageLabel: {
waiting_system_start: '等待系统启动',
},
},
},
errors: { generic: '错误' },
},
},
});
const router = createRouter({
history: createMemoryHistory(),
routes: [
{ path: '/chat/:agentId', name: 'Chat', component: { template: '' } },
{
path: '/workspace/shipping-tasks/:taskNo',
name: 'workspace-shipping-tasks',
component: { template: '' },
},
],
});
await router.push({ path: '/chat/agent-1', query: { mode: 'order-review', run_no: 'RUN-1' } });
await router.isReady();
const wrapper = mount(ShippingOrderReviewView, {
global: {
plugins: [i18n, router],
provide: {
[CHAT_PAGE_KEY as symbol]: {
conversationId: 'conv-1',
messages: [],
},
},
stubs: {
ReviewActionConfirmDialog: {
name: 'ReviewActionConfirmDialog',
props: ['action', 'modelValue', 'confirmLoading'],
emits: ['confirm', 'cancel', 'update:modelValue'],
template:
''
+ ''
+ '
',
},
ReviewLineNoOverrideDialog: true,
ReviewDocumentEvidenceDrawer: evidenceDrawerStub,
},
},
});
await flushPromises();
return wrapper;
}
/** 将共享 Case fixture 恢复为可编辑草稿,避免跨用例污染确认恢复态。 */
function resetActiveCaseFixture() {
activeCase.value = {
...activeCase.value,
status: 'draft',
confirmed_task_no: null,
confirmed_task_id: null,
has_formal_ot: false,
task_missing: false,
recovery_available: null,
post_confirm_auto_progress: null,
process_gate: null,
current_stage: null,
technical_progress: null,
automation: { status: 'idle', can_auto_create: false, can_build: true },
available_actions: ['validate', 'confirm', 'mark_non_order', 'reparse'],
profile_match: { available: false, visibility: 'admin_only', candidates: [] },
};
shippingProcessingProjection.value = null;
}
describe('ShippingOrderReviewView layout phase 1', () => {
beforeEach(() => {
vi.clearAllMocks();
resetActiveCaseFixture();
workItem.value = null;
reviewProgressContext.value = null;
});
it('uses the current-task card as the only Gate action entry for every formal-OT Gate', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed',
has_formal_ot: true,
task_missing: false,
confirmed_task_id: 88,
confirmed_task_no: 'SN-GATE-1',
process_gate: {
execution_no: 'EXEC-GATE-1',
status: 'blocked',
owner_type: 'human',
technical_auto_only: false,
current_blocking_gate: { gate_code: 'customer_confirmation', status: 'blocked' },
primary_action: {
code: 'confirm_customer',
label_key: 'chat.shippingNotice.processGate.actionCodes.confirm_customer',
kind: 'current_gate',
dispatch: 'mutation',
},
},
automation: { status: 'manual_fallback', can_auto_create: false, can_build: true },
};
const wrapper = await mountView();
await flushPromises();
// 任意正式 OT Gate 的可执行入口只保留在“当前任务”;待处理事项只读说明仍保留。
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="mock-process-gate"]').attributes('data-actions')).toBe('hidden');
});
it('does not revive a Case Gate action when the formal OT ui_state explicitly has no action', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed', has_formal_ot: true, task_missing: false,
confirmed_task_id: 89, confirmed_task_no: 'SN-NO-ACTION-1',
process_gate: {
execution_no: 'EXEC-NO-ACTION-1', status: 'blocked', owner_type: 'human', technical_auto_only: false,
current_blocking_gate: { gate_code: 'customer_confirmation', status: 'blocked' },
primary_action: { code: 'confirm_customer', label_key: 'chat.shippingNotice.processGate.actionCodes.confirm_customer' },
},
automation: { status: 'running', can_auto_create: false, can_build: true },
};
shippingProcessingProjection.value = {
workItemType: 'order_task', workItemNo: 'SN-NO-ACTION-1', sourceType: 'direct_pdf',
rootOrderTaskNo: 'SN-NO-ACTION-1', shippingNoticeNo: 'SN-NO-ACTION-1', conversationId: 'conv-1',
submissionNo: 'SUB-NO-ACTION', intakeNo: 'SNI-NO-ACTION', status: 'processing', stage: 'order_creating',
progressVersion: 1, lastActivityAt: '2026-08-14T00:00:00Z', currentGate: null, availableActions: ['confirm_customer'],
sourceSummary: { emailSubject: null, filename: 'no-action.pdf', documentCount: 1, parsedDocumentCount: 1, candidateCount: 1, customerName: null, poNumber: null },
childOrderTasks: [], uiState: { status: 'processing', stage: 'order_creating', blocking_reason: null, primary_action: null, secondary_actions: [] },
};
const wrapper = await mountView();
await flushPromises();
// 正式 OT 已有后端 ui_state,Case Gate 只是诊断/建单前兼容来源,不能复活按钮。
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
});
it('shows restored version as current and latest version only as failed attempt', async () => {
reviewProgressContext.value = {
item_no: 'WFI-1',
current_version_no: 4,
lifecycle_status: 'reparse_failed',
displayed_version: { version_no: 3, run_no: 'RUN-3', case_no: 'CASE-1', status: 'restored' },
latest_attempt: {
version_no: 4,
run_no: 'RUN-4',
status: 'failed',
failure_stage: 'layout_parsing',
error_code: 'SHIPPING_NOTICE.ORDER_EXTRACTION_LAYOUT_FAILED',
},
};
const wrapper = await mountView();
const notice = wrapper.find('[data-testid="review-reparse-failed-version-notice"]');
expect(notice.text()).toContain('V4 重新识别失败');
expect(notice.text()).toContain('解析 PDF 页面与表格');
expect(notice.text()).toContain('V3');
// 关键断言:顶栏当前版本跟随旧成功结果 V3,禁止把旧字段标成失败尝试 V4。
expect(wrapper.text()).toContain('WFI-1');
expect(wrapper.text()).toContain('V3');
});
it('does not show reparse-failure version notice for normal review', async () => {
reviewProgressContext.value = {
item_no: 'WFI-1', current_version_no: 3, lifecycle_status: 'pending_review',
};
const wrapper = await mountView();
expect(wrapper.find('[data-testid="review-reparse-failed-version-notice"]').exists()).toBe(false);
});
it('renders main editor + summary rail without chat context toggle', async () => {
const wrapper = await mountView();
expect(wrapper.find('[data-testid="shipping-order-review-view"]').attributes('data-workbench-mode')).toBe('standard');
expect(wrapper.find('[data-testid="review-main-editor"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-build-gate-rail"]').exists()).toBe(true);
// 单 OT/PDF:产品规则隐藏文档导航(mode=hidden),不得断言节点存在。
expect(wrapper.find('[data-testid="review-document-navigation"]').exists()).toBe(false);
// 标准复核不展示仅含标题的空模式条,避免占用主编辑区高度。
expect(wrapper.find('[data-testid="review-workbench-mode"]').exists()).toBe(false);
expect(wrapper.text()).not.toContain('对话上下文');
expect(wrapper.html()).not.toContain('showContext');
expect(wrapper.html()).not.toContain('hideContext');
});
it('hides PDF evidence drawer in standard mode by default', async () => {
const wrapper = await mountView();
expect(wrapper.find('[data-testid="review-document-evidence-drawer"]').exists()).toBe(false);
});
it('keeps footer actions without confirm-create when draft exists', async () => {
const wrapper = await mountView();
// 关键断言:底栏仍在,但正常路径不再暴露「确认并创建任务」。
expect(wrapper.find('[data-testid="review-footer-actions"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-confirm-create"]').exists()).toBe(false);
});
it('renders a persistent result panel for a completed formal task', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed',
confirmed_task_no: 'SN-MOCK',
confirmed_task_id: 1,
has_formal_ot: true,
current_stage: { code: 'completed', label_key: 'completed' },
automation: { status: 'completed', can_auto_create: false, can_build: false },
};
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValueOnce({
task_no: 'SN-MOCK',
status: 'completed',
upload_status: 'uploaded',
upload_status: 'uploaded',
lines: [],
line_results: [{
part_number: 'PN-1', reservation_id: 'RES-1', required_qty: 2,
available_qty: 2, shortage_qty: 0, line_status: 'ok',
}],
export_artifacts: [{ id: 1, artifact_no: 'EXP-1', status: 'ready', file_name: 'result.xlsx' }],
events: [],
ui_state: { action_buttons: [], summary: {}, process_gate: null },
} as any);
const wrapper = await mountView();
expect(wrapper.find('[data-testid="review-formal-task-result-region"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-formal-task-result-panel"]').text()).toContain('PN-1');
expect(wrapper.find('[data-testid="review-formal-task-result-download"]').exists()).toBe(true);
});
it('renders empty optional schema fields as editable line columns', async () => {
const wrapper = await mountView();
const inputs = wrapper.findAll('[data-testid="review-line-field-input"]');
// 关键断言:库存源线索即使非必填且尚无机器值,也必须作为 Schema 列显示并可编辑。
expect(wrapper.text()).toContain('库存源线索');
expect(inputs).toHaveLength(1);
expect(inputs[0].attributes('disabled')).toBeUndefined();
});
it('does not render resident AI card without focused field', async () => {
const wrapper = await mountView();
expect(wrapper.find('[data-testid="review-llm-field-entry"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="mock-llm-drawer"]').exists()).toBe(true);
expect(wrapper.html()).not.toContain('panelTitle');
});
it('opens evidence PDF drawer only via locate action, not via input focus', async () => {
const wrapper = await mountView();
const input = wrapper.find('[data-testid="review-header-field-input"]');
expect(input.exists()).toBe(true);
await input.trigger('focus');
await flushPromises();
expect(wrapper.find('[data-testid="shipping-order-review-view"]').attributes('data-workbench-mode')).toBe('standard');
expect(wrapper.find('[data-testid="review-document-evidence-drawer"]').exists()).toBe(false);
const locate = wrapper.find('[data-testid="review-field-locate"]');
expect(locate.exists()).toBe(true);
await locate.trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="shipping-order-review-view"]').attributes('data-workbench-mode')).toBe('evidence');
expect(wrapper.find('[data-testid="review-document-evidence-drawer"]').exists()).toBe(true);
// 关键断言:定位后字段与 PDF 证据联动高亮。
expect(wrapper.find('[data-testid="review-header-field-input"]').attributes('data-evidence-active')).toBe('true');
});
it('opens evidence PDF drawer via field double-click', async () => {
const wrapper = await mountView();
const input = wrapper.find('[data-testid="review-header-field-input"]');
await input.trigger('dblclick');
await flushPromises();
// 关键断言:双击字段等价于定位原文,进入证据模式。
expect(wrapper.find('[data-testid="shipping-order-review-view"]').attributes('data-workbench-mode')).toBe('evidence');
expect(wrapper.find('[data-testid="review-document-evidence-drawer"]').exists()).toBe(true);
});
it('navigates exception fields from the summary rail', async () => {
activeCase.value = {
...activeCase.value,
draft: {
...activeCase.value.draft,
issues: [
{
code: 'required_field_missing',
severity: 'blocking',
field_id: 'fld-po',
message: '缺少 PO',
},
],
},
};
const wrapper = await mountView();
expect(wrapper.find('[data-testid="review-exception-nav"]').exists()).toBe(true);
await wrapper.find('[data-testid="review-exception-next"]').trigger('click');
await flushPromises();
// 关键断言:异常导航会打开证据并定位到问题字段。
expect(wrapper.find('[data-testid="shipping-order-review-view"]').attributes('data-workbench-mode')).toBe('evidence');
expect(wrapper.find('[data-testid="review-header-field-input"]').attributes('data-evidence-active')).toBe('true');
});
it('opens evidence as floating panel without docking editor body layout', async () => {
const wrapper = await mountView();
await wrapper.find('[data-testid="review-field-locate"]').trigger('click');
await flushPromises();
const body = wrapper.find('[data-testid="review-editor-body"]');
const drawer = wrapper.find('[data-testid="review-document-evidence-drawer"]');
// 关键断言:定位证据默认浮窗;主编辑区不切换为 PDF 网格列。
expect(drawer.attributes('data-presentation')).toBe('floating');
expect(body.attributes('data-evidence-docked')).toBe('false');
expect(body.classes()).toContain('space-y-4');
expect(body.classes().some((cls) => cls.includes('minmax(280px'))).toBe(false);
});
});
describe('ShippingOrderReviewView audit and progress recovery', () => {
beforeEach(async () => {
vi.clearAllMocks();
resetActiveCaseFixture();
reviewProgressContext.value = null;
vi.mocked(auditWorkspaceShippingOrderReviewVersionHistory).mockResolvedValue({
audited: true,
case_no: 'CASE-1',
});
vi.mocked(auditWorkspaceShippingOrderReviewEligibilityDetails).mockResolvedValue({
audited: true,
case_no: 'CASE-1',
});
}, 20000);
it('refuses to open version history when access audit fails', async () => {
vi.mocked(auditWorkspaceShippingOrderReviewVersionHistory).mockRejectedValueOnce(new Error('audit down'));
const wrapper = await mountView();
await wrapper.find('[data-testid="review-open-version-history"]').trigger('click');
await flushPromises();
// 关键断言:审计失败有告警且不打开版本历史面板。
expect(wrapper.find('[data-testid="mock-versions-drawer"]').exists()).toBe(false);
expect(messageMocks.warning).toHaveBeenCalledWith('审计记录失败,敏感面板未打开,请重试');
});
it('refuses to open eligibility details when access audit fails', async () => {
vi.mocked(auditWorkspaceShippingOrderReviewEligibilityDetails).mockRejectedValueOnce(new Error('audit down'));
const wrapper = await mountView();
await wrapper.find('[data-testid="review-open-eligibility-details"]').trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="mock-eligibility-details"]').exists()).toBe(false);
expect(messageMocks.warning).toHaveBeenCalledWith('审计记录失败,敏感面板未打开,请重试');
});
it('restores object-level retry from post_confirm_auto_progress after reload', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed',
has_formal_ot: true,
task_missing: false,
confirmed_task_id: 7,
confirmed_task_no: 'SN-RECOVER-1',
automation: {
status: 'failed',
retryable: true,
phase: 'post_ot_progress',
can_auto_create: false,
can_build: true,
},
post_confirm_auto_progress: {
task_no: 'SN-RECOVER-1',
needs_retry: true,
status: 'needs_retry',
message: '已建单但任务仍停在待推进,可重试自动推进',
},
};
const wrapper = await mountView();
await flushPromises();
// 关键断言:琥珀色确认条已移除;刷新后对象级重试挂在当前处理卡。
expect(wrapper.find('[data-testid="review-confirm-outcome"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="retry-auto-progress-after-confirm"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-current-processing-ot"]').text()).toContain('SN-RECOVER-1');
}, 15000);
it('retries formal OT via unified /retry from main card after refresh without confirmSuccess (UI-01)', async () => {
// 关键断言:刷新后无 confirmSuccess 时,主卡仍用 confirmed_task_no 调统一 /retry(禁止 auto-progress)。
vi.mocked(retryWorkspaceShippingTask).mockClear();
activeCase.value = {
...activeCase.value,
status: 'confirmed',
has_formal_ot: true,
task_missing: false,
confirmed_task_id: 42,
confirmed_task_no: 'SN-OT-FAIL-1',
current_stage: { code: 'order_creating', inconsistent: false },
automation: {
status: 'failed',
retryable: true,
phase: 'post_ot_progress',
can_auto_create: false,
can_build: true,
},
post_confirm_auto_progress: {
task_no: 'SN-OT-FAIL-1',
needs_retry: true,
status: 'needs_retry',
},
};
const wrapper = await mountView();
await flushPromises();
const retryBtn = wrapper.find('[data-testid="review-current-processing-retry"]');
expect(retryBtn.exists()).toBe(true);
await retryBtn.trigger('click');
await flushPromises();
expect(retryWorkspaceShippingTask).toHaveBeenCalledWith('SN-OT-FAIL-1');
}, 15000);
it('keeps top / wide / narrow stage labels identical via Progress projection (waiting_system_start)', async () => {
// 关键断言:Case.current_stage 故意降级为误导码;三处必须消费 Progress label_key 文案。
shippingProcessingProjection.value = {
workItemType: 'order_task',
workItemNo: 'OT-WAIT-1',
sourceType: 'eml',
rootOrderTaskNo: 'OT-WAIT-1',
shippingNoticeNo: 'SN-WAIT-1',
conversationId: 'conv-1',
submissionNo: 'SUB-1',
intakeNo: 'INT-1',
status: 'automating',
stage: 'order_creating',
stageLabelKey: 'waiting_system_start',
progressVersion: 1,
lastActivityAt: '2026-08-07T00:00:00Z',
currentGate: null,
availableActions: [],
sourceSummary: {
emailSubject: null,
filename: 'po.pdf',
documentCount: 1,
parsedDocumentCount: 1,
candidateCount: 1,
customerName: null,
poNumber: 'PO-1',
},
childOrderTasks: [],
};
activeCase.value = {
...activeCase.value,
status: 'confirmed',
has_formal_ot: true,
task_missing: false,
confirmed_task_id: 88,
confirmed_task_no: 'SN-WAIT-1',
// 故意与 Progress 文案分叉:若宽屏仍直读 Case code,会显示「库存匹配」。
current_stage: {
code: 'inventory_matching',
label_key: 'inventory_matching',
inconsistent: false,
},
automation: {
status: 'waiting_to_start',
retryable: false,
phase: 'post_ot_progress',
can_auto_create: false,
can_build: true,
},
};
const wrapper = await mountView();
await flushPromises();
const expected = '等待系统启动';
const top = wrapper.find('[data-testid="review-progress-stage-label"]');
const cards = wrapper.findAll('[data-testid="review-current-processing-card"]');
expect(top.exists()).toBe(true);
expect(cards.length).toBeGreaterThanOrEqual(2);
expect(top.text()).toContain(expected);
for (const card of cards) {
expect(card.text()).toContain(expected);
expect(card.text()).not.toContain('库存匹配');
expect(card.text()).not.toContain('创建正式订单');
}
});
it('shows STP retry button for failed automation and calls retry API (UI-02)', async () => {
activeCase.value = {
...activeCase.value,
status: 'ready',
confirmed_task_no: null,
available_actions: ['validate', 'retry_stp_auto_create'],
automation: {
status: 'failed',
retryable: true,
can_auto_create: true,
can_build: true,
reason_code: 'stp_job_failed',
},
};
const wrapper = await mountView();
await flushPromises();
// 关键断言:failed 态主卡/底栏露出 STP 重试(非确认后 auto_progress)。
const railBtn = wrapper.find('[data-testid="review-current-processing-retry"]');
const footerBtn = wrapper.find('[data-testid="review-retry-stp-auto-create"]');
expect(railBtn.exists() || footerBtn.exists()).toBe(true);
await (railBtn.exists() ? railBtn : footerBtn).trigger('click');
await flushPromises();
expect(retryWorkspaceShippingOrderStpAutoCreate).toHaveBeenCalledWith('CASE-1');
}, 15000);
it('shows STP retry for manual_fallback without confirm-create (UI-02)', async () => {
activeCase.value = {
...activeCase.value,
status: 'ready',
confirmed_task_no: null,
available_actions: ['validate', 'retry_stp_auto_create'],
automation: {
status: 'manual_fallback',
retryable: true,
can_auto_create: true,
can_build: true,
reason_code: 'stp_waiting_timeout',
},
};
const wrapper = await mountView();
await flushPromises();
expect(
wrapper.find('[data-testid="review-current-processing-retry"]').exists()
|| wrapper.find('[data-testid="review-retry-stp-auto-create"]').exists(),
).toBe(true);
// 关键断言:正常路径不再保留「确认并创建任务」兜底。
expect(wrapper.find('[data-testid="review-confirm-create"]').exists()).toBe(false);
}, 15000);
it('hides profile match panel when profile_match.available is false', async () => {
activeCase.value = {
...activeCase.value,
profile_match: { available: false, visibility: 'admin_only', candidates: [] },
};
const wrapper = await mountView();
await flushPromises();
// 关键断言:普通用户裁剪后 DOM 不得出现模板匹配面板。
expect(wrapper.find('[data-testid="review-profile-match-panel"]').exists()).toBe(false);
});
it('shows profile match panel for admin when profile_match.available is true', async () => {
activeCase.value = {
...activeCase.value,
profile_match: {
available: true,
visibility: 'admin',
status: 'matched',
candidates: [{ profile_id: 1, score: 0.9 }],
selected_profile: { profile_id: 1, profile_code: 'P1' },
},
};
const wrapper = await mountView();
await flushPromises();
expect(wrapper.find('[data-testid="review-profile-match-panel"]').exists()).toBe(true);
}, 15000);
it('hydrates progress-failed retry state from Case projection without confirm UI', async () => {
// 关键断言:无确认建单按钮时,仍可从 post_confirm_auto_progress 恢复对象级重试入口。
activeCase.value = {
...activeCase.value,
status: 'confirmed',
has_formal_ot: true,
task_missing: false,
confirmed_task_id: 55,
confirmed_task_no: 'SN-CONFIRM-PROGRESS-FAIL',
automation: {
status: 'failed',
retryable: true,
phase: 'post_ot_progress',
can_auto_create: false,
can_build: true,
},
post_confirm_auto_progress: {
task_no: 'SN-CONFIRM-PROGRESS-FAIL',
needs_retry: true,
status: 'needs_retry',
message: '入队失败',
},
};
const wrapper = await mountView();
await flushPromises();
expect(wrapper.find('[data-testid="review-confirm-create"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-current-processing-ot"]').text()).toContain('SN-CONFIRM-PROGRESS-FAIL');
}, 15000);
});
describe('ShippingOrderReviewView viewport layout remediation', () => {
beforeEach(() => {
vi.clearAllMocks();
resetActiveCaseFixture();
});
it('uses a single primary vertical scroll container (not nested editor/rail scroll)', async () => {
const wrapper = await mountView();
const scroll = wrapper.find('[data-testid="review-workbench-scroll"]');
const editor = wrapper.find('[data-testid="review-main-editor"]');
const rail = wrapper.find('[data-testid="review-build-gate-rail"]');
// 关键断言:仅外层主滚动带 overflow-y-auto;编辑区与摘要栏不得再套纵向滚动。
expect(scroll.classes()).toContain('overflow-y-auto');
expect(editor.classes()).not.toContain('overflow-y-auto');
expect(rail.classes()).not.toContain('overflow-y-auto');
expect(editor.classes()).not.toContain('xl:max-h-[calc(100vh-12rem)]');
});
it('keeps footer sticky for always-visible actions', async () => {
const wrapper = await mountView();
const footer = wrapper.find('[data-testid="review-footer-actions"]');
expect(footer.classes()).toContain('sticky');
expect(footer.classes()).toContain('bottom-0');
});
it('keeps summary rail visible in floating evidence mode and docks only on demand', async () => {
const wrapper = await mountView();
await wrapper.find('[data-testid="review-field-locate"]').trigger('click');
await flushPromises();
const rail = wrapper.find('[data-testid="review-build-gate-rail"]');
// 关键断言:浮窗证据不再为挤 PDF 而隐藏摘要栏。
expect(rail.classes()).not.toContain('hidden');
expect(rail.classes()).toContain('xl:sticky');
await wrapper.find('[data-testid="review-evidence-toggle-dock"]').trigger('click');
await flushPromises();
const body = wrapper.find('[data-testid="review-editor-body"]');
const drawer = wrapper.find('[data-testid="review-document-evidence-drawer"]');
// 关键断言:用户主动固定后才进入双栏网格。
expect(body.attributes('data-evidence-docked')).toBe('true');
expect(drawer.attributes('data-docked')).toBe('true');
expect(wrapper.html()).toContain('minmax(420px,1fr)');
});
});