diff --git a/src/game/engine/tests/unit/test_ecology_grudge_badge.gd b/src/game/engine/tests/unit/test_ecology_grudge_badge.gd index 36512332..a5244cb4 100644 --- a/src/game/engine/tests/unit/test_ecology_grudge_badge.gd +++ b/src/game/engine/tests/unit/test_ecology_grudge_badge.gd @@ -5,6 +5,8 @@ extends GutTest ## grudge_against result. Tests are headless-compatible (no display server needed). const CombatPreviewScript: GDScript = preload("res://engine/scenes/combat/combat_preview.gd") +## Full scene so the @onready %nodes resolve (bare .new() logs Node-not-found). +const PREVIEW_SCENE: PackedScene = preload("res://engine/scenes/combat/combat_preview.tscn") ## Minimal mock that satisfies the grudge_against() call signature. ## Extends RefCounted so it can be stored in a typed GdFaunaEcology field — @@ -40,7 +42,7 @@ func before_all() -> void: func test_grudge_badge_not_shown_without_fauna_ecology() -> void: ## When _fauna_ecology is null, no badge node should be added. - var preview: CombatPreviewScript = CombatPreviewScript.new() + var preview: CombatPreviewScript = PREVIEW_SCENE.instantiate() as CombatPreviewScript add_child_autofree(preview) # Don't inject fauna ecology — stays null. var atk: MockWildDefender = MockWildDefender.new() @@ -51,7 +53,7 @@ func test_grudge_badge_not_shown_without_fauna_ecology() -> void: func test_grudge_badge_not_shown_for_regular_unit() -> void: ## Regular units (no ecology_species_id) must never show a grudge badge. - var preview: CombatPreviewScript = CombatPreviewScript.new() + var preview: CombatPreviewScript = PREVIEW_SCENE.instantiate() as CombatPreviewScript add_child_autofree(preview) # Even with a grudge-always mock, regular units without the wild fields # should not trigger the badge. diff --git a/src/game/engine/tests/unit/test_ecology_tile_inspector.gd b/src/game/engine/tests/unit/test_ecology_tile_inspector.gd index 53b6bec8..157b3837 100644 --- a/src/game/engine/tests/unit/test_ecology_tile_inspector.gd +++ b/src/game/engine/tests/unit/test_ecology_tile_inspector.gd @@ -5,6 +5,9 @@ extends GutTest ## Headless-compatible (no display server required). const TileInfoPanelScript: GDScript = preload("res://engine/scenes/world_map/tile_info_panel.gd") +## Instantiate the full scene (not a bare script) so the @onready %nodes resolve; +## a bare .new() logs "Node not found" for every unique-name label. +const PANEL_SCENE: PackedScene = preload("res://engine/scenes/world_map/tile_info_panel.tscn") func before_all() -> void: @@ -14,7 +17,7 @@ func before_all() -> void: func test_ecology_list_absent_does_not_crash() -> void: ## When the scene does not include an EcologySpeciesList node, ## _populate_ecology_species should silently no-op. - var panel: TileInfoPanelScript = TileInfoPanelScript.new() + var panel: TileInfoPanelScript = PANEL_SCENE.instantiate() as TileInfoPanelScript add_child_autofree(panel) # _ecology_list will be null (no scene node named EcologySpeciesList). # Must not crash. @@ -24,7 +27,7 @@ func test_ecology_list_absent_does_not_crash() -> void: func test_set_fauna_ecology_stores_reference() -> void: ## set_fauna_ecology assigns _fauna_ecology — used by _populate_ecology_species. - var panel: TileInfoPanelScript = TileInfoPanelScript.new() + var panel: TileInfoPanelScript = PANEL_SCENE.instantiate() as TileInfoPanelScript add_child_autofree(panel) var mock: RefCounted = RefCounted.new() # Assign via the setter. The panel's typed field won't accept a plain