feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3a9fbac2fc
commit
d2b3d74def
571 files changed
+78064
-24681
No files matched your search
@@ -47,4 +47,15 @@ describe('parseOrderReviewConfirmResponse', () => {
|
||||
it('returns null without task_no', () => {
|
||||
expect(parseOrderReviewConfirmResponse(baseResponse({ task_no: null }))).toBeNull();
|
||||
});
|
||||
|
||||
it('prefers order_task_no for focus identity and keeps Notice as taskNo', () => {
|
||||
const parsed = parseOrderReviewConfirmResponse(baseResponse({
|
||||
task_no: 'SN-NOTICE',
|
||||
shipping_notice_no: 'SN-NOTICE',
|
||||
order_task_no: 'OT-ROOT-C102',
|
||||
}));
|
||||
// 关键断言:对话聚焦必须用 OT,不能把 Notice 编号当成 OT。
|
||||
expect(parsed?.taskNo).toBe('SN-NOTICE');
|
||||
expect(parsed?.orderTaskNo).toBe('OT-ROOT-C102');
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,8 @@
|
||||
* features/chat/shipping-review/parseOrderReviewConfirmResponse.ts
|
||||
* 用途:统一解析复核确认建单 API 的业务态,禁止调用方仅凭 HTTP/success/confirm_ok 判定推进成功。
|
||||
* 依赖:ShippingOrderReviewConfirmResponse 类型。
|
||||
* 逻辑:ShippingOrderReviewView / 其他确认调用方共用;与后端 resolve_confirm_outcome 枚举对齐。
|
||||
* 逻辑:ShippingOrderReviewView / 其他确认调用方共用;与后端 resolve_confirm_outcome 枚举对齐;
|
||||
* 同时暴露 shipping_notice_no 与 order_task_no,禁止用 Notice 编号聚焦 OT 卡。
|
||||
*/
|
||||
|
||||
import type { ShippingOrderReviewConfirmResponse } from '@/features/chat/types/shipping.api.types';
|
||||
@@ -16,7 +17,10 @@ export type ShippingOrderReviewConfirmOutcome =
|
||||
|
||||
/** 确认响应解析结果:建单与自动推进解耦。 */
|
||||
export interface ParsedOrderReviewConfirmResult {
|
||||
/** 正式 ShippingNotice 编号(自动推进 / 工作台)。 */
|
||||
taskNo: string;
|
||||
/** Candidate 一对一 OT 编号(对话右侧聚焦)。 */
|
||||
orderTaskNo: string;
|
||||
confirmOk: boolean;
|
||||
confirmOutcome: ShippingOrderReviewConfirmOutcome;
|
||||
/** 自动推进已入队/启动 */
|
||||
@@ -36,17 +40,26 @@ const PROGRESS_FAILED_STATUSES = new Set([
|
||||
|
||||
/**
|
||||
* 解析复核确认响应的业务态。
|
||||
* 核心逻辑:confirm_ok 仅表示建单成功;推进成败读 confirm_outcome / auto_progress.status。
|
||||
* 核心逻辑:confirm_ok 仅表示建单成功;推进成败读 confirm_outcome / auto_progress.status;
|
||||
* focus / 统一进度只认 order_task_no,task_no 仅表示 Notice。
|
||||
*
|
||||
* @param response - confirm API data(非 HTTP envelope)
|
||||
* @returns 解析结果;无 task_no 时返回 null
|
||||
* @returns 解析结果;无 Notice task_no 时返回 null
|
||||
*/
|
||||
export function parseOrderReviewConfirmResponse(
|
||||
response: ShippingOrderReviewConfirmResponse | null | undefined,
|
||||
): ParsedOrderReviewConfirmResult | null {
|
||||
const taskNo = String(response?.task_no || '').trim();
|
||||
const taskNo = String(
|
||||
response?.shipping_notice_no || response?.task_no || '',
|
||||
).trim();
|
||||
if (!taskNo) return null;
|
||||
|
||||
const orderTaskNo = String(
|
||||
response?.order_task_no
|
||||
|| response?.case?.order_task_no
|
||||
|| '',
|
||||
).trim();
|
||||
|
||||
const progressStatus = String(response?.auto_progress?.status || '').trim();
|
||||
const confirmOutcome = String(response?.confirm_outcome || '').trim()
|
||||
|| (PROGRESS_FAILED_STATUSES.has(progressStatus)
|
||||
@@ -63,6 +76,7 @@ export function parseOrderReviewConfirmResponse(
|
||||
|
||||
return {
|
||||
taskNo,
|
||||
orderTaskNo,
|
||||
confirmOk: response?.confirm_ok !== false,
|
||||
confirmOutcome,
|
||||
autoProgressStarted,
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* features/chat/shipping-review/showReviewResumeOutcome.ts
|
||||
* 用途:复核写操作后统一展示 resume_outcome 提示(与 Customer 面板一致)。
|
||||
* 依赖:vue-i18n、ShippingOrderReviewResumeOutcome。
|
||||
* 逻辑:各 Reservation / 冲突 / 重复 / 履约面板在 API 成功后调用本 helper。
|
||||
*/
|
||||
import type { ComposerTranslation } from 'vue-i18n';
|
||||
import type { ShippingOrderReviewResumeOutcome } from '../types/shipping.api.types';
|
||||
|
||||
type ToastApi = {
|
||||
success: (message: string) => void;
|
||||
};
|
||||
|
||||
/**
|
||||
* 按 resume_outcome 展示成功提示;无 outcome 时使用 fallbackSuccess。
|
||||
* 核心逻辑:auto_created/idempotent_replay → 自动建单;waiting_manual_confirm → 待人工确认。
|
||||
* @param resume - 后端统一恢复协调结果
|
||||
* @param msg - useMessage 实例
|
||||
* @param t - vue-i18n translate
|
||||
* @param fallbackSuccess - 无特殊 outcome 时的默认成功文案
|
||||
* @returns 是否已展示 resume 专用提示(调用方可跳过 fallback)
|
||||
*/
|
||||
export function showReviewResumeOutcome(
|
||||
resume: ShippingOrderReviewResumeOutcome | null | undefined,
|
||||
msg: ToastApi,
|
||||
t: ComposerTranslation,
|
||||
fallbackSuccess?: string,
|
||||
): void {
|
||||
const outcome = String(resume?.outcome || '').trim();
|
||||
if (outcome === 'auto_created' || outcome === 'idempotent_replay') {
|
||||
msg.success(t('chat.shippingOrderReview.resume.autoCreated', {
|
||||
taskNo: resume?.task_no || '',
|
||||
}));
|
||||
return;
|
||||
}
|
||||
if (outcome === 'waiting_manual_confirm') {
|
||||
msg.success(t('chat.shippingOrderReview.resume.waitingManualConfirm'));
|
||||
return;
|
||||
}
|
||||
if (fallbackSuccess) {
|
||||
msg.success(fallbackSuccess);
|
||||
}
|
||||
}
|
||||
@@ -54,8 +54,8 @@ const api = vi.hoisted(() => ({
|
||||
|
||||
getPreview: vi.fn(),
|
||||
|
||||
listWorkflows: vi.fn(),
|
||||
getWorkflowItem: vi.fn(),
|
||||
getExtractionRun: vi.fn(),
|
||||
getProcessingWorkItem: vi.fn(),
|
||||
|
||||
reparseDocument: vi.fn(),
|
||||
|
||||
@@ -80,9 +80,8 @@ vi.mock('../api/shipping.api', () => ({
|
||||
|
||||
getWorkspaceShippingOrderReviewPreview: api.getPreview,
|
||||
|
||||
listWorkspaceShippingWorkflows: api.listWorkflows,
|
||||
|
||||
getWorkspaceShippingWorkflowItem: api.getWorkflowItem,
|
||||
getWorkspaceShippingOrderExtractionRun: api.getExtractionRun,
|
||||
getWorkspaceShippingProcessingWorkItem: api.getProcessingWorkItem,
|
||||
|
||||
putWorkspaceShippingOrderReviewInventoryCandidates: api.putInventoryCandidates,
|
||||
postWorkspaceShippingOrderReviewInventoryRoutingReroute: api.rerouteInventoryRouting,
|
||||
@@ -224,17 +223,12 @@ describe('useShippingOrderReview historical readonly', () => {
|
||||
|
||||
|
||||
it('forces readonly when session work item is closed', () => {
|
||||
|
||||
expect(isReviewWorkItemClosed({ lifecycle_status: 'closed', current_case_no: 'CASE-1' })).toBe(true);
|
||||
|
||||
expect(isReviewWorkItemClosed({ lifecycle_status: 'manual_upload_pending', current_case_no: 'CASE-1' })).toBe(false);
|
||||
expect(isReviewReadOnly(
|
||||
|
||||
{ case_no: 'CASE-1', status: 'draft' },
|
||||
|
||||
{ current_case_no: 'CASE-1', lifecycle_status: 'closed' },
|
||||
|
||||
)).toBe(true);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
@@ -377,20 +371,9 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
|
||||
api.getPreview.mockRejectedValue(new Error('preview unavailable'));
|
||||
|
||||
api.listWorkflows.mockResolvedValue({ conversation_id: 'conv-1', workflows: [] });
|
||||
|
||||
api.getWorkflowItem.mockResolvedValue({
|
||||
item_no: 'SWI-1',
|
||||
workflow_no: 'SNWF-1',
|
||||
conversation_id: 'conv-1',
|
||||
root_document_id: 1,
|
||||
current_document_id: 1,
|
||||
current_version_no: 1,
|
||||
current_case_no: 'CASE-1',
|
||||
lifecycle_status: 'pending_review',
|
||||
current_stage: 'pending_review',
|
||||
lock_version: 1,
|
||||
});
|
||||
api.getProcessingWorkItem.mockRejectedValue(
|
||||
Object.assign(new Error('not found'), { name: 'BusinessError', status: 404, code: 'NOT_FOUND' }),
|
||||
);
|
||||
|
||||
api.getCase.mockResolvedValue(buildCase());
|
||||
|
||||
@@ -559,21 +542,23 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
});
|
||||
api.getEvidence.mockResolvedValue({ items: [] });
|
||||
api.getPreview.mockResolvedValue({ preview_url: '' });
|
||||
api.listWorkflows.mockResolvedValue({ conversation_id: 'conv-1', workflows: [] });
|
||||
api.getWorkflowItem.mockResolvedValue({
|
||||
item_no: 'WFI-1',
|
||||
workflow_no: 'WF-1',
|
||||
lifecycle_status: 'building_order',
|
||||
current_stage: 'building_order',
|
||||
current_task_no: 'SN-1',
|
||||
current_version_no: 1,
|
||||
api.getProcessingWorkItem.mockResolvedValueOnce({
|
||||
work_item_no: 'OT-1',
|
||||
status: 'building_order',
|
||||
});
|
||||
api.getProcessingWorkItem.mockResolvedValueOnce({
|
||||
work_item_no: 'OT-1',
|
||||
status: 'completed',
|
||||
});
|
||||
api.confirmCase.mockResolvedValue({
|
||||
task_no: 'SN-1',
|
||||
order_task_no: 'OT-1',
|
||||
shipping_notice_no: 'SN-1',
|
||||
idempotent_replay: false,
|
||||
workflow_id: 'WF-1',
|
||||
workflow_item_id: 'WFI-1',
|
||||
case: { ...readyCase, status: 'confirmed' },
|
||||
order_task_no: 'OT-1',
|
||||
shipping_notice_no: 'SN-1',
|
||||
case: { ...readyCase, status: 'confirmed', order_task_no: 'OT-1' },
|
||||
auto_progress_started: true,
|
||||
});
|
||||
|
||||
@@ -581,56 +566,104 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'WFI-1' });
|
||||
const response = await review.confirm();
|
||||
|
||||
expect(response?.workflow_item_id).toBe('WFI-1');
|
||||
expect(response?.order_task_no).toBe('OT-1');
|
||||
expect(response?.shipping_notice_no || response?.task_no).toBeTruthy();
|
||||
expect(review.reviewProgressContext.value?.user_task_no).toBe('OT-1');
|
||||
expect(review.showWorkflowProgress.value).toBe(true);
|
||||
expect(review.workflowProgressPolling.value).toBe(true);
|
||||
expect(api.getWorkflowItem).toHaveBeenCalled();
|
||||
expect(api.getProcessingWorkItem).toHaveBeenCalled();
|
||||
|
||||
api.getWorkflowItem.mockResolvedValue({
|
||||
item_no: 'WFI-1',
|
||||
workflow_no: 'WF-1',
|
||||
lifecycle_status: 'manual_upload_pending',
|
||||
current_stage: 'manual_upload_pending',
|
||||
current_task_no: 'SN-1',
|
||||
current_version_no: 1,
|
||||
});
|
||||
await vi.advanceTimersByTimeAsync(2600);
|
||||
expect(review.workItem.value?.lifecycle_status).toBe('manual_upload_pending');
|
||||
await Promise.resolve();
|
||||
expect(review.workflowProgressPolling.value).toBe(false);
|
||||
|
||||
review.stopWorkflowProgressPolling();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('does not fall back to extraction run root OT when case has candidate binding', async () => {
|
||||
api.getCase.mockResolvedValue(buildCase({
|
||||
candidate_id: 42,
|
||||
candidate: { candidate_no: 'CAND-42', validation_status: 'ready' },
|
||||
order_task_no: 'OT-CAND',
|
||||
}));
|
||||
api.getRun.mockResolvedValue({
|
||||
run_no: 'RUN-1',
|
||||
summary: {},
|
||||
items: [{ case_no: 'CASE-1', document_id: 1, status: 'draft', available_actions: ['edit_draft'] }],
|
||||
});
|
||||
api.getEvidence.mockResolvedValue({ items: [] });
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1' });
|
||||
|
||||
expect(review.reviewProgressContext.value?.user_task_no).toBe('OT-CAND');
|
||||
expect(review.reviewProgressContext.value?.user_task_authoritative).toBe(true);
|
||||
});
|
||||
|
||||
it('leaves OT unset during reparse polling when candidate-bound case lacks order_task_no', async () => {
|
||||
vi.useFakeTimers();
|
||||
api.getCase.mockResolvedValue(buildCase({
|
||||
candidate_id: 42,
|
||||
candidate: { candidate_no: 'CAND-42', validation_status: 'ready' },
|
||||
}));
|
||||
api.getRun.mockResolvedValue({
|
||||
run_no: 'RUN-1',
|
||||
summary: {},
|
||||
items: [{ case_no: 'CASE-1', document_id: 1, status: 'reparse_pending', available_actions: [] }],
|
||||
});
|
||||
api.getEvidence.mockResolvedValue({ items: [] });
|
||||
api.reparseDocument.mockResolvedValue({
|
||||
run: { run_no: 'RUN-2' },
|
||||
reused: false,
|
||||
});
|
||||
api.getExtractionRun.mockResolvedValue({
|
||||
run_no: 'RUN-2',
|
||||
status: 'extracting',
|
||||
user_task_no: 'OT-ROOT',
|
||||
current_activity: { user_visible_stage: 'extracting' },
|
||||
});
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1' });
|
||||
await review.reparseDocument('layout_issue');
|
||||
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
await Promise.resolve();
|
||||
|
||||
expect(review.reviewProgressContext.value?.user_task_no).toBeNull();
|
||||
expect(review.reviewProgressContext.value?.user_task_authoritative).toBe(false);
|
||||
|
||||
review.stopReparseProgressPolling();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('polls reparse progress and loads the new review version when ready', async () => {
|
||||
vi.useFakeTimers();
|
||||
let reparseStarted = false;
|
||||
let reparsePollCount = 0;
|
||||
api.reparseDocument.mockImplementation(async () => {
|
||||
reparseStarted = true;
|
||||
return { run: { run_no: 'RUN-2', items: [], summary: {} }, reused: false };
|
||||
});
|
||||
api.reparseDocument.mockImplementation(async () => ({
|
||||
run: { run_no: 'RUN-2', items: [], summary: {} },
|
||||
reused: false,
|
||||
}));
|
||||
api.getRun.mockImplementation(async (runNo: string) => ({
|
||||
run_no: runNo,
|
||||
status: runNo === 'RUN-2' ? 'review_required' : 'review_required',
|
||||
summary: {},
|
||||
items: [{ case_no: runNo === 'RUN-2' ? 'CASE-2' : 'CASE-1', status: 'draft', issue_count: 0 }],
|
||||
}));
|
||||
api.getExtractionRun.mockImplementation(async (runNo: string) => {
|
||||
reparsePollCount += 1;
|
||||
const ready = runNo === 'RUN-2' && reparsePollCount >= 2;
|
||||
return {
|
||||
run_no: runNo,
|
||||
status: ready ? 'review_required' : 'extracting',
|
||||
current_activity: { user_visible_stage: ready ? 'review_required' : 'extracting' },
|
||||
};
|
||||
});
|
||||
api.getCase.mockImplementation(async (caseNo: string) => buildCase({
|
||||
case_no: caseNo,
|
||||
run_no: caseNo === 'CASE-2' ? 'RUN-2' : 'RUN-1',
|
||||
}));
|
||||
api.getWorkflowItem.mockImplementation(async () => {
|
||||
if (reparseStarted) reparsePollCount += 1;
|
||||
const ready = reparseStarted && reparsePollCount > 2;
|
||||
return {
|
||||
item_no: 'SWI-1',
|
||||
current_run_no: ready ? 'RUN-2' : 'RUN-1',
|
||||
current_case_no: ready ? 'CASE-2' : 'CASE-1',
|
||||
lifecycle_status: ready ? 'pending_review' : (reparseStarted ? 'extracting' : 'pending_review'),
|
||||
current_stage: ready ? 'pending_review' : (reparseStarted ? 'extracting' : 'pending_review'),
|
||||
current_version_no: ready ? 2 : 1,
|
||||
};
|
||||
});
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'SWI-1' });
|
||||
@@ -638,8 +671,8 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
|
||||
expect(review.reparseProgressActive.value).toBe(true);
|
||||
await vi.advanceTimersByTimeAsync(2600);
|
||||
await Promise.resolve();
|
||||
|
||||
// 关键断言:新版指针就绪后自动停止轮询并加载新的 Run/Case。
|
||||
expect(review.reparseProgressStage.value).toBe('draft_ready');
|
||||
expect(review.reparseProgressPolling.value).toBe(false);
|
||||
expect(review.reviewRun.value?.run_no).toBe('RUN-2');
|
||||
@@ -648,13 +681,49 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('refreshes the work item before resolving the current version target', async () => {
|
||||
it('loads a partially completed reparse result and clears the read-only progress state', async () => {
|
||||
vi.useFakeTimers();
|
||||
api.reparseDocument.mockImplementation(async () => ({
|
||||
run: { run_no: 'RUN-PARTIAL', items: [], summary: {} },
|
||||
reused: false,
|
||||
}));
|
||||
api.getRun.mockImplementation(async (runNo: string) => ({
|
||||
run_no: runNo,
|
||||
status: runNo === 'RUN-PARTIAL' ? 'partially_completed' : 'review_required',
|
||||
summary: {},
|
||||
items: [{ case_no: runNo === 'RUN-PARTIAL' ? 'CASE-PARTIAL' : 'CASE-1', status: 'draft', issue_count: 0 }],
|
||||
}));
|
||||
api.getExtractionRun.mockImplementation(async (runNo: string) => ({
|
||||
run_no: runNo,
|
||||
status: runNo === 'RUN-PARTIAL' ? 'partially_completed' : 'review_required',
|
||||
current_activity: { user_visible_stage: 'review_required' },
|
||||
}));
|
||||
api.getCase.mockImplementation(async (caseNo: string) => buildCase({
|
||||
case_no: caseNo,
|
||||
run_no: caseNo === 'CASE-PARTIAL' ? 'RUN-PARTIAL' : 'RUN-1',
|
||||
}));
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'SWI-1' });
|
||||
api.getWorkflowItem.mockResolvedValue({
|
||||
item_no: 'SWI-1', current_run_no: 'RUN-2', current_case_no: 'CASE-2',
|
||||
lifecycle_status: 'pending_review', current_stage: 'pending_review', current_version_no: 2,
|
||||
});
|
||||
await review.reparseDocument('document_quality');
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
await Promise.resolve();
|
||||
|
||||
expect(review.reviewRun.value?.run_no).toBe('RUN-PARTIAL');
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-PARTIAL');
|
||||
expect(review.reparseProgressStage.value).toBe('draft_ready');
|
||||
expect(review.reparseProgressPolling.value).toBe(false);
|
||||
expect(review.reparseProgressActive.value).toBe(false);
|
||||
expect(review.isReadOnly.value).toBe(false);
|
||||
expect(review.statusMessage.value).not.toBe('reparse_in_progress');
|
||||
review.stopReparseProgressPolling();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('resolves the replacement run when superseded_by_run_no is set', async () => {
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'SWI-1' });
|
||||
review.reviewRun.value!.superseded_by_run_no = 'RUN-2';
|
||||
api.getRun.mockResolvedValue({
|
||||
run_no: 'RUN-2', summary: {}, items: [{ case_no: 'CASE-2', status: 'draft', issue_count: 0 }],
|
||||
});
|
||||
@@ -666,22 +735,49 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-2');
|
||||
});
|
||||
|
||||
it('resolves the replacement run when the historical item still points at the open case', async () => {
|
||||
api.getRun.mockImplementation(async (runNo: string) => runNo === 'RUN-1'
|
||||
? {
|
||||
run_no: 'RUN-1',
|
||||
summary: {},
|
||||
items: [{ case_no: 'CASE-1', status: 'superseded', issue_count: 0 }],
|
||||
}
|
||||
: {
|
||||
run_no: 'RUN-2',
|
||||
summary: {},
|
||||
items: [{ case_no: 'CASE-2', status: 'draft', issue_count: 0 }],
|
||||
});
|
||||
api.getCase.mockImplementation(async (caseNo: string) => buildCase({
|
||||
case_no: caseNo,
|
||||
run_no: caseNo === 'CASE-2' ? 'RUN-2' : 'RUN-1',
|
||||
status: caseNo === 'CASE-2' ? 'draft' : 'superseded',
|
||||
}));
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'SWI-1' });
|
||||
review.reviewRun.value!.superseded_by_run_no = 'RUN-2';
|
||||
const target = await review.openCurrentVersion();
|
||||
|
||||
expect(target).toEqual({ runNo: 'RUN-2', caseNo: 'CASE-2' });
|
||||
expect(review.reviewRun.value?.run_no).toBe('RUN-2');
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-2');
|
||||
});
|
||||
|
||||
it('shows a terminal failed stage when reparse fails', async () => {
|
||||
vi.useFakeTimers();
|
||||
api.reparseDocument.mockResolvedValue({
|
||||
run: { run_no: 'RUN-FAILED', items: [], summary: {} }, reused: false,
|
||||
});
|
||||
api.getWorkflowItem.mockResolvedValue({
|
||||
item_no: 'SWI-1', current_run_no: 'RUN-1', current_case_no: 'CASE-1',
|
||||
lifecycle_status: 'reparse_failed', current_stage: 'reparse_failed', current_version_no: 1,
|
||||
});
|
||||
api.getExtractionRun.mockResolvedValue({ run_no: 'RUN-FAILED', status: 'failed' });
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'SWI-1' });
|
||||
await review.reparseDocument('document_quality');
|
||||
await vi.runAllTicks();
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
await Promise.resolve();
|
||||
await vi.advanceTimersByTimeAsync(2600);
|
||||
await Promise.resolve();
|
||||
|
||||
// 关键断言:失败必须成为明确终态,不能继续伪装为字段提取进行中。
|
||||
expect(review.reparseProgressStage.value).toBe('failed');
|
||||
expect(review.reparseProgressPolling.value).toBe(false);
|
||||
review.stopReparseProgressPolling();
|
||||
@@ -708,18 +804,9 @@ describe('inventory routing recovery', () => {
|
||||
});
|
||||
api.getEvidence.mockResolvedValue({ items: [] });
|
||||
api.getPreview.mockResolvedValue(new Blob());
|
||||
api.listWorkflows.mockResolvedValue({ conversation_id: 'conv-1', workflows: [] });
|
||||
api.getWorkflowItem.mockResolvedValue({
|
||||
item_no: 'WFI-1',
|
||||
workflow_no: 'WF-1',
|
||||
root_document_id: 1,
|
||||
current_document_id: 1,
|
||||
current_version_no: 1,
|
||||
current_case_no: 'CASE-1',
|
||||
lifecycle_status: 'pending_review',
|
||||
current_stage: 'pending_review',
|
||||
lock_version: 1,
|
||||
});
|
||||
api.getProcessingWorkItem.mockRejectedValue(
|
||||
Object.assign(new Error('not found'), { name: 'BusinessError', status: 404, code: 'NOT_FOUND' }),
|
||||
);
|
||||
api.getCase.mockResolvedValue(buildCase());
|
||||
});
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user