From a42002c8342ec56ee34b24e7adb5aab31612fb6e Mon Sep 17 00:00:00 2001 From: goose Date: Fri, 9 Oct 2026 00:16:07 -0400 Subject: [PATCH] test: expose broken HUD composition --- .goose/hud-red-report.md | 35 +++++++++ tests/e2e/test_visual_readability_e2e.gd | 60 ++++++++++++++++ tests/unit/test_display_layout.gd | 57 +++++++++++++++ tests/unit/test_hud_layout.gd | 90 ++++++++++++++++++++++++ 4 files changed, 242 insertions(+) create mode 100644 .goose/hud-red-report.md diff --git a/.goose/hud-red-report.md b/.goose/hud-red-report.md new file mode 100644 index 0000000..1c6f5ad --- /dev/null +++ b/.goose/hud-red-report.md @@ -0,0 +1,35 @@ +# HUD composition RED report + +## Scope + +RED-only TDD change. No production scene, script, or asset was modified. Contracts were added only to: + +- `tests/unit/test_hud_layout.gd` +- `tests/unit/test_display_layout.gd` +- `tests/e2e/test_visual_readability_e2e.gd` + +## Measured current-state failures + +Targeted GUT execution completed without `SCRIPT ERROR` or `Parse Error`. + +- **Journal/minimap collision:** at both 1920×1080 and 1280×720, `EventLog` and `LogPanel` intersect `Minimap`. +- **Mockup width proportions:** each rail measures 320/1920 = **16.67%** (below 22%); `PlayAreaFrame` measures 1180/1920 = **61.46%** (above 56%). The same scaled ratios occur at 1280×720. +- **Opaque outside-play-area mask:** all four required `PlayAreaMaskTop`, `PlayAreaMaskLeft`, `PlayAreaMaskRight`, and `PlayAreaMaskBottom` nodes are absent. +- **Named visual sections:** `CharacterSection`, `ObjectivesSection`, `StatusSection`, `JournalSection`, and `MapSection` are absent. +- **Camera viewport:** the camera exposes **1920×1080** while `PlayAreaFrame` is **1180×830**, proving the world is still full-screen rather than constrained to the central frame. + +## Commands and result + +```sh +/snap/bin/godot4 --headless --path . -s res://addons/gut/gut_cmdln.gd \ + -gtest=res://tests/unit/test_hud_layout.gd,res://tests/unit/test_display_layout.gd -gexit +/snap/bin/godot4 --headless --path . -s res://addons/gut/gut_cmdln.gd \ + -gtest=res://tests/e2e/test_visual_readability_e2e.gd -gexit +``` + +Expected RED result observed: + +- unit targeted suite: **5 failing tests** (16/21 passing) +- E2E targeted suite: **1 failing test** (1/2 passing) + +The failures are behavioral contract failures listed above, not parser failures. diff --git a/tests/e2e/test_visual_readability_e2e.gd b/tests/e2e/test_visual_readability_e2e.gd index 9849b42..84b6f5b 100644 --- a/tests/e2e/test_visual_readability_e2e.gd +++ b/tests/e2e/test_visual_readability_e2e.gd @@ -50,6 +50,66 @@ func test_real_game_scene_exposes_readable_fov_zoom_and_framed_center_viewport() for region: Control in [top_bar, left_rail, right_rail, command_bar]: assert_false(region.get_global_rect().intersects(play_rect), "%s obscures the framed center viewport" % region.name) +func test_live_scene_has_an_unmasked_central_camera_view_and_named_non_overlapping_rail_sections() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + var camera := game.get_node_or_null("Camera2D") as Camera2D + assert_not_null(hud, "Game scene requires HUD") + assert_not_null(camera, "Game scene requires Camera2D") + if hud == null or camera == null: + return + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout") + if layout == null: + return + var artboard := layout.get_node_or_null("Artboard") as Control + var play_area := layout.get_node_or_null("PlayAreaFrame") as Control + assert_not_null(artboard, "ResponsiveLayout requires Artboard") + assert_not_null(play_area, "ResponsiveLayout requires PlayAreaFrame") + if artboard == null or play_area == null: + return + + assert_eq(camera.get_viewport().get_visible_rect().size, play_area.get_global_rect().size, "The real-game camera must render only the central PlayAreaFrame rather than the full artboard") + _assert_live_named_sections(layout, "LeftRail", ["CharacterSection", "ObjectivesSection", "StatusSection"]) + _assert_live_named_sections(layout, "RightRail", ["JournalSection", "MapSection"]) + _assert_live_play_area_masks(layout, artboard.get_global_rect(), play_area.get_global_rect()) + +func _assert_live_named_sections(layout: Control, rail_name: String, names: Array[String]) -> void: + var rail := layout.get_node_or_null(rail_name) as Control + assert_not_null(rail, "ResponsiveLayout requires %s" % rail_name) + if rail == null: + return + var sections: Array[Control] = [] + for section_name in names: + var section := layout.get_node_or_null(section_name) as Control + assert_not_null(section, "%s must expose a named %s section" % [rail_name, section_name]) + if section == null: + continue + assert_true(section.visible, "%s must be visible in the real game scene" % section_name) + assert_true(rail.get_global_rect().encloses(section.get_global_rect()), "%s must stay inside %s" % [section_name, rail_name]) + sections.append(section) + for index in sections.size(): + for other_index in range(index + 1, sections.size()): + assert_false(sections[index].get_global_rect().intersects(sections[other_index].get_global_rect()), "%s overlaps %s" % [sections[index].name, sections[other_index].name]) + +func _assert_live_play_area_masks(layout: Control, artboard_rect: Rect2, play_rect: Rect2) -> void: + var expected_masks := { + "PlayAreaMaskTop": Rect2(artboard_rect.position, Vector2(artboard_rect.size.x, play_rect.position.y - artboard_rect.position.y)), + "PlayAreaMaskLeft": Rect2(Vector2(artboard_rect.position.x, play_rect.position.y), Vector2(play_rect.position.x - artboard_rect.position.x, play_rect.size.y)), + "PlayAreaMaskRight": Rect2(Vector2(play_rect.end.x, play_rect.position.y), Vector2(artboard_rect.end.x - play_rect.end.x, play_rect.size.y)), + "PlayAreaMaskBottom": Rect2(Vector2(artboard_rect.position.x, play_rect.end.y), Vector2(artboard_rect.size.x, artboard_rect.end.y - play_rect.end.y)), + } + for mask_name: String in expected_masks: + var mask := layout.get_node_or_null(mask_name) as Panel + assert_not_null(mask, "Real-game HUD requires %s" % mask_name) + if mask == null: + continue + assert_eq(mask.get_global_rect(), expected_masks[mask_name], "%s must exactly cover its artboard band outside PlayAreaFrame" % mask_name) + assert_false(mask.get_global_rect().intersects(play_rect), "%s must leave the PlayAreaFrame interior visible" % mask_name) + var style := mask.get_theme_stylebox(&"panel") as StyleBoxFlat + assert_not_null(style, "%s requires an opaque panel style" % mask_name) + if style != null: + assert_eq(style.bg_color.a, 1.0, "%s must be fully opaque" % mask_name) + func _assert_legacy_panel_paths(layout: Control) -> void: assert_not_null(layout.get_node_or_null("StatsPanel") as PanelContainer, "HUD must preserve ResponsiveLayout/StatsPanel") assert_not_null(layout.get_node_or_null("LogPanel") as PanelContainer, "HUD must preserve ResponsiveLayout/LogPanel because GameHud uses that path") diff --git a/tests/unit/test_display_layout.gd b/tests/unit/test_display_layout.gd index 9605b02..dffdcc5 100644 --- a/tests/unit/test_display_layout.gd +++ b/tests/unit/test_display_layout.gd @@ -87,6 +87,63 @@ func test_camera_tracks_player_after_a_valid_action_and_uses_map_limits() -> voi assert_eq(camera.position, Vector2(state.player.cell * GameType.TILE_SIZE) + game.get_node("World").position) +func test_play_area_has_four_opaque_masks_that_cover_only_the_artboard_outside_the_frame() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + + for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: + hud.apply_viewport_layout(viewport_size) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout at %s" % viewport_size) + if layout == null: + return + var artboard := layout.get_node_or_null("Artboard") as Control + var play_area := layout.get_node_or_null("PlayAreaFrame") as Control + assert_not_null(artboard, "ResponsiveLayout requires Artboard at %s" % viewport_size) + assert_not_null(play_area, "ResponsiveLayout requires PlayAreaFrame at %s" % viewport_size) + if artboard == null or play_area == null: + return + + var artboard_rect := artboard.get_global_rect() + var play_rect := play_area.get_global_rect() + var expected_masks := { + "PlayAreaMaskTop": Rect2(artboard_rect.position, Vector2(artboard_rect.size.x, play_rect.position.y - artboard_rect.position.y)), + "PlayAreaMaskLeft": Rect2(Vector2(artboard_rect.position.x, play_rect.position.y), Vector2(play_rect.position.x - artboard_rect.position.x, play_rect.size.y)), + "PlayAreaMaskRight": Rect2(Vector2(play_rect.end.x, play_rect.position.y), Vector2(artboard_rect.end.x - play_rect.end.x, play_rect.size.y)), + "PlayAreaMaskBottom": Rect2(Vector2(artboard_rect.position.x, play_rect.end.y), Vector2(artboard_rect.size.x, artboard_rect.end.y - play_rect.end.y)), + } + for mask_name: String in expected_masks: + var mask := layout.get_node_or_null(mask_name) as Panel + assert_not_null(mask, "ResponsiveLayout requires %s at %s" % [mask_name, viewport_size]) + if mask == null: + continue + assert_true(mask.visible, "%s must be visible at %s" % [mask_name, viewport_size]) + assert_eq(mask.get_global_rect(), expected_masks[mask_name], "%s must exactly cover its outside-PlayAreaFrame band at %s" % [mask_name, viewport_size]) + assert_false(mask.get_global_rect().intersects(play_rect), "%s must not mask the PlayAreaFrame interior at %s" % [mask_name, viewport_size]) + var style := mask.get_theme_stylebox(&"panel") as StyleBoxFlat + assert_not_null(style, "%s requires an explicit opaque panel style" % mask_name) + if style != null: + assert_eq(style.bg_color.a, 1.0, "%s must be fully opaque" % mask_name) + +func test_camera_viewport_is_constrained_to_the_central_play_area_frame() -> void: + var game := GameScene.instantiate() as Game + add_child_autofree(game) + await get_tree().process_frame + var camera := game.get_node_or_null("Camera2D") as Camera2D + var play_area := game.get_node_or_null("HUD/ResponsiveLayout/PlayAreaFrame") as Control + assert_not_null(camera, "Game scene requires Camera2D") + assert_not_null(play_area, "HUD requires ResponsiveLayout/PlayAreaFrame") + if camera == null or play_area == null: + return + + assert_eq(camera.get_viewport().get_visible_rect().size, play_area.get_global_rect().size, "The camera viewport must expose the central PlayAreaFrame, not the full-screen world") + func test_camera_limits_are_recomputed_when_entering_a_larger_generated_floor() -> void: var game := GameScene.instantiate() as Game add_child_autofree(game) diff --git a/tests/unit/test_hud_layout.gd b/tests/unit/test_hud_layout.gd index 1d2552b..a27a1b9 100644 --- a/tests/unit/test_hud_layout.gd +++ b/tests/unit/test_hud_layout.gd @@ -392,6 +392,96 @@ func test_long_deadline_text_wraps_and_stays_inside_the_left_rail() -> void: assert_lte(deadline.get_minimum_size().x, deadline.size.x) assert_gt(deadline.size.y, deadline.get_line_height()) +func test_event_log_and_log_panel_never_intersect_the_hud_minimap_at_reference_and_compact_sizes() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + + for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: + hud.apply_viewport_layout(viewport_size) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + var event_log := hud.get_node_or_null("EventLog") as Control + var minimap := hud.get_node_or_null("Minimap") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout at %s" % viewport_size) + assert_not_null(event_log, "HUD requires EventLog at %s" % viewport_size) + assert_not_null(minimap, "HUD requires Minimap at %s" % viewport_size) + if layout == null or event_log == null or minimap == null: + return + var log_panel := layout.get_node_or_null("LogPanel") as Control + assert_not_null(log_panel, "HUD requires ResponsiveLayout/LogPanel at %s" % viewport_size) + if log_panel == null: + return + + assert_false(event_log.get_global_rect().intersects(minimap.get_global_rect()), "EventLog must not intersect HUD/Minimap at %s" % viewport_size) + assert_false(log_panel.get_global_rect().intersects(minimap.get_global_rect()), "LogPanel must not intersect HUD/Minimap at %s" % viewport_size) + +func test_artboard_rails_and_center_follow_the_mockup_width_proportions() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + + for viewport_size: Vector2 in [Vector2(1920, 1080), Vector2(1280, 720)]: + hud.apply_viewport_layout(viewport_size) + await get_tree().process_frame + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout at %s" % viewport_size) + if layout == null: + return + var artboard := layout.get_node_or_null("Artboard") as Control + var left_rail := layout.get_node_or_null("LeftRail") as Control + var play_area := layout.get_node_or_null("PlayAreaFrame") as Control + var right_rail := layout.get_node_or_null("RightRail") as Control + assert_not_null(artboard, "ResponsiveLayout requires Artboard at %s" % viewport_size) + assert_not_null(left_rail, "ResponsiveLayout requires LeftRail at %s" % viewport_size) + assert_not_null(play_area, "ResponsiveLayout requires PlayAreaFrame at %s" % viewport_size) + assert_not_null(right_rail, "ResponsiveLayout requires RightRail at %s" % viewport_size) + if artboard == null or left_rail == null or play_area == null or right_rail == null: + return + + var left_ratio := left_rail.size.x / artboard.size.x + var center_ratio := play_area.size.x / artboard.size.x + var right_ratio := right_rail.size.x / artboard.size.x + assert_gte(left_ratio, 0.22, "LeftRail must use at least 22%% of the artboard width at %s" % viewport_size) + assert_lte(left_ratio, 0.26, "LeftRail must use at most 26%% of the artboard width at %s" % viewport_size) + assert_gte(center_ratio, 0.48, "PlayAreaFrame must use at least 48%% of the artboard width at %s" % viewport_size) + assert_lte(center_ratio, 0.56, "PlayAreaFrame must use at most 56%% of the artboard width at %s" % viewport_size) + assert_gte(right_ratio, 0.22, "RightRail must use at least 22%% of the artboard width at %s" % viewport_size) + assert_lte(right_ratio, 0.26, "RightRail must use at most 26%% of the artboard width at %s" % viewport_size) + +func test_named_left_and_right_rail_sections_are_visible_enclosed_and_non_overlapping() -> void: + var hud := game.get_node_or_null("HUD") as GameHud + assert_not_null(hud, "Game scene requires HUD") + if hud == null: + return + var layout := hud.get_node_or_null("ResponsiveLayout") as Control + assert_not_null(layout, "HUD requires ResponsiveLayout") + if layout == null: + return + + _assert_named_non_overlapping_sections(layout, "LeftRail", ["CharacterSection", "ObjectivesSection", "StatusSection"]) + _assert_named_non_overlapping_sections(layout, "RightRail", ["JournalSection", "MapSection"]) + +func _assert_named_non_overlapping_sections(layout: Control, rail_name: String, section_names: Array[String]) -> void: + var rail := layout.get_node_or_null(rail_name) as Control + assert_not_null(rail, "ResponsiveLayout requires %s" % rail_name) + if rail == null: + return + var sections: Array[Control] = [] + for section_name in section_names: + var section := layout.get_node_or_null(section_name) as Control + assert_not_null(section, "%s requires a visible %s" % [rail_name, section_name]) + if section == null: + continue + assert_true(section.visible, "%s must be visible" % section_name) + assert_true(rail.get_global_rect().encloses(section.get_global_rect()), "%s must be enclosed by %s" % [section_name, rail_name]) + sections.append(section) + for index in sections.size(): + for other_index in range(index + 1, sections.size()): + assert_false(sections[index].get_global_rect().intersects(sections[other_index].get_global_rect()), "%s must not overlap %s" % [sections[index].name, sections[other_index].name]) + func _assert_play_area_is_centered_and_inside_effective_viewport(play_area_frame: Control) -> void: var viewport_rect := get_viewport().get_visible_rect() var expected_viewport := Vector2(Game.REFERENCE_VIEWPORT)