Add business pricing and closure controls with compatible digest optimization
This commit is contained in:
@@ -75,6 +75,8 @@ func _run() -> void:
|
||||
_test_unavailable_and_expiry()
|
||||
_test_restore_guards()
|
||||
_test_pickup_retry()
|
||||
_test_source_closes_after_assignment()
|
||||
_test_source_closes_after_loading()
|
||||
_test_unavailable_before_pickup()
|
||||
_test_partial_expiry_return()
|
||||
_test_shift_boundary()
|
||||
@@ -202,6 +204,36 @@ func _test_pickup_retry() -> void:
|
||||
_expect(_quantity(_inventory(_destination)) == 8 and _quantity(_cargo()) == 0, "retry delivers the same stock exactly once")
|
||||
|
||||
|
||||
func _test_source_closes_after_assignment() -> void:
|
||||
_expect(_runtime.restore_snapshot(_reserved), "restore source-closure approach scenario")
|
||||
_clock.advance_minutes(1)
|
||||
var old_task := _worker().current_task_id
|
||||
_expect(_request().state == LogisticsRequest.State.ASSIGNED and not old_task.is_empty(), "source closure begins after assigning the real pickup Task")
|
||||
_expect(_command(&"set_facility_policy", {&"facility_id": _source, &"patch": {&"business_open": false}}), "close the source while its porter approaches")
|
||||
_wait_for(LogisticsRequest.State.BLOCKED, 40)
|
||||
_expect(_request().state == LogisticsRequest.State.BLOCKED and _request().state_reason == "SOURCE_CLOSED", "arrival at a newly closed source blocks before loading")
|
||||
_expect(_quantity(_inventory(_source)) == 8 and _quantity(_cargo()) == 0 and _quantity(_inventory(_destination)) == 0, "closed source retains every purchased unit without transfer")
|
||||
_expect(_runtime.inventory_service.available_quantity(_inventory(_source), SupplyCatalog.RAW_FOOD) == 8 and _worker().current_task_id.is_empty(), "blocked pickup releases both source stock and employee reservations")
|
||||
_expect(_runtime.logistics_dispatcher.get_reserved_load(PORTER) == 0 and _crosslinks(), "closed-source cleanup retains no dispatcher or Task ghost")
|
||||
_expect(_runtime.restore_snapshot(_runtime.create_snapshot()), "blocked closed-source state passes strict Runtime restore")
|
||||
_expect(_command(&"set_facility_policy", {&"facility_id": _source, &"patch": {&"business_open": true}}), "reopen the source for a retry")
|
||||
_wait_for(LogisticsRequest.State.DELIVERING, 40)
|
||||
_expect(_request().state == LogisticsRequest.State.DELIVERING and _worker().current_task_id != old_task and _quantity(_cargo()) == 8, "reopening retries with a fresh Task and physical pickup")
|
||||
var loaded_cell := _worker().current_cell
|
||||
_wait_for(LogisticsRequest.State.COMPLETED, 40)
|
||||
_expect(_request().state == LogisticsRequest.State.COMPLETED and _worker().current_cell != loaded_cell and _quantity(_inventory(_destination)) == 8, "reopened source stock reaches the kitchen by actual porter movement")
|
||||
_expect(_quantity(_inventory(_source)) == 0 and _quantity(_cargo()) == 0 and _runtime.logistics_dispatcher.get_reserved_load(PORTER) == 0 and _crosslinks(), "reopened source delivery consumes and releases ownership exactly once")
|
||||
|
||||
|
||||
func _test_source_closes_after_loading() -> void:
|
||||
_expect(_runtime.restore_snapshot(_loaded), "restore loaded source-closure scenario")
|
||||
_expect(_command(&"set_facility_policy", {&"facility_id": _source, &"patch": {&"business_open": false}}), "close the source after loading")
|
||||
var cell := _worker().current_cell
|
||||
_wait_for(LogisticsRequest.State.COMPLETED, 40)
|
||||
_expect(_request().state == LogisticsRequest.State.COMPLETED and _worker().current_cell != cell and _quantity(_inventory(_destination)) == 8, "already-loaded porter can finish delivery to an open destination")
|
||||
_expect(_quantity(_cargo()) == 0 and _runtime.logistics_dispatcher.get_reserved_load(PORTER) == 0 and _crosslinks(), "delivery after source closure clears cargo and carrier ownership")
|
||||
|
||||
|
||||
func _test_unavailable_before_pickup() -> void:
|
||||
_expect(_runtime.restore_snapshot(_reserved), "restore unloaded health failure")
|
||||
_clock.advance_minutes(1)
|
||||
|
||||
Reference in New Issue
Block a user