feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程
清理废弃的shipping xfa ocr automark相关代码和job配置 新增收料报表管理的前端页面、路由和侧边栏入口 新增后端收料报表配置接口、数据库模型和RPA脚本 优化发货通知流程的重试策略,将shipping相关job默认不自动重试 移除废弃的库存源确认相关逻辑,更新流程门禁规则 重构订单模板的值适配器模块,新增坐标OCR值适配器 清理前端shipping菜单和action的废弃选项 更新相关文档和测试用例,调整.gitignore忽略规则
This commit is contained in:
1 parent
260465b72d
commit
1b6483a4ea
466 files changed
+32115
-33796
No files matched your search
@@ -2,8 +2,7 @@
|
||||
* features/chat/shipping-review/useShippingOrderReview.spec.ts
|
||||
* 用途:阶段 3 复核页历史版本只读、草稿版本冲突、建单资格门禁、库存候选与路由恢复写入冒烟。
|
||||
* 依赖:isReviewCaseHistorical / isDraftVersionMismatchError / summarizeDraftConflictDiff /
|
||||
* isBuildConfirmBlocked / lineNeedsManualInventorySelection /
|
||||
* lineHasPendingRoutingSuggestion / lineNeedsInventoryRoutingRecovery、useShippingOrderReview。
|
||||
* isBuildConfirmBlocked / lineNeedsInventoryRoutingRecovery、useShippingOrderReview。
|
||||
* 逻辑:断言 superseded 只读、版本冲突码识别、差异摘要、confirm 门禁、inventory PUT、
|
||||
* reroute/adopt/keep 与 suggestion_pending 行筛选。
|
||||
*/
|
||||
@@ -18,8 +17,6 @@ import {
|
||||
isReviewCaseHistorical,
|
||||
isReviewReadOnly,
|
||||
isReviewWorkItemClosed,
|
||||
lineNeedsManualInventorySelection,
|
||||
lineHasPendingRoutingSuggestion,
|
||||
lineNeedsInventoryRoutingRecovery,
|
||||
mapReviewContextLifecycleStatus,
|
||||
REVIEW_BUILD_ELIGIBILITY_BLOCKED,
|
||||
@@ -55,10 +52,7 @@ const api = vi.hoisted(() => ({
|
||||
|
||||
reparseDocument: vi.fn(),
|
||||
|
||||
putInventoryCandidates: vi.fn(),
|
||||
rerouteInventoryRouting: vi.fn(),
|
||||
adoptInventoryRoutingSuggestion: vi.fn(),
|
||||
keepManualInventoryRouting: vi.fn(),
|
||||
|
||||
confirmCase: vi.fn(),
|
||||
|
||||
@@ -89,10 +83,7 @@ vi.mock('../api/shipping.api', () => ({
|
||||
getWorkspaceShippingOrderExtractionRun: api.getExtractionRun,
|
||||
getWorkspaceShippingProcessingWorkItem: api.getProcessingWorkItem,
|
||||
|
||||
putWorkspaceShippingOrderReviewInventoryCandidates: api.putInventoryCandidates,
|
||||
postWorkspaceShippingOrderReviewInventoryRoutingReroute: api.rerouteInventoryRouting,
|
||||
postWorkspaceShippingOrderReviewInventoryRoutingAdoptSuggestion: api.adoptInventoryRoutingSuggestion,
|
||||
postWorkspaceShippingOrderReviewInventoryRoutingKeepManual: api.keepManualInventoryRouting,
|
||||
|
||||
confirmWorkspaceShippingOrderReviewCase: api.confirmCase,
|
||||
|
||||
@@ -345,36 +336,6 @@ describe('build eligibility helpers', () => {
|
||||
|
||||
|
||||
|
||||
it('detects lines needing manual inventory selection', () => {
|
||||
|
||||
expect(lineNeedsManualInventorySelection({ can_build: true })).toBe(false);
|
||||
|
||||
expect(lineNeedsManualInventorySelection({
|
||||
|
||||
can_build: false,
|
||||
|
||||
candidate_inventory_source_codes: ['DSV360_AWSDU'],
|
||||
|
||||
})).toBe(true);
|
||||
|
||||
expect(lineNeedsManualInventorySelection({
|
||||
|
||||
can_build: false,
|
||||
|
||||
block_reason: 'require_manual_review',
|
||||
|
||||
})).toBe(true);
|
||||
|
||||
expect(lineNeedsManualInventorySelection({
|
||||
|
||||
can_build: false,
|
||||
|
||||
block_reason: 'customer_unresolved',
|
||||
|
||||
})).toBe(false);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -429,7 +390,7 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
|
||||
|
||||
|
||||
it('exposes buildEligibility and manualInventoryLines from active case draft', async () => {
|
||||
it('exposes buildEligibility and automatic routing recovery lines from active case draft', async () => {
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
|
||||
@@ -439,9 +400,8 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
|
||||
expect(review.canConfirmBuild.value).toBe(false);
|
||||
|
||||
expect(review.manualInventoryLines.value).toHaveLength(1);
|
||||
|
||||
expect(review.manualInventoryLines.value[0]?.line_key).toBe('line-1');
|
||||
expect(review.routingRecoveryLines.value).toHaveLength(1);
|
||||
expect(review.routingRecoveryLines.value[0]?.line_key).toBe('line-1');
|
||||
|
||||
});
|
||||
|
||||
@@ -709,76 +669,6 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-B');
|
||||
});
|
||||
|
||||
it('submits inventory candidates via PUT and refreshes case', async () => {
|
||||
|
||||
const updated = buildCase({
|
||||
|
||||
draft: {
|
||||
|
||||
...buildCase().draft!,
|
||||
|
||||
draft_version: 3,
|
||||
|
||||
build_eligibility: {
|
||||
|
||||
can_build: true,
|
||||
|
||||
status: 'ready',
|
||||
|
||||
line_projections: [{
|
||||
|
||||
line_key: 'line-1',
|
||||
|
||||
line_index: 0,
|
||||
|
||||
can_build: true,
|
||||
|
||||
selection_mode: 'manual',
|
||||
|
||||
manual_reason: 'Confirmed with planner',
|
||||
|
||||
candidate_inventory_source_codes: ['DSV360_AWSDU'],
|
||||
|
||||
}],
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
api.putInventoryCandidates.mockResolvedValue(updated);
|
||||
|
||||
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
|
||||
await review.load('RUN-1', 'CASE-1');
|
||||
|
||||
await review.setLineInventoryCandidates('line-1', ['DSV360_AWSDU'], 'Confirmed with planner');
|
||||
|
||||
|
||||
|
||||
expect(api.putInventoryCandidates).toHaveBeenCalledWith('CASE-1', 'line-1', {
|
||||
|
||||
expected_draft_version: 2,
|
||||
|
||||
source_codes: ['DSV360_AWSDU'],
|
||||
|
||||
reason: 'Confirmed with planner',
|
||||
|
||||
});
|
||||
|
||||
expect(review.activeCase.value?.draft?.draft_version).toBe(3);
|
||||
|
||||
expect(review.buildEligibility.value?.can_build).toBe(true);
|
||||
|
||||
expect(review.canConfirmBuild.value).toBe(true);
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
it('blocks confirm when build eligibility cannot build', async () => {
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
@@ -866,7 +756,7 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('notifies the conversation workflow when auto progress reaches a retryable terminal state', async () => {
|
||||
it('keeps polling after a recoverable RPA failure so a later callback can refresh the workflow', async () => {
|
||||
vi.useFakeTimers();
|
||||
const onWorkflowRefresh = vi.fn();
|
||||
const readyCase: ShippingOrderReviewCase = {
|
||||
@@ -881,7 +771,8 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
api.getPreview.mockResolvedValue({ preview_url: '' });
|
||||
api.getProcessingWorkItem
|
||||
.mockResolvedValueOnce({ work_item_no: 'OT-1', status: 'building_order' })
|
||||
.mockResolvedValueOnce({ work_item_no: 'OT-1', status: 'retryable', retryable: true });
|
||||
.mockResolvedValueOnce({ work_item_no: 'OT-1', status: 'retryable', retryable: true })
|
||||
.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', case: { ...readyCase, status: 'confirmed', order_task_no: 'OT-1' }, auto_progress_started: true,
|
||||
@@ -894,6 +785,10 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
await Promise.resolve();
|
||||
|
||||
expect(onWorkflowRefresh).toHaveBeenCalled();
|
||||
// RPA 可重试失败不是工作流关闭;必须继续读取后续成功回调的 Projection。
|
||||
expect(review.workflowProgressPolling.value).toBe(true);
|
||||
await vi.advanceTimersByTimeAsync(2600);
|
||||
await Promise.resolve();
|
||||
expect(review.workflowProgressPolling.value).toBe(false);
|
||||
review.stopWorkflowProgressPolling();
|
||||
vi.useRealTimers();
|
||||
@@ -919,7 +814,7 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
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 () => {
|
||||
it('leaves OT unset while waiting for a reparse Case when candidate-bound case lacks order_task_no', async () => {
|
||||
vi.useFakeTimers();
|
||||
api.getCase.mockResolvedValue(buildCase({
|
||||
candidate_id: 42,
|
||||
@@ -952,11 +847,11 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
expect(review.reviewProgressContext.value?.user_task_no).toBeNull();
|
||||
expect(review.reviewProgressContext.value?.user_task_authoritative).toBe(false);
|
||||
|
||||
review.stopReparseProgressPolling();
|
||||
review.stopReparseCaseRefreshPolling();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('polls reparse progress and loads the new review version when ready', async () => {
|
||||
it('loads the new review version when completed reparse has activated its Stream Case', async () => {
|
||||
vi.useFakeTimers();
|
||||
let reparsePollCount = 0;
|
||||
api.reparseDocument.mockImplementation(async () => ({
|
||||
@@ -965,17 +860,26 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
}));
|
||||
api.getRun.mockImplementation(async (runNo: string) => ({
|
||||
run_no: runNo,
|
||||
status: runNo === 'RUN-2' ? 'review_required' : 'review_required',
|
||||
status: runNo === 'RUN-2' ? 'completed' : 'review_required',
|
||||
summary: {},
|
||||
items: [{ case_no: runNo === 'RUN-2' ? 'CASE-2' : 'CASE-1', status: 'draft', issue_count: 0 }],
|
||||
}));
|
||||
api.getQueue.mockImplementation(async (runNo: string) => ({
|
||||
summary: { total: 1, needs_action: 1, processing: 0, completed: 0 },
|
||||
items: [{
|
||||
case_no: runNo === 'RUN-2' ? 'CASE-2' : 'CASE-1',
|
||||
document_id: 1,
|
||||
source_run_no: runNo,
|
||||
status: 'draft', issue_count: 0, available_actions: [],
|
||||
}],
|
||||
}));
|
||||
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' },
|
||||
status: ready ? 'completed' : 'extracting',
|
||||
current_activity: { user_visible_stage: ready ? 'completed' : 'extracting' },
|
||||
};
|
||||
});
|
||||
api.getCase.mockImplementation(async (caseNo: string) => buildCase({
|
||||
@@ -987,19 +891,16 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'SWI-1' });
|
||||
await review.reparseDocument('document_quality');
|
||||
|
||||
expect(review.reparseProgressActive.value).toBe(true);
|
||||
await vi.advanceTimersByTimeAsync(2600);
|
||||
await Promise.resolve();
|
||||
|
||||
expect(review.reparseProgressStage.value).toBe('draft_ready');
|
||||
expect(review.reparseProgressPolling.value).toBe(false);
|
||||
expect(review.reviewRun.value?.run_no).toBe('RUN-2');
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-2');
|
||||
review.stopReparseProgressPolling();
|
||||
review.stopReparseCaseRefreshPolling();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('loads a partially completed reparse result and clears the read-only progress state', async () => {
|
||||
it('loads a partially completed reparse result without a legacy read-only progress state', async () => {
|
||||
vi.useFakeTimers();
|
||||
api.reparseDocument.mockImplementation(async () => ({
|
||||
run: { run_no: 'RUN-PARTIAL', items: [], summary: {} },
|
||||
@@ -1016,6 +917,15 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
status: runNo === 'RUN-PARTIAL' ? 'partially_completed' : 'review_required',
|
||||
current_activity: { user_visible_stage: 'review_required' },
|
||||
}));
|
||||
api.getQueue.mockImplementation(async (runNo: string) => ({
|
||||
summary: { total: 1, needs_action: 1, processing: 0, completed: 0 },
|
||||
items: [{
|
||||
case_no: runNo === 'RUN-PARTIAL' ? 'CASE-PARTIAL' : 'CASE-1',
|
||||
document_id: 1,
|
||||
source_run_no: runNo,
|
||||
status: 'draft', issue_count: 0, available_actions: [],
|
||||
}],
|
||||
}));
|
||||
api.getCase.mockImplementation(async (caseNo: string) => buildCase({
|
||||
case_no: caseNo,
|
||||
run_no: caseNo === 'CASE-PARTIAL' ? 'RUN-PARTIAL' : 'RUN-1',
|
||||
@@ -1029,59 +939,69 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
|
||||
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();
|
||||
review.stopReparseCaseRefreshPolling();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('resolves the replacement run when superseded_by_run_no is set', async () => {
|
||||
it('opens the Stream current version instead of retaining a historical Case', async () => {
|
||||
api.getQueue.mockResolvedValue({
|
||||
summary: { total: 1, needs_action: 1, processing: 0, completed: 0 },
|
||||
items: [{ case_no: 'CASE-2', document_id: 1, source_run_no: 'RUN-2', status: 'draft', issue_count: 0, available_actions: [] }],
|
||||
});
|
||||
api.getRun.mockImplementation(async (runNo: string) => ({
|
||||
run_no: runNo, summary: {},
|
||||
items: [{ case_no: runNo === 'RUN-2' ? 'CASE-2' : 'CASE-1', document_id: 1, status: 'draft', issue_count: 0 }],
|
||||
}));
|
||||
api.getCase.mockImplementation(async (caseNo: string) => buildCase({
|
||||
case_no: caseNo, run_no: caseNo === 'CASE-2' ? 'RUN-2' : 'RUN-1',
|
||||
}));
|
||||
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 }],
|
||||
});
|
||||
api.getCase.mockResolvedValue(buildCase({ case_no: 'CASE-2', run_no: 'RUN-2' }));
|
||||
|
||||
const target = await review.openCurrentVersion();
|
||||
|
||||
expect(target).toEqual({ runNo: 'RUN-2', caseNo: 'CASE-2' });
|
||||
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 () => {
|
||||
it('does not jump to a different PDF when the Stream contains multiple documents', async () => {
|
||||
api.getRun.mockImplementation(async (runNo: string) => runNo === 'RUN-1'
|
||||
? {
|
||||
run_no: 'RUN-1',
|
||||
run_no: runNo,
|
||||
summary: {},
|
||||
items: [{ case_no: 'CASE-1', status: 'superseded', issue_count: 0 }],
|
||||
}
|
||||
: {
|
||||
run_no: 'RUN-2',
|
||||
run_no: runNo,
|
||||
summary: {},
|
||||
items: [{ case_no: 'CASE-2', status: 'draft', issue_count: 0 }],
|
||||
items: [{ case_no: runNo === 'RUN-3' ? 'CASE-1-NEW' : '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',
|
||||
run_no: caseNo === 'CASE-1-NEW' ? 'RUN-3' : caseNo === 'CASE-2' ? 'RUN-2' : 'RUN-1',
|
||||
status: caseNo === 'CASE-1-NEW' || caseNo === 'CASE-2' ? 'draft' : 'superseded',
|
||||
}));
|
||||
api.getQueue.mockResolvedValue({
|
||||
summary: { total: 2, needs_action: 2, processing: 0, completed: 0 },
|
||||
items: [
|
||||
{ case_no: 'CASE-1-NEW', document_id: 1, source_run_no: 'RUN-3', status: 'draft', issue_count: 0, available_actions: [] },
|
||||
{ case_no: 'CASE-2', document_id: 2, source_run_no: 'RUN-2', status: 'draft', issue_count: 0, available_actions: [] },
|
||||
],
|
||||
});
|
||||
|
||||
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');
|
||||
expect(target).toEqual({ runNo: 'RUN-3', caseNo: 'CASE-1-NEW' });
|
||||
expect(review.reviewRun.value?.run_no).toBe('RUN-3');
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-1-NEW');
|
||||
});
|
||||
|
||||
it('shows a terminal failed stage when reparse fails', async () => {
|
||||
it('stops waiting when reparse fails without exposing a synthetic stage', async () => {
|
||||
vi.useFakeTimers();
|
||||
api.reparseDocument.mockResolvedValue({
|
||||
run: { run_no: 'RUN-FAILED', items: [], summary: {} }, reused: false,
|
||||
@@ -1096,9 +1016,8 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
await vi.advanceTimersByTimeAsync(2600);
|
||||
await Promise.resolve();
|
||||
|
||||
expect(review.reparseProgressStage.value).toBe('failed');
|
||||
expect(review.reparseProgressPolling.value).toBe(false);
|
||||
review.stopReparseProgressPolling();
|
||||
expect(review.reviewRun.value?.run_no).toBe('RUN-1');
|
||||
review.stopReparseCaseRefreshPolling();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
@@ -1132,24 +1051,14 @@ describe('inventory routing recovery', () => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('detects pending suggestion and recovery lines beyond manual selection', () => {
|
||||
// 关键断言:suggestion_pending 即使 can_build true 也应进入恢复集合。
|
||||
expect(lineHasPendingRoutingSuggestion({ suggestion_pending: true })).toBe(true);
|
||||
expect(lineNeedsInventoryRoutingRecovery({
|
||||
can_build: true,
|
||||
suggestion_pending: true,
|
||||
})).toBe(true);
|
||||
it('detects automatic routing recovery lines', () => {
|
||||
expect(lineNeedsInventoryRoutingRecovery({
|
||||
can_build: true,
|
||||
unavailable_source_codes: ['OFFLINE_SRC'],
|
||||
})).toBe(true);
|
||||
expect(lineNeedsManualInventorySelection({
|
||||
can_build: true,
|
||||
suggestion_pending: true,
|
||||
})).toBe(false);
|
||||
});
|
||||
|
||||
it('exposes routingRecoveryLines for suggestion_pending rows', async () => {
|
||||
it('exposes routingRecoveryLines for blocked rule rows', async () => {
|
||||
api.getCase.mockResolvedValue(buildCase({
|
||||
draft: {
|
||||
...buildCase().draft!,
|
||||
@@ -1159,8 +1068,8 @@ describe('inventory routing recovery', () => {
|
||||
line_projections: [{
|
||||
line_key: 'line-pending',
|
||||
line_index: 0,
|
||||
can_build: true,
|
||||
suggestion_pending: true,
|
||||
can_build: false,
|
||||
block_reason: 'inventory_source_unavailable',
|
||||
rule_suggestion_source_codes: ['DSV360_AWSDU'],
|
||||
candidate_inventory_source_codes: ['DSV360_AWSHK'],
|
||||
selection_mode: 'manual',
|
||||
@@ -1170,7 +1079,6 @@ describe('inventory routing recovery', () => {
|
||||
}));
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1');
|
||||
expect(review.manualInventoryLines.value).toHaveLength(0);
|
||||
expect(review.routingRecoveryLines.value).toHaveLength(1);
|
||||
expect(review.routingRecoveryLines.value[0]?.line_key).toBe('line-pending');
|
||||
});
|
||||
@@ -1193,32 +1101,6 @@ describe('inventory routing recovery', () => {
|
||||
uuidSpy.mockRestore();
|
||||
});
|
||||
|
||||
it('adopts and keeps inventory routing suggestions via POST APIs', async () => {
|
||||
const updated = buildCase({ draft: { ...buildCase().draft!, draft_version: 4 } });
|
||||
api.adoptInventoryRoutingSuggestion.mockResolvedValue(updated);
|
||||
api.keepManualInventoryRouting.mockResolvedValue(updated);
|
||||
const uuidSpy = vi.spyOn(crypto, 'randomUUID')
|
||||
.mockReturnValueOnce('idem-adopt-1')
|
||||
.mockReturnValueOnce('idem-keep-1');
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1');
|
||||
await review.adoptInventoryRoutingSuggestion('line-1', 'use rule');
|
||||
await review.keepManualInventoryRouting('line-1', 'keep manual');
|
||||
|
||||
expect(api.adoptInventoryRoutingSuggestion).toHaveBeenCalledWith('CASE-1', 'line-1', {
|
||||
expected_draft_version: 2,
|
||||
idempotency_key: 'idem-adopt-1',
|
||||
reason: 'use rule',
|
||||
});
|
||||
expect(api.keepManualInventoryRouting).toHaveBeenCalledWith('CASE-1', 'line-1', {
|
||||
expected_draft_version: 4,
|
||||
idempotency_key: 'idem-keep-1',
|
||||
reason: 'keep manual',
|
||||
});
|
||||
uuidSpy.mockRestore();
|
||||
});
|
||||
|
||||
it('sets draftConflict on 409 VERSION_MISMATCH during reroute', async () => {
|
||||
api.rerouteInventoryRouting.mockRejectedValue(
|
||||
new BusinessError({ message: 'stale', code: REVIEW_DRAFT_VERSION_MISMATCH }),
|
||||
|
||||
Reference in new issue
Block a user