Files
TheTree_mock/tests/mvp/test_staff_unique_contract_report.gd
T
Takeshi 5dde0c5ec2 Record original-alignment implementation and traceability checkpoint
Capture current source, content data, tests, asset licenses, and original-specification traceability. Original implementation remains incomplete. The accepted matching UI generation passed 154 suites and 12,253 checks, with eight rendered staff-contract screens reviewed. Latest native Windows and full-original acceptance remain outstanding.
2026-09-30 23:52:24 +09:00

118 lines
9.0 KiB
GDScript

extends SceneTree
## Boundary coverage for owned canonical unique employment reports.
## Current definitions supply values; synthetic identity/link cases are disclosed.
var checks := 0
var failures := 0
var runtime: Variant
var clock: Variant
var state: Variant
func _initialize() -> void:
call_deferred("run")
func expect(ok: bool, label: String) -> void:
checks += 1
if not ok:
failures += 1
push_error("UNIQUE_CONTRACT_REPORT: " + label)
func row_for(staff_id: StringName) -> Dictionary:
for row: Dictionary in runtime.get_staff_management_report()[&"staff"]:
if row[&"staff_id"] == staff_id:
return row
return {}
func effect_for(staff_id: StringName) -> Dictionary:
var row := row_for(staff_id)
var contract: Dictionary = row.get(&"unique_contract", {})
var effects: Array = contract.get(&"passive_effects", [])
return effects[0] if effects.size() == 1 else {}
func run() -> void:
runtime = load("res://autoload/simulation_runtime.gd").new()
clock = load("res://autoload/game_clock.gd").new()
state = load("res://autoload/game_state.gd").new()
clock.reset(1, 6, 0)
state.reset()
expect(runtime.initialize(clock, state, 42602)[&"valid"], "canonical content initializes")
clock.set_paused(true)
expect(runtime.submit_command(&"hire_staff_candidate", {&"candidate_id": &"heroine_anri"}).is_success(), "normal approved command joins canonical Anri")
expect(runtime.submit_command(&"hire_staff_candidate", {&"candidate_id": &"staff_akane"}).is_success(), "normal paid candidate remains available")
var unassigned := row_for(&"heroine_anri")
var contract: Dictionary = unassigned.get(&"unique_contract", {})
expect(contract.get(&"canonical_id") == &"heroine_anri" and contract.get(&"free_employment") == true and contract.get(&"free_upkeep") == true and contract.get(&"permanent_removal_forbidden") == true, "report connects canonical free and protected employment")
expect(row_for(&"staff_akane").get(&"unique_contract", {}).is_empty(), "ordinary paid actor receives no unique contract")
expect(effect_for(&"heroine_anri").get(&"multiplier_bp") == 12000 and effect_for(&"heroine_anri").get(&"applied") == false and not effect_for(&"heroine_anri").has(&"floor_y"), "unassigned report preserves original effect but has no invented target")
var panel := StaffManagementPanel.new()
var unassigned_text: String = panel._unique_contract_text(unassigned)
expect(unassigned_text.contains("雇用・維持費無料") and unassigned_text.contains("解雇・売却不可") and unassigned_text.contains("未適用(配属先なし・施設不在)"), "UI presents valid unassigned contract without a false active floor")
expect(panel._unique_contract_text(row_for(&"staff_akane")).is_empty(), "ordinary UI does not infer unique identity from wages")
identity_boundaries()
for request: Array in [[&"reception", Vector3i(-6,0,0)], [&"warehouse", Vector3i(-6,0,1)], [&"premium_room", Vector3i(-6,2,0)], [&"warehouse", Vector3i(-6,2,1)], [&"service_stairs", Vector3i(-7,1,1)], [&"service_stairs", Vector3i(-7,2,1)]]:
var built: CommandResult = runtime.submit_command(&"build_facility", {&"definition_id": request[0], &"origin": request[1]})
expect(built.is_success(), "normal construction provides accessible upper-floor fixtures")
if not built.is_success():
finish(panel)
return
clock.advance_minutes(runtime.definition_registry.get_facility(request[0]).build_minutes)
var workplace: FacilityInstance
var room: FacilityInstance
for facility: FacilityInstance in runtime.facility_service.get_instances():
if facility.definition_id == &"warehouse" and facility.origin.y == 2:
workplace = facility
if facility.definition_id == &"premium_room":
room = facility
expect(workplace != null and room != null, "real upper workplace and opposite-layer room exist")
if workplace == null or room == null:
finish(panel)
return
expect(runtime.submit_command(&"set_staff_work_assignment", {&"staff_id": &"heroine_anri", &"facility_id": workplace.instance_id, &"template_id": &"NIGHT"}).is_success(), "normal assignment uses existing path/role/capacity checks")
var effect := effect_for(&"heroine_anri")
expect(effect.get(&"applied") == true and effect.get(&"floor_y") == 2 and effect.get(&"assigned_facility_id") == workplace.instance_id and effect.get(&"scope") == &"ASSIGNED_FLOOR_ALL_LAYERS", "report exposes actual planned target floor across both layers")
expect(runtime.get_floor_price_multiplier(2) == effect[&"multiplier_bp"] and runtime.get_floor_price_multiplier(0) == 10000 and runtime.get_facility_business_price(room) == 264, "presentation matches existing real pricing without changing its rounding")
expect(panel._unique_contract_text(row_for(&"heroine_anri")).contains("対象:3F(表層・裏層の全施設)"), "UI converts saved target Y with the existing floor naming convention")
var worker: StaffRuntime = runtime.staff_service.get_staff(&"heroine_anri")
var old_state := worker.state
worker.state = StaffRuntime.State.OFF_DUTY # Disclosed read-only applicability boundary fixture.
expect(effect_for(&"heroine_anri").get(&"applied") == true and runtime.get_floor_price_multiplier(2) == 12000, "passive placement does not acquire an attendance condition")
worker.state = old_state
var old_operation := workplace.operation_state
workplace.operation_state = FacilityInstance.OperationState.SUSPENDED # Presentation-only boundary fixture.
expect(effect_for(&"heroine_anri").get(&"applied") == true and runtime.get_floor_price_multiplier(2) == 12000, "passive placement does not acquire a workplace-operation condition")
workplace.operation_state = old_operation
var before: Dictionary = runtime.create_snapshot()
var before_bytes: PackedByteArray = var_to_bytes(before)
var exposed := row_for(&"heroine_anri")
exposed[&"unique_contract"][&"free_upkeep"] = false
exposed[&"unique_contract"][&"passive_effects"][0][&"floor_y"] = -999
exposed[&"unique_contract"][&"passive_effects"].clear()
expect(effect_for(&"heroine_anri").get(&"floor_y") == 2 and row_for(&"heroine_anri")[&"unique_contract"][&"free_upkeep"] == true, "report callers cannot mutate future contract/effect presentation")
expect(runtime.create_snapshot() == before and var_to_bytes(runtime.create_snapshot()) == before_bytes, "report and text rendering leave every live field/event/RNG/ID/queue byte unchanged")
var missing_plan: Dictionary = runtime.staff_service._work_assignments[&"heroine_anri"].duplicate(true)
runtime.staff_service._work_assignments[&"heroine_anri"][&"facility_id"] = &"absent_contract_workplace" # Invalid-link observation fixture, never saved as valid data.
expect(effect_for(&"heroine_anri").get(&"applied") == false and not effect_for(&"heroine_anri").has(&"floor_y") and runtime.get_floor_price_multiplier(2) == 10000, "missing facility neither invents a target nor keeps an active bonus")
expect(panel._unique_contract_text(row_for(&"heroine_anri")).contains("未適用(配属先なし・施設不在)"), "missing target is actionable in the ordinary detail text")
runtime.staff_service._work_assignments[&"heroine_anri"] = missing_plan
expect(runtime.create_snapshot() == before and var_to_bytes(runtime.create_snapshot()) == before_bytes, "invalid-link fixture was fully restored before compatibility assertions")
var report_before: Dictionary = runtime.get_staff_management_report()
expect(runtime.restore_snapshot(before), "unchanged existing schema restores canonical hire and planned placement")
expect(runtime.create_snapshot() == before and var_to_bytes(runtime.create_snapshot()) == before_bytes and runtime.get_staff_management_report() == report_before, "normal restore reconstructs report from persisted existing fields without new save values")
expect(not runtime.staff_service.remove_staff(&"heroine_anri", &"SOLD").is_success() and not runtime.staff_service.retire_staff(&"heroine_anri").is_success() and runtime.create_snapshot() == before, "visible protection corresponds to existing atomic remove/retire rejection")
finish(panel)
func identity_boundaries() -> void:
for options: Array in [[&"heroine_anri", &"innkeeper", &"FREE_HIRE"], [&"heroine_anri", &"cleaner", &"UNIQUE"], [&"unregistered_unique_fixture", &"innkeeper", &"UNIQUE"], [&"paid_zero_wage_fixture", &"receptionist", &"FREE_HIRE"]]:
var staff := StaffRuntime.new().configure(options[0], options[1], {&"employment_kind": options[2], &"daily_wage": 0})
expect(runtime._staff_unique_contract_report(staff).is_empty(), "synthetic wrong identity/kind/role or zero salary is not promoted to canonical unique")
var rai := StaffRuntime.new().configure(&"rival_rai", &"influencer", {&"employment_kind": &"UNIQUE"})
var contract: Dictionary = runtime._staff_unique_contract_report(rai)
expect(contract.get(&"canonical_id") == &"rival_rai" and contract.get(&"permanent_removal_forbidden") == true and contract.get(&"passive_effects", []).is_empty(), "canonical Rai gets general protection but no invented Anri effect or normal joining")
func finish(panel: StaffManagementPanel) -> void:
panel.free()
runtime.free()
clock.free()
state.free()
print("STAFF_UNIQUE_CONTRACT_REPORT checks=%d failures=%d" % [checks, failures])
quit(failures)