Files
TheTree_mock/tests/ui/test_upkeep_inspector.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

55 lines
2.7 KiB
GDScript

extends SceneTree
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:
var runtime: Variant = root.get_node("SimulationRuntime")
var clock: Variant = root.get_node("GameClock")
var state: Variant = root.get_node("GameState")
clock.reset(1, 6, 0)
state.reset()
runtime.initialize(clock, state, 424242)
clock.set_paused(true)
root.size = Vector2i(1440, 900)
var main: Control = load("res://scenes/main/main.tscn").instantiate()
main.set("manual_save_path", "user://tests/upkeep_inspector_%d" % OS.get_process_id())
root.add_child(main)
await process_frame
runtime.configure_save_policy({&"enabled": false, &"daily_checkpoint_enabled": false})
var definition: FacilityDefinition = runtime.definition_registry.get_facility(&"guest_corridor")
var old_rate := definition.maintenance_gold
definition.maintenance_gold = 1440
expect(runtime.submit_command(&"build_facility", {&"definition_id": &"guest_corridor", &"origin": Vector3i(4, 1, 0)}).is_success(), "public construction accepts infrastructure")
clock.advance_minutes(10)
var facilities: Array = runtime.construction_service.get_facilities()
expect(facilities.size() == 1, "one completed corridor")
if not facilities.is_empty():
var id: StringName = facilities[0][&"instance_id"]
clock.advance_minutes(3)
main.get("world_preview").facility_selected.emit(id)
var report: Dictionary = runtime.get_facility_upkeep_report(id)
expect(report[&"owned"] and report[&"daily_rate"] == 1440 and report[&"unsettled_units"] == 4320, "inspector projection preserves exact ownership accrual")
var text: String = main.get("selected_detail_label").text
expect("設備完成" in text and "1440G / 日" in text and "約3.00G" in text and "未払い 0G" in text, "infrastructure inspector displays daily pending and unpaid amounts")
expect("閉店・休止中" in text and "同期しています" not in text, "completed infrastructure explains ownership instead of a permanent sync placeholder")
var before: Dictionary = runtime.create_snapshot()
main.call("_refresh_selected_entity")
expect(runtime.create_snapshot() == before, "refresh is read only")
if DisplayServer.get_name() != "headless":
for frame in 6:
await process_frame
await RenderingServer.frame_post_draw
DirAccess.make_dir_recursive_absolute("res://artifacts/upkeep-2026-09-29")
expect(root.get_texture().get_image().save_png("res://artifacts/upkeep-2026-09-29/upkeep-inspector.png") == OK, "rendered inspector captured")
definition.maintenance_gold = old_rate
main.queue_free()
await process_frame
print("%s: %d checks" % ["PASS" if failures == 0 else "FAIL", checks])
quit(failures)