feat(shipping-notice): 实现对话级批量重试自动推进功能,优化库存与PDF匹配逻辑

- 新增对话级批量重试自动推进的完整链路:后端服务、API、数据投影逻辑
- 前端新增对话级重试按钮、多语言国际化支持与API类型定义
- 优化行级库存重试控制,新增retryable字段统一管控重试按钮展示,清理废弃的view_fulfillment_detail动作,标准化前端动作码排序逻辑
- 修复PDF坐标匹配的fail-close防护逻辑,避免生成伪精确匹配分数
- 调整订单确认后流程,提前进入库存获取阶段,移除冗余的确认建单按钮,优化用户流转体验
- 新增对应单元测试用例覆盖核心业务逻辑
This commit is contained in:
hugo committed 2026-08-07 16:30:45 +08:00
1 parent fd6a23f870
commit 1008911a7e
41 files changed
+3956 -1256

No files matched your search

@@ -0,0 +1,63 @@
"""
tests/test_conversation_retry_auto_progress.py
用途:锁定对话级重试自动推进的 eligible 判定、跳过原因与汇总结构。
依赖:conversation_retry_auto_progress_service。
逻辑:纯单元测跳过映射与 summary;不依赖完整 DB 工厂。
"""
from __future__ import annotations
from app.services.shipping_notice.conversation_retry_auto_progress_service import (
ACTION_RETRY_AUTO_PROGRESS,
_skip_reason_from_automation,
_summarize_items,
project_conversation_allowed_actions,
)
def test_skip_reason_maps_queued_and_not_retryable():
"""queued → already_running;retryable=false → not_retryable。"""
assert _skip_reason_from_automation(
{'status': 'queued', 'retryable': False},
task_missing=False,
) == 'already_running'
assert _skip_reason_from_automation(
{'status': 'waiting_to_start', 'retryable': False},
task_missing=False,
) == 'not_retryable'
assert _skip_reason_from_automation(
{'status': 'failed', 'retryable': True},
task_missing=False,
) is None
def test_manual_fallback_human_owner_still_retryable():
"""manual_fallback 虽 owner=human,但 retryable 时不得跳过。"""
assert _skip_reason_from_automation(
{'status': 'manual_fallback', 'retryable': True, 'owner_type': 'human'},
task_missing=False,
) is None
def test_task_missing_always_skipped():
assert _skip_reason_from_automation(
{'status': 'failed', 'retryable': True},
task_missing=True,
) == 'task_missing'
def test_summarize_items_counts_outcomes():
summary = _summarize_items([
{'outcome': 'queued'},
{'outcome': 'queued'},
{'outcome': 'skipped', 'reason_code': 'already_running'},
{'outcome': 'failed'},
])
assert summary == {'total': 4, 'retried': 2, 'skipped': 1, 'failed': 1}
def test_project_conversation_allowed_actions_empty_without_conversation():
"""无 conversation_id 时不返回禁用空按钮。"""
assert project_conversation_allowed_actions(user_id=1, conversation_id='') == []
assert ACTION_RETRY_AUTO_PROGRESS == 'retry_auto_progress'