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

@@ -15,6 +15,7 @@ import { CHAT_PAGE_KEY } from '@/features/chat/composables/chat.context';
import {
auditWorkspaceShippingOrderReviewEligibilityDetails,
auditWorkspaceShippingOrderReviewVersionHistory,
retryWorkspaceShippingOrderStpAutoCreate,
} from '@/features/chat/api/shipping.api';
const focusSuggestionField = vi.fn();
@@ -105,6 +106,8 @@ const activeCase = ref({
issues: [],
},
process_gate: null,
profile_match: { available: false, visibility: 'admin_only', candidates: [] },
automation: { status: 'idle', can_auto_create: false, can_build: true },
});
vi.mock('@/features/chat/api/shipping.api', async (importOriginal) => {
@@ -114,6 +117,11 @@ vi.mock('@/features/chat/api/shipping.api', async (importOriginal) => {
auditWorkspaceShippingOrderReviewVersionHistory: vi.fn().mockResolvedValue({ audited: true, case_no: 'CASE-1' }),
auditWorkspaceShippingOrderReviewEligibilityDetails: vi.fn().mockResolvedValue({ audited: true, case_no: 'CASE-1' }),
autoProgressWorkspaceShippingTask: vi.fn().mockResolvedValue({ status: 'ok' }),
retryWorkspaceShippingOrderStpAutoCreate: vi.fn().mockResolvedValue({
status: 'queued',
job_id: 901,
case: null,
}),
};
});
@@ -140,6 +148,9 @@ vi.mock('@/features/chat/shipping-review/useShippingOrderReview', () => ({
isReadOnly: computed(() => false),
loading: ref(false),
loadFailed: ref(false),
caseSwitchLoading: ref(false),
caseSwitchFailed: ref(false),
requestedCaseNo: ref(null),
saving: ref(false),
saveFailed: ref(false),
versionsLoading: ref(false),
@@ -314,6 +325,9 @@ async function mountView() {
loading: '加载中',
unavailable: '不可用',
retryLoad: '重试',
caseSwitchLoading: '正在加载当前 PDF…',
caseSwitchFailed: '当前 PDF 加载失败,可重试',
caseSwitchRetry: '重试',
documentNavigation: 'PDF 导航',
documents: 'PDF',
unnamedDocument: '未命名',
@@ -357,11 +371,24 @@ async function mountView() {
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: '标准复核',
@@ -370,6 +397,7 @@ async function mountView() {
reparse: '重新识别',
confirm_progress: '建单进度',
},
moreStatus: '更多状态',
enterInventory: '查看库存问题',
returnStandard: '返回标准复核',
openPdf: '打开 PDF',
@@ -381,6 +409,8 @@ async function mountView() {
openVersionHistory: '版本历史',
auditFailed: '审计记录失败,敏感面板未打开,请重试',
summaryRail: '摘要',
actionSuccess: '已完成',
resultNotReady: '结果未就绪',
},
evidenceAt: 'PDF 第 {page} 页',
evidenceNoHighlight: '无坐标',
@@ -429,6 +459,8 @@ async function mountView() {
returnToChat: '返回对话查看进度',
retry: '重试自动推进',
retrySuccess: '已重新触发',
retryStp: '重试自动推进',
retryStpSuccess: '已重新入队自动建单',
},
confirmSuccess: '{taskNo}',
confirmAutoProgress: '{taskNo}',
@@ -540,7 +572,8 @@ describe('ShippingOrderReviewView layout phase 1', () => {
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);
expect(wrapper.find('[data-testid="review-document-navigation"]').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('对话上下文');
@@ -698,6 +731,77 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
expect(banner.text()).toContain('SN-RECOVER-1');
});
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', 'confirm', '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();
const btn = wrapper.find('[data-testid="review-retry-stp-auto-create"]');
// 关键断言:failed 态必须露出 STP 重试入口(非确认后 auto_progress 重试)。
expect(btn.exists()).toBe(true);
await btn.trigger('click');
await flushPromises();
expect(retryWorkspaceShippingOrderStpAutoCreate).toHaveBeenCalledWith('CASE-1');
});
it('shows STP retry for manual_fallback while keeping confirm fallback (UI-02)', async () => {
activeCase.value = {
...activeCase.value,
status: 'ready',
confirmed_task_no: null,
available_actions: ['validate', 'confirm', '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-retry-stp-auto-create"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-confirm-create"]').exists()).toBe(true);
});
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);
});
it('treats HTTP/confirm_ok success with confirm_outcome failed as progress failure', async () => {
confirmMock.mockResolvedValueOnce({
task_no: 'SN-CONFIRM-PROGRESS-FAIL',