perf(shipping-notice): 优化发货任务性能,修复上传流程与终态问题

This commit is contained in:
hugo committed 2026-08-27 19:25:16 +08:00
1 parent 434c04ed2d
commit bcdd8285ae
29 files changed
+1074 -128

No files matched your search

@@ -345,6 +345,31 @@ def test_task_ui_state_keeps_resolved_download_alongside_process_gate(app, monke
assert [item['code'] for item in state['actions']['secondary']] == ['download_excel']
def test_verified_upload_complete_state_has_no_follow_up_actions(app, monkeypatch) -> None:
"""通知完成是终态,即使旧 Gate 尚未清理也不得继续下发下一步。"""
with app.app_context():
task = ShippingNotice(task_no='SN-UI-UPLOAD-COMPLETE', source_type='manual')
monkeypatch.setattr(
'app.services.shipping_notice.upload_attempt_service.has_verified_upload_success',
lambda _task: True,
)
monkeypatch.setattr(
'app.services.shipping_notice.ui_state._process_gate_user_summary_for_task',
lambda _task: {
'current_gate': {'gate_code': 'manual_upload_handoff', 'evaluation_version': 3},
'current_blocking_gate': {'gate_code': 'manual_upload_handoff', 'evaluation_version': 3},
'primary_action': {'code': 'mark_manual_uploaded', 'label': '确认上传'},
'action_presentation': [],
},
)
state = build_task_ui_state(task)
# 关键断言:已核验上传成功优先于滞后的 Gate,完成态不能渲染任何下一步。
assert state['lifecycle_stage'] == 'upload_complete'
assert state['actions'] == {'primary': None, 'secondary': []}
def test_stp_facts_candidates_frozen_projected(app) -> None:
"""多候选冻结任务须投影 stp_facts.frozen_candidate_codes。"""
with app.app_context():