chore(shipping-notice): 统一货代发货生命周期阶段命名并优化全链路业务逻辑
This commit is contained in:
1 parent
5ef8329bd8
commit
4ec4e57005
183 files changed
+14653
-3936
No files matched your search
@@ -83,6 +83,29 @@ def test_projection_fact_read_failure_is_fail_closed():
|
||||
assert payload['blocking_reason']['code'] == 'projection_data_inconsistent'
|
||||
|
||||
|
||||
def test_inventory_shortage_gate_projects_a_user_visible_blocking_reason():
|
||||
"""库存缺口 Gate 不能只保留内部码而遗漏批次/工作台的统一阻塞原因。"""
|
||||
payload = apply_user_projection_fields(reconcile_processing_projection_facts({
|
||||
'status': 'blocked',
|
||||
'stage': 'inventory_matching',
|
||||
'source_type': 'eml',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_sufficiency',
|
||||
'status': 'blocked_manual',
|
||||
'next_action_code': 'open_shortage_review',
|
||||
'blocking_reason_code': 'inventory_shortage_review_required',
|
||||
},
|
||||
'available_actions': ['open_shortage_review'],
|
||||
}))
|
||||
|
||||
assert payload['user_status'] == 'waiting_human'
|
||||
assert payload['blocking_reason'] == {
|
||||
'code': 'inventory_shortage_review_required',
|
||||
'i18n_key': 'workspace.shippingNotice.processGate.reasons.inventory_shortage_review_required',
|
||||
'details': {},
|
||||
}
|
||||
|
||||
|
||||
def test_normalize_unknown_action_codes():
|
||||
"""未知 / 别名动作码映射到契约或丢弃。"""
|
||||
assert normalize_action_code('retry_failed_documents') == 'retry'
|
||||
@@ -295,6 +318,93 @@ def test_inventory_snapshot_missing_projects_retryable_inventory_action():
|
||||
}
|
||||
|
||||
|
||||
def test_formal_blocked_gate_overrides_stale_preparation_running_state():
|
||||
"""正式 Gate 已阻断时,旧库存准备 waiting 不能把用户态降回系统处理中。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'processing',
|
||||
'stage': 'inventory_preparation',
|
||||
'source_type': 'order_task',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_preparation',
|
||||
'status': 'blocked_retryable',
|
||||
'next_action_code': 'retry_inventory_preparation',
|
||||
'blocking_reason_code': 'technical_failure_present',
|
||||
},
|
||||
'available_actions': ['retry_inventory_preparation'],
|
||||
})
|
||||
|
||||
# 关键断言:Gate 是业务裁决真相;Preparation Attempt 只能作为过程明细。
|
||||
assert payload['user_status'] == 'retryable'
|
||||
assert payload['primary_action']['code'] == 'retry_inventory_preparation'
|
||||
|
||||
|
||||
def test_formal_inventory_matching_retry_projects_business_i18n_key():
|
||||
"""正式 OT 的库存重试不得让页面回退展示内部 action code。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'blocked',
|
||||
'stage': 'inventory_matching',
|
||||
'source_type': 'order_task',
|
||||
'shipping_notice_no': 'SN-RETRY-MATCH',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_matching',
|
||||
'status': 'blocked_retryable',
|
||||
'next_action_code': 'retry_inventory_matching',
|
||||
'blocking_reason_code': 'inventory_match_failed',
|
||||
},
|
||||
'available_actions': ['retry_inventory_matching'],
|
||||
})
|
||||
|
||||
assert payload['primary_action'] == {
|
||||
'code': 'retry_inventory_matching',
|
||||
'i18n_key': 'workspace.shippingNotice.processGate.actionCodes.retry_inventory_matching',
|
||||
'parameters': {},
|
||||
}
|
||||
|
||||
|
||||
def test_formal_inventory_gate_overrides_stale_waiting_review_compatibility_fields():
|
||||
"""正式库存 Gate 必须覆盖历史 OT 的 waiting_review,防止阶段回退。"""
|
||||
payload = reconcile_processing_projection_facts({
|
||||
'work_item_no': 'OT-GATE-OVERRIDE',
|
||||
'shipping_notice_no': 'SN-GATE-OVERRIDE',
|
||||
'status': 'waiting_review',
|
||||
'stage': 'waiting_review',
|
||||
'source_type': 'order_task',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_preparation',
|
||||
'status': 'blocked_manual',
|
||||
'next_action_code': 'retry_inventory_preparation',
|
||||
'blocking_reason_code': 'inventory_rpa_timeout',
|
||||
},
|
||||
'available_actions': ['open_order_review'],
|
||||
})
|
||||
|
||||
assert payload['status'] == 'waiting_review'
|
||||
assert payload['stage'] == 'inventory_fetching'
|
||||
assert 'projection_inconsistency_code' not in payload
|
||||
assert payload['available_actions'] == ['retry_inventory_preparation']
|
||||
|
||||
|
||||
def test_inventory_file_missing_exposes_a_user_facing_reason_i18n_key():
|
||||
"""库存文件缺失需携带可翻译原因,批次中心不得回显内部原因码。"""
|
||||
payload = apply_user_projection_fields({
|
||||
'status': 'blocked',
|
||||
'stage': 'inventory_preparation',
|
||||
'source_type': 'order_task',
|
||||
'current_gate': {
|
||||
'gate_code': 'inventory_preparation',
|
||||
'status': 'blocked_manual',
|
||||
'blocking_reason_code': 'inventory_file_missing',
|
||||
},
|
||||
'available_actions': [],
|
||||
})
|
||||
|
||||
assert payload['blocking_reason'] == {
|
||||
'code': 'inventory_file_missing',
|
||||
'i18n_key': 'chat.shippingProcessing.reasonCode.inventory_file_missing',
|
||||
'details': {},
|
||||
}
|
||||
|
||||
|
||||
def test_inventory_file_empty_keeps_gate_retry_as_the_only_primary_action():
|
||||
"""库存文件缺失必须保留 Gate 重试,不得降级为线外上传或空按钮。"""
|
||||
payload = apply_user_projection_fields({
|
||||
|
||||
Reference in new issue
Block a user