test: finalize S6.2 regression coverage
This commit is contained in:
@@ -11,17 +11,34 @@
|
||||
- `GameState.get_context_target()` et `InteractionResolver` partagent `InteractionResolver.TARGET_OFFSETS`. La priorité est : sortie déjà atteinte, escalier sous le joueur, coffre (sous le joueur ou dans l'ordre des offsets), porte, puis aucune interaction.
|
||||
- `Espace` et `E` ouvrent un coffre ciblé : `CHEST` devient `FLOOR`, le résultat est `chest_opened` avec le texte exact `You open the chest.`, l'exploration/FOV est recalculée et une seule réponse ennemie normale au plus est ajoutée.
|
||||
- Le HUD affiche exactement `Espace — Ouvrir le coffre` tant que le coffre est la cible de contexte. La documentation décrit aussi le comportement et l'absence volontaire de loot/inventaire.
|
||||
- Le parcours réel E2E utilise des `InputEvent` : porte (Espace), blocage sur coffre fermé, coffre (E), puis escalier (Espace).
|
||||
- Le parcours réel E2E utilise des `InputEvent` : porte (`E`, en conservant ainsi une preuve du binding alternatif), blocage sur coffre fermé, coffre (`Espace`, avec assertion explicite de `chest_opened` puis `FLOOR`), puis escalier (Espace).
|
||||
|
||||
## Couverture TDD
|
||||
|
||||
### RED historique reconstruit et durable
|
||||
|
||||
La preuve RED manquante a été reconstruite sur le baseline **`b5eaf0e`**, dans un worktree détaché, avant tout changement de production. Le test minimal crée une case `CHEST` adjacente et exige que `state.try_interact()` retourne `results[0].kind == &"chest_opened"`. Il échoue bien (statut 1) avec :
|
||||
|
||||
```text
|
||||
[STRING_NAME(nothing_to_interact)] expected to equal [STRING_NAME(chest_opened)]
|
||||
```
|
||||
|
||||
La source exacte et le journal GUT assaini sont versionnés ici afin que cette preuve reste consultable :
|
||||
|
||||
- `tdd-red-chest-contract-b5eaf0e.gd` ;
|
||||
- `tdd-red-chest-contract-b5eaf0e.txt`.
|
||||
|
||||
`./scripts/test-unit.sh` ne découvre volontairement que `res://tests/unit`; la reconstruction temporaire a donc été exécutée directement avec GUT et `-gdir=res://tests/tdd_red`, comme indiqué dans le journal. Le test GREEN permanent correspondant est `tests/unit/test_chest_interaction.gd`.
|
||||
|
||||
Les tests ajoutés couvrent les conditions des micro-tâches :
|
||||
|
||||
- M1 : dimensions 30×20, spawn et positions/route porte-coffre-escalier (`test_demo_map.gd`) ;
|
||||
- M2 : coffre fermé non praticable et mouvement bloqué sans réponse ennemie (`test_chest_interaction.gd`) ;
|
||||
- M3 : texte et durée du prompt coffre (`test_hud_chest_prompt.gd`) ;
|
||||
- M4 : `chest_opened`, texte exact, remplacement par sol, FOV et unique réponse ennemie (`test_chest_interaction.gd`) ;
|
||||
- M5 : scène `Game.tscn` et événements clavier réels pour le parcours intégral (`test_demo_map_chest_e2e.gd`).
|
||||
- M5 : scène `Game.tscn` et événements clavier réels pour le parcours intégral (`test_demo_map_chest_e2e.gd`) ; `E` reste vérifié sur la porte et `Espace` ouvre explicitement le coffre avec les assertions `chest_opened` et `FLOOR`.
|
||||
|
||||
`test_combat_hud_e2e.gd` rétablit les invariants de régression retirés lors de l'adaptation 30×20 : mur et porte bloqués sans tour ennemi, cellule joueur inchangée, dégâts/HP joueur et feedback visuel, messages du journal, HP et résumé de combat avant/après coup, puis suppression de la cible et résumé final après défaite.
|
||||
|
||||
Les tests existants adaptés à l'extension 30×20 conservent leurs invariants fonctionnels (combat, audio, FOV, caméra, HUD, porte et escalier) sans dépendre de l'ancien layout 12×10.
|
||||
|
||||
@@ -31,7 +48,7 @@ Exécutée avec Godot **4.5.0** (`/snap/bin/godot4`) :
|
||||
|
||||
```text
|
||||
./scripts/test-unit.sh PASS — 33 tests, 163 assertions
|
||||
./scripts/test-e2e.sh PASS — 12 tests, 127 assertions
|
||||
./scripts/test-e2e.sh PASS — 12 tests, 147 assertions
|
||||
./scripts/run-visual-check.sh PASS — Xvfb, deux captures PNG 1280×720
|
||||
./scripts/verify.sh PASS — unit + E2E + visual
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Historical RED reconstruction source
|
||||
#
|
||||
# Executed unchanged in a detached worktree at b5eaf0e with:
|
||||
# /snap/bin/godot4 --headless --path . -s res://addons/gut/gut_cmdln.gd \
|
||||
# -gdir=res://tests/tdd_red -gexit
|
||||
#
|
||||
# It is preserved as S6.2 TDD evidence rather than placed under tests/, because
|
||||
# its assertion intentionally fails before chest interaction is implemented.
|
||||
extends GutTest
|
||||
|
||||
const GridMapState = preload("res://scripts/domain/grid_map_state.gd")
|
||||
const ActorState = preload("res://scripts/domain/actor_state.gd")
|
||||
const GameState = preload("res://scripts/domain/game_state.gd")
|
||||
|
||||
func test_interacting_with_a_chest_reports_chest_opened() -> void:
|
||||
var chest := Vector2i(3, 2)
|
||||
var map := GridMapState.new(Vector2i(9, 7), GridMapState.CellKind.FLOOR)
|
||||
map.set_cell(chest, GridMapState.CellKind.CHEST)
|
||||
var state := GameState.new(map, ActorState.new(&"player", Vector2i(3, 3), 12, 3), {})
|
||||
|
||||
var results := state.try_interact()
|
||||
|
||||
assert_eq(results[0].kind, &"chest_opened")
|
||||
@@ -0,0 +1,43 @@
|
||||
S6.2 historical TDD RED reconstruction
|
||||
=======================================
|
||||
|
||||
Baseline revision: b5eaf0e
|
||||
Detached worktree: /home/hectelyon/Documents/Projects/ProjetsPersos/DungeonCrawlerWorld/.worktrees/s6-2-chest-red-b5eaf0e
|
||||
Test source preserved beside this log as tdd-red-chest-contract-b5eaf0e.gd.
|
||||
|
||||
Command (run from the detached b5eaf0e worktree):
|
||||
/snap/bin/godot4 --headless --path . -s res://addons/gut/gut_cmdln.gd \
|
||||
-gdir=res://tests/tdd_red -gexit
|
||||
|
||||
Exit status: 1 (expected RED)
|
||||
|
||||
Relevant sanitized GUT output:
|
||||
|
||||
res://tests/tdd_red/test_chest_contract_red.gd
|
||||
* test_interacting_with_a_chest_reports_chest_opened
|
||||
[Failed]: [STRING_NAME(nothing_to_interact)] expected to equal [STRING_NAME(chest_opened)]:
|
||||
at line 15
|
||||
0/1 passed.
|
||||
|
||||
==============================================
|
||||
= Run Summary
|
||||
==============================================
|
||||
|
||||
res://tests/tdd_red/test_chest_contract_red.gd
|
||||
- test_interacting_with_a_chest_reports_chest_opened
|
||||
[Failed]: [STRING_NAME(nothing_to_interact)] expected to equal [STRING_NAME(chest_opened)]:
|
||||
at line 15
|
||||
|
||||
Totals
|
||||
------
|
||||
Scripts 1
|
||||
Tests 1
|
||||
Passing Tests none
|
||||
Failing Tests 1
|
||||
Asserts 0/1
|
||||
|
||||
---- 1 failing tests ----
|
||||
|
||||
Note: ./scripts/test-unit.sh intentionally targets res://tests/unit only, so it
|
||||
cannot execute this temporary res://tests/tdd_red reconstruction. The direct
|
||||
GUT command above is therefore the authoritative RED command.
|
||||
+10
-9
@@ -15,6 +15,7 @@ const ActorViewType = preload("res://scripts/presentation/actor_view.gd")
|
||||
@onready var audio_library = $AudioLibrary
|
||||
var game_state: GameState
|
||||
var enemy_views: Dictionary[StringName, ActorView] = {}
|
||||
var last_turn_results: Array[TurnResult] = []
|
||||
|
||||
func _ready() -> void:
|
||||
game_state = _create_initial_state()
|
||||
@@ -59,23 +60,23 @@ func _prepare_exit_capture_state() -> void:
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"interact"):
|
||||
submit_test_interact()
|
||||
last_turn_results = submit_test_interact()
|
||||
elif event.is_action_pressed(&"move_north"):
|
||||
_process_action(Vector2i.UP)
|
||||
last_turn_results = _process_action(Vector2i.UP)
|
||||
elif event.is_action_pressed(&"move_south"):
|
||||
_process_action(Vector2i.DOWN)
|
||||
last_turn_results = _process_action(Vector2i.DOWN)
|
||||
elif event.is_action_pressed(&"move_west"):
|
||||
_process_action(Vector2i.LEFT)
|
||||
last_turn_results = _process_action(Vector2i.LEFT)
|
||||
elif event.is_action_pressed(&"move_east"):
|
||||
_process_action(Vector2i.RIGHT)
|
||||
last_turn_results = _process_action(Vector2i.RIGHT)
|
||||
elif event.is_action_pressed(&"move_northwest"):
|
||||
_process_action(Vector2i(-1, -1))
|
||||
last_turn_results = _process_action(Vector2i(-1, -1))
|
||||
elif event.is_action_pressed(&"move_northeast"):
|
||||
_process_action(Vector2i(1, -1))
|
||||
last_turn_results = _process_action(Vector2i(1, -1))
|
||||
elif event.is_action_pressed(&"move_southwest"):
|
||||
_process_action(Vector2i(-1, 1))
|
||||
last_turn_results = _process_action(Vector2i(-1, 1))
|
||||
elif event.is_action_pressed(&"move_southeast"):
|
||||
_process_action(Vector2i(1, 1))
|
||||
last_turn_results = _process_action(Vector2i(1, 1))
|
||||
|
||||
func submit_test_action(direction: Vector2i) -> Array[TurnResult]:
|
||||
return _process_action(direction)
|
||||
|
||||
@@ -44,23 +44,50 @@ func test_real_game_scene_completes_walking_combat_and_defeat_route() -> void:
|
||||
var hud := game.get_node("HUD") as GameHud
|
||||
var player_view := game.get_node("World/Player") as ActorView
|
||||
var enemy_view := game.get_node("World/Enemies/Goblin") as ActorView
|
||||
state.enemies[&"goblin"].cell = state.player.cell + Vector2i(2, 0)
|
||||
assert_eq(hud.combat_summary, "Target: Goblin HP: 6/6")
|
||||
assert_eq(hud.combat_summary_label.text, "Target: Goblin HP: 6/6")
|
||||
|
||||
# The new spawn is beside a wall and a closed door; neither consumes a turn.
|
||||
var start := state.player.cell
|
||||
var wall := game.submit_test_action(Vector2i(-1, -1))
|
||||
assert_eq(wall.size(), 1)
|
||||
assert_eq(wall[0].kind, &"blocked")
|
||||
assert_eq(state.player.cell, start)
|
||||
var door := game.submit_test_action(Vector2i.UP)
|
||||
assert_eq(door.size(), 1)
|
||||
assert_eq(door[0].kind, &"blocked")
|
||||
assert_eq(state.player.cell, start)
|
||||
assert_string_contains(hud.event_log.get_parsed_text(), "Your way is blocked.")
|
||||
|
||||
# Move the existing goblin onto the adapted combat lane after the map assertions.
|
||||
state.enemies[&"goblin"].cell = start + Vector2i(2, 0)
|
||||
var movement := game.submit_test_action(Vector2i.RIGHT)
|
||||
assert_eq(movement[0].kind, &"moved")
|
||||
assert_eq(state.player.cell, start + Vector2i.RIGHT)
|
||||
assert_eq(movement[1].kind, &"enemy_melee")
|
||||
assert_eq(player_view.last_damage, 2)
|
||||
assert_string_contains(game.get_node("HUD/PlayerHealthLabel").text, "10/12")
|
||||
assert_string_contains(hud.event_log.get_parsed_text(), "You move to (5, 12).")
|
||||
assert_string_contains(hud.event_log.get_parsed_text(), "The goblin hits you for 2.")
|
||||
|
||||
var first_melee := game.submit_test_action(Vector2i.RIGHT)
|
||||
assert_eq(first_melee[0].kind, &"melee")
|
||||
assert_eq(first_melee[1].kind, &"enemy_melee")
|
||||
assert_eq(enemy_view.last_damage, 3)
|
||||
assert_eq(player_view.last_damage, 2)
|
||||
assert_string_contains(game.get_node("HUD/EnemyHealthLabel").text, "3/6")
|
||||
assert_eq(hud.combat_summary, "Target: Goblin HP: 3/6")
|
||||
assert_eq(hud.combat_summary_label.text, "Target: Goblin HP: 3/6")
|
||||
assert_string_contains(hud.event_log.get_parsed_text(), "You strike the goblin for 3.")
|
||||
|
||||
var lethal_melee := game.submit_test_action(Vector2i.RIGHT)
|
||||
assert_eq(lethal_melee[0].kind, &"melee")
|
||||
assert_eq(lethal_melee[1].kind, &"enemy_defeated")
|
||||
assert_false(state.enemies.has(&"goblin"))
|
||||
await get_tree().process_frame
|
||||
assert_eq(game.get_node("World/Enemies").get_child_count(), 0)
|
||||
assert_eq(game.get_node_or_null("World/Enemies/Goblin"), null)
|
||||
assert_eq(game.get_node("HUD/EnemyHealthLabel").text, "No active target")
|
||||
assert_eq(hud.combat_summary, "No active target")
|
||||
assert_eq(hud.combat_summary_label.text, "No active target")
|
||||
assert_string_contains(hud.event_log.get_parsed_text(), "The goblin is defeated.")
|
||||
|
||||
@@ -17,7 +17,8 @@ func test_real_input_opens_door_then_chest_and_preserves_stairs_route() -> void:
|
||||
|
||||
assert_eq(state.map.size, Vector2i(30, 20))
|
||||
assert_eq(prompt_label.text, "Espace — Ouvrir la porte")
|
||||
game._unhandled_input(_key_event(KEY_SPACE))
|
||||
game._unhandled_input(_key_event(KEY_E))
|
||||
assert_eq(game.last_turn_results[0].kind, &"door_opened")
|
||||
assert_eq(state.map.get_cell(Vector2i(4, 11)), GridMapState.CellKind.FLOOR)
|
||||
|
||||
for keycode in [KEY_UP, KEY_UP, KEY_UP, KEY_UP]:
|
||||
@@ -29,7 +30,8 @@ func test_real_input_opens_door_then_chest_and_preserves_stairs_route() -> void:
|
||||
assert_eq(state.map.get_cell(Vector2i(4, 7)), GridMapState.CellKind.CHEST)
|
||||
assert_string_contains(event_log.get_parsed_text(), "Your way is blocked.")
|
||||
|
||||
game._unhandled_input(_key_event(KEY_E))
|
||||
game._unhandled_input(_key_event(KEY_SPACE))
|
||||
assert_eq(game.last_turn_results[0].kind, &"chest_opened")
|
||||
assert_eq(state.map.get_cell(Vector2i(4, 7)), GridMapState.CellKind.FLOOR)
|
||||
assert_eq(hud.get_context_prompt(), "")
|
||||
assert_string_contains(event_log.get_parsed_text(), "You open the chest.")
|
||||
|
||||
Reference in New Issue
Block a user