fix: prove title timing and compact journal readability

This commit is contained in:
goose
2026-10-09 13:17:25 -04:00
parent bc67e5ed88
commit bbf89a9f36
6 changed files with 109 additions and 6 deletions
+52 -3
View File
@@ -50,9 +50,8 @@ func test_real_hit_unlocks_reward_toast_journal_claim_and_title_refresh() -> voi
assert_eq(notification.text, "Frappeur")
assert_true(notification_timer.one_shot)
assert_eq(notification_timer.wait_time, 5.0)
notification_timer.timeout.emit()
await get_tree().process_frame
assert_false(notification.visible, "The title notification disappears at timeout")
# The real five-second expiry is intentionally verified by the dedicated
# transition test below, rather than manually emitting this timer's signal.
if permanent_title != null:
assert_eq(permanent_title.text, "Étage 0")
@@ -63,6 +62,56 @@ func test_real_hit_unlocks_reward_toast_journal_claim_and_title_refresh() -> voi
assert_true(game.get_run_state().recent_events(3).any(func(event: GameEvent) -> bool: return event.kind == &"achievement_reward_claimed"))
assert_string_contains((panel.get_node("Body") as RichTextLabel).get_parsed_text(), "Récompense reçue")
func test_title_notification_only_announces_real_transitions_and_expires_after_its_timer() -> void:
var permanent_title := game.get_node_or_null("HUD/TitleLabel") as Label
var notification := game.get_node_or_null("HUD/TitleNotificationLabel") as Label
var notification_timer := game.get_node_or_null("HUD/TitleNotificationTimer") as Timer
assert_not_null(permanent_title)
assert_not_null(notification)
assert_not_null(notification_timer)
if permanent_title == null or notification == null or notification_timer == null:
return
assert_false(notification.visible, "Initialization must not announce the established title")
assert_eq(notification.text, "")
assert_eq(permanent_title.text, "Étage 0")
game._refresh_title()
assert_false(notification.visible, "Refreshing the same current title stays silent")
assert_eq(permanent_title.text, "Étage 0")
game.title_engine = TitleEngineType.new([])
game._refresh_title()
assert_false(notification.visible, "Losing a title or receiving no title stays silent")
assert_eq(notification.text, "")
assert_eq(permanent_title.text, "Étage 0")
game.title_engine = TitleEngineType.new([
{"id": "renewed", "name": "Renouveau", "rank": 1, "conditions": []},
])
game._refresh_title()
assert_true(notification.visible, "A real title transition needs a temporary notification")
assert_eq(notification.text, "Renouveau")
assert_true(notification_timer.time_left > 0.0)
assert_eq(permanent_title.text, "Étage 0")
game.title_engine = TitleEngineType.new([])
game._refresh_title()
assert_false(notification.visible, "A title loss clears an in-flight notification")
assert_eq(notification.text, "")
assert_eq(permanent_title.text, "Étage 0")
game.title_engine = TitleEngineType.new([
{"id": "renewed", "name": "Renouveau", "rank": 1, "conditions": []},
])
game._refresh_title()
assert_true(notification.visible, "Regaining a title is a real transition")
await notification_timer.timeout
await get_tree().process_frame
assert_false(notification.visible, "The actual five-second timer hides the notification")
assert_eq(notification.text, "")
assert_eq(permanent_title.text, "Étage 0")
func _dispatch_key(keycode: Key) -> void:
Input.parse_input_event(_key_event(keycode, true))
await get_tree().process_frame
@@ -0,0 +1,25 @@
extends GutTest
const GameScene = preload("res://scenes/Game.tscn")
const RunSettingsType = preload("res://scripts/domain/run/run_settings.gd")
func test_capture_preparation_refreshes_the_real_name_and_started_journal() -> void:
var game := GameScene.instantiate() as Game
game.configure_new_run(RunSettingsType.new("visual-check", &"crawler", false, false), "Visual Check")
add_child_autofree(game)
await get_tree().process_frame
var hud := game.get_node_or_null("HUD") as GameHud
var character_title := game.get_node_or_null("HUD/ResponsiveLayout/CharacterSectionTitle") as Label
var event_log := game.get_node_or_null("HUD/EventLog") as RichTextLabel
assert_not_null(hud)
assert_not_null(character_title)
assert_not_null(event_log)
if hud == null or character_title == null or event_log == null:
return
assert_eq(character_title.text, "Visual Check")
assert_eq(event_log.get_parsed_text(), "", "Startup initially refreshes before game_started is appended")
game._refresh_capture_hud()
assert_eq(character_title.text, "Visual Check")
assert_string_contains(event_log.get_parsed_text(), "Visual Check commence une nouvelle aventure.")
@@ -0,0 +1 @@
uid://d00r2dqs4yi56