feat(shipping-notice): 新增通用解析能力,优化性能并清理遗留废弃代码
This commit is contained in:
1 parent
935bf26fa6
commit
7cfd5d167e
230 files changed
+9337
-10989
No files matched your search
@@ -121,8 +121,8 @@ def test_task_ui_state_stage_context_is_opt_in(app) -> None:
|
||||
assert "stage_context" in detailed_state
|
||||
|
||||
|
||||
def test_build_task_ui_state_exposes_five_business_stages_and_unified_actions(app) -> None:
|
||||
"""没有 Gate 的旧 checkpoint 仅表达状态,不能再直接产生可写 UI 动作。"""
|
||||
def test_build_task_ui_state_without_formal_gate_is_unclassified(app) -> None:
|
||||
"""旧 checkpoint 不能再推导五阶段或任何可写 UI 动作。"""
|
||||
with app.app_context():
|
||||
task = ShippingNotice(
|
||||
task_no="SN-UI-STAGE-ACTIONS",
|
||||
@@ -131,15 +131,15 @@ def test_build_task_ui_state_exposes_five_business_stages_and_unified_actions(ap
|
||||
source_type="manual",
|
||||
)
|
||||
state = build_task_ui_state(task)
|
||||
assert state["stage"]["code"] == "order_review"
|
||||
assert state["stage"]["index"] == 2
|
||||
assert state["stage"]["code"] == "unclassified"
|
||||
assert state["stage"]["index"] == 0
|
||||
assert state["stage"]["total"] == 5
|
||||
assert state["actions"]["primary"] is None
|
||||
assert state["actions"]["secondary"] == []
|
||||
|
||||
|
||||
def test_build_task_ui_state_exposes_backend_owned_lifecycle_entries(app) -> None:
|
||||
"""正式工作台的五个入口必须由后端下发,页面不能按阶段顺序自行生成。"""
|
||||
def test_build_task_ui_state_without_formal_gate_has_no_lifecycle_entries(app) -> None:
|
||||
"""正式工作台入口必须来自 Gate,不能按旧 checkpoint 生成。"""
|
||||
with app.app_context():
|
||||
task = ShippingNotice(
|
||||
task_no="SN-UI-LIFECYCLE-ENTRIES",
|
||||
@@ -148,14 +148,8 @@ def test_build_task_ui_state_exposes_backend_owned_lifecycle_entries(app) -> Non
|
||||
source_type="manual",
|
||||
)
|
||||
state = build_task_ui_state(task)
|
||||
assert state["lifecycle_stage"] == "order_review"
|
||||
assert state["lifecycle_entries"] == [
|
||||
{"code": "intake_parse", "state": "available", "target_surface": "order_lifecycle_workbench"},
|
||||
{"code": "order_review", "state": "current", "target_surface": "order_lifecycle_workbench"},
|
||||
{"code": "fulfillment_prep", "state": "unavailable", "target_surface": "order_lifecycle_workbench"},
|
||||
{"code": "freight_upload", "state": "unavailable", "target_surface": "order_lifecycle_workbench"},
|
||||
{"code": "upload_complete", "state": "unavailable", "target_surface": "order_lifecycle_workbench"},
|
||||
]
|
||||
assert state["lifecycle_stage"] == "unclassified"
|
||||
assert state["lifecycle_entries"] == []
|
||||
|
||||
|
||||
def test_task_ui_state_ignores_superseded_process_execution(app) -> None:
|
||||
@@ -209,7 +203,7 @@ def test_task_ui_state_formal_gate_overrides_stale_task_fields(app) -> None:
|
||||
assert state['stage']['code'] == 'fulfillment_prep'
|
||||
assert state['current_step']['code'] == 'fulfillment_prep'
|
||||
assert [entry['state'] for entry in state['lifecycle_entries']] == [
|
||||
'available', 'available', 'current', 'unavailable',
|
||||
'available', 'available', 'current', 'unavailable', 'unavailable',
|
||||
]
|
||||
|
||||
|
||||
@@ -244,8 +238,8 @@ def test_task_ui_state_manual_upload_gate_overrides_stale_task_fields(app) -> No
|
||||
]
|
||||
|
||||
|
||||
def test_build_task_ui_state_maps_domain_facts_to_fulfillment_and_upload_stages(app) -> None:
|
||||
"""库存匹配与无证据历史上传分别映射通知准备和货代上传。"""
|
||||
def test_build_task_ui_state_does_not_map_domain_fields_to_lifecycle(app) -> None:
|
||||
"""库存和上传历史字段不能再替代正式 Gate 生成生命周期。"""
|
||||
with app.app_context():
|
||||
fulfillment = ShippingNotice(
|
||||
task_no="SN-UI-FULFILLMENT",
|
||||
@@ -258,11 +252,11 @@ def test_build_task_ui_state_maps_domain_facts_to_fulfillment_and_upload_stages(
|
||||
source_type="manual",
|
||||
upload_status="uploaded",
|
||||
)
|
||||
assert build_task_ui_state(fulfillment)["stage"]["code"] == "fulfillment_prep"
|
||||
assert build_task_ui_state(fulfillment)["stage"]["code"] == "unclassified"
|
||||
upload_state = build_task_ui_state(upload, include_stage_context=True)
|
||||
assert upload_state["stage"]["code"] == "freight_upload"
|
||||
assert upload_state["stage"]["code"] == "unclassified"
|
||||
# 旧 Task 字段只能决定工作面;没有可追溯 UploadAttempt 时不得显示上传成功。
|
||||
assert upload_state["stage_context"]["upload"]["outcome"] == "awaiting_manual"
|
||||
assert upload_state["stage_context"]["upload"]["outcome"] == "not_started"
|
||||
|
||||
|
||||
def test_entry_surface_parse_review_is_review_workbench(app) -> None:
|
||||
|
||||
Reference in new issue
Block a user