Files
DungeonCrawlerWorld/tests/e2e/test_hud_prompts_e2e.gd
T

39 lines
1.5 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 test_real_game_exposes_door_and_stairs_prompts_with_help_and_event_log() -> void:
var hud := game.get_node("HUD") as GameHud
var state := game.get_game_state()
var help_label := game.get_node("HUD/HelpLabel") as Label
var prompt_label := game.get_node("HUD/ContextPromptLabel") as Label
var event_log := game.get_node("HUD/EventLog") as RichTextLabel
assert_eq(hud.get_context_prompt(), "Espace — Ouvrir la porte")
assert_eq(prompt_label.text, "Espace — Ouvrir la porte")
assert_string_contains(help_label.text, "Déplacer : ZQSD / Flèches")
assert_string_contains(help_label.text, "Interagir : Espace ou E")
var interact_event := InputEventKey.new()
interact_event.keycode = KEY_SPACE
interact_event.pressed = true
game._unhandled_input(interact_event)
assert_eq(hud.get_context_prompt(), "Espace — Ouvrir la porte")
assert_eq(state.map.get_cell(Vector2i(2, 1)), GridMapState.CellKind.CLOSED_DOOR)
state.map.set_cell(Vector2i(2, 1), GridMapState.CellKind.FLOOR)
state.player.cell = Vector2i(9, 7)
game.submit_test_interact()
assert_eq(hud.get_context_prompt(), "Espace — Descendre l’escalier")
assert_eq(prompt_label.text, "Espace — Descendre l’escalier")
var results := game.submit_test_action(Vector2i.LEFT)
assert_eq(results[0].kind, &"moved")
assert_string_contains(event_log.get_parsed_text(), "You move to")