feat(shipping-notice): 收敛复核阶段同源投影与 OT 后履约推进
统一 Case/Progress 阶段 label_key、修复 Job 成功未推进 OT 的可重试失败投影与写路径,并落地 OT 后行级匹配/波次履约与版面诊断开关。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
74270adc22
commit
fd6a23f870
100 files changed
+12138
-1017
No files matched your search
@@ -15,6 +15,7 @@ import { CHAT_PAGE_KEY } from '@/features/chat/composables/chat.context';
|
||||
import {
|
||||
auditWorkspaceShippingOrderReviewEligibilityDetails,
|
||||
auditWorkspaceShippingOrderReviewVersionHistory,
|
||||
autoProgressWorkspaceShippingTask,
|
||||
retryWorkspaceShippingOrderStpAutoCreate,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
|
||||
@@ -63,6 +64,8 @@ const reviewRun = ref({
|
||||
});
|
||||
const workItem = ref<Record<string, any> | null>(null);
|
||||
const reviewProgressContext = ref<Record<string, any> | null>(null);
|
||||
/** 与 activeCase 同源共享,供断言 Progress 优先阶段源。 */
|
||||
const shippingProcessingProjection = ref<Record<string, any> | null>(null);
|
||||
|
||||
const activeCase = ref({
|
||||
case_no: 'CASE-1',
|
||||
@@ -125,9 +128,26 @@ vi.mock('@/features/chat/api/shipping.api', async (importOriginal) => {
|
||||
};
|
||||
});
|
||||
|
||||
/** mock 工厂句柄:vi.mock 提升后由下方 createReviewComposableMock 赋值。 */
|
||||
const reviewComposableMockApi = vi.hoisted(() => ({
|
||||
create: null as null | (() => Record<string, unknown>),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/chat/shipping-review/useShippingOrderReview', () => ({
|
||||
REVIEW_BUILD_ELIGIBILITY_BLOCKED: 'SHIPPING.REVIEW_BUILD_ELIGIBILITY_BLOCKED',
|
||||
useShippingOrderReview: () => ({
|
||||
useShippingOrderReview: () => {
|
||||
if (!reviewComposableMockApi.create) {
|
||||
throw new Error('createReviewComposableMock not initialized');
|
||||
}
|
||||
return reviewComposableMockApi.create();
|
||||
},
|
||||
}));
|
||||
|
||||
/**
|
||||
* 统一维护 useShippingOrderReview mock 契约,避免新增返回字段时漏改。
|
||||
*/
|
||||
function createReviewComposableMock() {
|
||||
return {
|
||||
reviewRun,
|
||||
activeCase,
|
||||
reviewProgressContext,
|
||||
@@ -152,6 +172,7 @@ vi.mock('@/features/chat/shipping-review/useShippingOrderReview', () => ({
|
||||
caseSwitchFailed: ref(false),
|
||||
requestedCaseNo: ref(null),
|
||||
saving: ref(false),
|
||||
validationInProgress: ref(false),
|
||||
saveFailed: ref(false),
|
||||
versionsLoading: ref(false),
|
||||
evidence: ref([
|
||||
@@ -204,7 +225,7 @@ vi.mock('@/features/chat/shipping-review/useShippingOrderReview', () => ({
|
||||
isWorkItemClosed: computed(() => false),
|
||||
showWorkflowProgress: computed(() => false),
|
||||
workflowProgressPolling: computed(() => false),
|
||||
shippingProcessingProjection: ref(null),
|
||||
shippingProcessingProjection,
|
||||
shippingProcessingLoading: ref(false),
|
||||
shippingProcessingError: ref(null),
|
||||
refreshShippingProcessing: vi.fn(),
|
||||
@@ -218,8 +239,10 @@ vi.mock('@/features/chat/shipping-review/useShippingOrderReview', () => ({
|
||||
reparseLastRefreshedAt: computed(() => null),
|
||||
reparseStalePolls: computed(() => 0),
|
||||
refreshReparseProgress: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
||||
reviewComposableMockApi.create = createReviewComposableMock;
|
||||
|
||||
vi.mock('@/shared/composables/useMessage', () => ({
|
||||
useMessage: () => messageMocks,
|
||||
@@ -299,12 +322,39 @@ vi.mock('../components/shipping-review/ReviewVersionHistoryDrawer.vue', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('../components/shipping-review/ReviewWorkflowProgressPanel.vue', () => ({
|
||||
default: {
|
||||
name: 'ReviewWorkflowProgressPanel',
|
||||
template: '<div data-testid="mock-progress" />',
|
||||
},
|
||||
}));
|
||||
vi.mock('../components/shipping-review/ReviewWorkflowProgressPanel.vue', async () => {
|
||||
const { computed } = await import('vue');
|
||||
const { useI18n } = await import('vue-i18n');
|
||||
const { resolveShippingProcessingStageLabel } = await import(
|
||||
'@/features/chat/shipping/shippingProcessingLabels'
|
||||
);
|
||||
return {
|
||||
default: {
|
||||
name: 'ReviewWorkflowProgressPanel',
|
||||
props: ['processingProjection', 'hasFormalOt', 'polling'],
|
||||
setup(props: { processingProjection?: Record<string, unknown> | 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:
|
||||
'<div data-testid="mock-progress">'
|
||||
+ '<span data-testid="review-progress-stage-label">{{ stageLabel }}</span>'
|
||||
+ '</div>',
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* 挂载复核工作台视图并注入最小 Chat 上下文。
|
||||
@@ -462,12 +512,45 @@ async function mountView() {
|
||||
retryStp: '重试自动推进',
|
||||
retryStpSuccess: '已重新入队自动建单',
|
||||
},
|
||||
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: '等待系统启动自动推进',
|
||||
},
|
||||
confirmSuccess: '{taskNo}',
|
||||
confirmAutoProgress: '{taskNo}',
|
||||
confirmProgressFailed: '已创建任务 {taskNo},但自动推进失败,请重试推进',
|
||||
jumpToCurrentVersion: '跳转',
|
||||
currentVersionUnavailable: '不可用',
|
||||
},
|
||||
shippingProcessing: {
|
||||
stage: {
|
||||
order_creating: '创建正式订单',
|
||||
inventory_matching: '库存匹配',
|
||||
},
|
||||
stageLabel: {
|
||||
waiting_system_start: '等待系统启动',
|
||||
},
|
||||
},
|
||||
},
|
||||
errors: { generic: '错误' },
|
||||
},
|
||||
@@ -522,8 +605,18 @@ function resetActiveCaseFixture() {
|
||||
...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,
|
||||
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', () => {
|
||||
@@ -731,6 +824,105 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
|
||||
expect(banner.text()).toContain('SN-RECOVER-1');
|
||||
});
|
||||
|
||||
it('retries formal OT auto-progress from main card after refresh without confirmSuccess (UI-01)', async () => {
|
||||
// 关键断言:刷新后无 confirmSuccess 时,主卡仍用 confirmed_task_no 调 auto-progress API。
|
||||
vi.mocked(autoProgressWorkspaceShippingTask).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(autoProgressWorkspaceShippingTask).toHaveBeenCalledWith('SN-OT-FAIL-1');
|
||||
});
|
||||
|
||||
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,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user