extends SceneTree ## Headless UI/save integration test. ## --headless --path . --script res://tools/ui_test.gd var failures := 0 func _init() -> void: call_deferred("_run") func _check(condition: bool, message: String) -> void: if not condition: failures += 1 print("FAIL: ", message) func _run() -> void: var err := change_scene_to_file("res://scenes/Main.tscn") if err != OK: print("FAIL: could not load Main") quit(1) return await process_frame await process_frame var main = current_scene var save = root.get_node_or_null("SaveGame") _check(save != null, "SaveGame autoload missing") if save == null: quit(1) return save.reset_progress() main.game.start_level(0) await process_frame save.set_setting("patterns", false) _check(not main.game.board.show_patterns, "patterns setting did not reach Board") save.set_setting("patterns", true) _check(main.game.board.show_patterns, "patterns setting did not restore") save.set_setting("show_timer", false) main.show_screen("game") await process_frame _check(not main.game.timer_label.visible, "show_timer setting did not hide timer") save.set_setting("show_timer", true) save.set_setting("hold_seconds", 0.50) _check(abs(main.game.board.hold_seconds - 0.50) < 0.001, "hold_seconds did not reach Board") save.set_setting("hold_seconds", 0.35) var unlocked: String = save.complete_room("room-01", 1) _check(unlocked == "pepper", "room 1 should unlock Pepper") _check(save.is_guest_unlocked("pepper"), "Pepper should be unlocked") _check(save.is_guest_unlocked("miso"), "Miso should be unlocked as a resident") main.show_screen("guest_book") await process_frame await process_frame _check(main.guest_book != null, "Guest Book missing") if main.guest_book != null and main.guest_book.progress_label != null: _check(main.guest_book.progress_label.text.find("6/25") >= 0, "Guest Book progress should be 6/25") main.show_screen("rules") await process_frame var tutorial_board = main.rulebook.tutorial_board _check(tutorial_board != null, "Tutorial board missing") if tutorial_board != null: for i in range(8): tutorial_board.hint() await process_frame _check(Rules.is_valid(tutorial_board.cells, tutorial_board.regions), "Tutorial puzzle did not solve") save.reset_progress() save.set_setting("patterns", true) save.set_setting("show_timer", true) save.set_setting("reduce_motion", false) save.set_setting("hold_seconds", 0.35) print("UI TEST: ", "PASS" if failures == 0 else "FAIL (%d)" % failures) quit(0 if failures == 0 else 1)