test(@projects/@magic-civilization): 🐛 instantiate scenes (not bare scripts) in ecology UI tests

test_ecology_tile_inspector + test_ecology_grudge_badge did
TileInfoPanelScript.new() / CombatPreviewScript.new() — bare scripts whose
@onready %UniqueName labels resolve to null and log "Node not found" for every
label, which GUT flags as unexpected errors. Instantiate the real .tscn instead
(tile_info_panel.tscn lacks EcologySpeciesList, so the "absent list" scenario
still holds). Clears both tests + removes ~13 cross-test %node error bleeds.

GUT: 31 → 27 failing; Node-not-found errors 22 → 9.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Natalie 2026-06-24 04:06:17 -04:00
parent 5adedf911d
commit 07d34b6ac9
2 changed files with 9 additions and 4 deletions

View file

@ -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.

View file

@ -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