extends GutTest const GameScene = preload("res://scenes/Game.tscn") var game: Game func before_each() -> void: game = GameScene.instantiate() add_child_autofree(game) await get_tree().process_frame func after_each() -> void: # Rebinding changes the process-wide InputMap. Restore the project default so # this navigation contract cannot alter the physical-input contracts of later tests. var inventory_event := InputEventKey.new() inventory_event.keycode = KEY_I inventory_event.physical_keycode = KEY_I InputMap.action_erase_events(&"inventory") InputMap.action_add_event(&"inventory", inventory_event) func test_real_keyboard_navigation_opens_minimap_help_options_and_existing_action_panels() -> void: await _dispatch_key(KEY_TAB) var minimap := game.get_node("HUD/Minimap") as Minimap assert_true(minimap.visible) assert_true(minimap.expanded) await _dispatch_key(KEY_ESCAPE) assert_false(minimap.expanded) await _dispatch_key(KEY_F1) var help_panel := game.get_node("HUD/HelpPanel") as HelpPanel assert_true(help_panel.visible) assert_string_contains((help_panel.get_node("Body") as RichTextLabel).get_parsed_text(), "Inventaire") await _dispatch_key(KEY_ESCAPE) assert_false(help_panel.visible) await _dispatch_key(KEY_O) var options_panel := game.get_node("HUD/OptionsPanel") as OptionsPanel assert_true(options_panel.visible) assert_string_contains((options_panel.get_node("Body") as RichTextLabel).get_parsed_text(), "Échelle UI") await _dispatch_key(KEY_RIGHT) assert_gt(options_panel.ui_scale, 1.0) await _dispatch_key(KEY_DOWN) await _dispatch_key(KEY_DOWN) await _dispatch_key(KEY_ENTER) assert_true(options_panel.waiting_for_rebind) await _dispatch_key(KEY_F6) assert_eq(options_panel.binding_for(&"inventory"), KEY_F6) await _dispatch_key(KEY_ESCAPE) assert_false(options_panel.visible) await _dispatch_key(KEY_F6) assert_true((game.get_node("HUD/InventoryPanel") as PanelContainer).visible) await _dispatch_key(KEY_ESCAPE) assert_false((game.get_node("HUD/InventoryPanel") as PanelContainer).visible) await _dispatch_key(KEY_J) assert_true((game.get_node("HUD/QuestPanel") as PanelContainer).visible) await _dispatch_key(KEY_ESCAPE) assert_false((game.get_node("HUD/QuestPanel") as PanelContainer).visible) func _dispatch_key(keycode: Key) -> void: var event := InputEventKey.new() event.keycode = keycode event.physical_keycode = keycode event.pressed = true game._unhandled_input(event) await get_tree().process_frame