Files
TheTree_mock/tests/ui/test_staff_rest.gd
T
Takeshi b84bade045 Save The Tree implementation and acceptance work in progress
Preserve production code, regression fixtures, audio assets and provenance, test infrastructure, and the original-completion plan and progress ledger. Final game and Windows acceptance remain pending; excluded local artifacts and native experiments are not part of this snapshot.
2026-10-11 15:58:00 +09:00

46 lines
3.1 KiB
GDScript

extends SceneTree
const FixtureCleanup := preload("res://tests/helpers/ui_audio_fixture_cleanup.gd")
var checks := 0
var failures := 0
func _initialize() -> void: call_deferred("run")
func expect(ok: bool, message: String) -> void:
checks += 1
if not ok: failures += 1;push_error(message)
func run() -> void:
root.size = Vector2i(1440,810)
var clock: Variant = root.get_node("GameClock")
var state: Variant = root.get_node("GameState")
var runtime: Variant = root.get_node("SimulationRuntime")
clock.reset(1,6,0);state.reset();runtime.initialize(clock,state,718);clock.set_paused(true)
var main: Control = load("res://scenes/main/main.tscn").instantiate();root.add_child(main);await process_frame
runtime.configure_save_policy({&"enabled":false})
main._set_layer(1)
main.build_buttons[&"staff_waiting_room"].button_pressed = true
main._on_map_cell_clicked(Vector3i(-6,0,1))
expect(runtime.construction_service.get_jobs().size() == 1,"waiting room builds through the real map palette")
clock.advance_minutes(120)
# Fatigue/health fixture, normal public registration and authoritative movement.
expect(runtime.submit_command(&"register_staff",{&"staff_id":&"resting",&"role_id":&"porter",&"options":{&"health":20,&"fatigue":20,&"state":StaffRuntime.State.OFF_DUTY,&"current_cell":Vector3i(5,0,0)}},&"player").is_success(),"tired off-duty staff registers")
main._activate_management_mode(&"staff");main.staff_management_panel.select_staff(&"resting")
main.staff_management_panel.refresh()
expect(main.staff_management_panel.staff_detail_label.text.contains("休憩先へ移動中"),"panel exposes actual journey to rest")
clock.advance_minutes(60);main.staff_management_panel.refresh();main.world_preview.focus_operating_area()
await process_frame
expect(main.staff_management_panel.staff_detail_label.text.contains("待機室で休憩中"),"arrival updates the panel to resting")
expect(runtime.staff_service.get_staff(&"resting").health > 20,"resting health recovers in normal operations")
main.world_preview._prepare_room_presentations()
expect(main.world_preview._resting_staff.has(&"resting"),"room presentation uses actual resting staff ownership")
var room_id: StringName = main.world_preview._resting_staff.get(&"resting",&"")
expect(main.world_preview._room_presentations.get(room_id,{}).get(&"count",0) == 1,"rest room count is a real person, not cosmetic occupancy")
if OS.get_environment("THE_TREE_REST_CAPTURE") == "1":
main.world_preview.queue_redraw();await process_frame;await RenderingServer.frame_post_draw
expect(root.get_texture().get_image().save_png("res://artifacts/remaining-2026-09-29/staff-rest.png") == OK,"resting staff screenshot saved")
expect(runtime.restore_snapshot(runtime.create_snapshot()),"visible rest state remains saveable")
var _audio_cleanup_final: Dictionary = await FixtureCleanup.free_owner_and_wait(self, main)
if not bool(_audio_cleanup_final.get(&"passed", false)):
push_error("Ordinary fixture audio cleanup failed: %s" % str(_audio_cleanup_final))
quit(96)
return
await process_frame
print("Staff rest UI: %d checks, %d failures" % [checks,failures]);quit(failures)