Test the store button through a real tap, not the handler

The bug reported three times was in the input path, and every test I had
called the handlers directly - so they all passed while the button was
inert. test_crafter_feedback now taps the control the way a touch does,
including after the build menu has been opened and closed, which is the
sequence that used to block every button in the game.

Verified against the old guard: the direct-call assertions still pass,
and the real tap fails with "store button dead after the build menu was
opened and closed".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Loïc Wisniewski 2026-08-11 23:44:29 +02:00
commit 7a8f521941

View file

@ -115,6 +115,48 @@ func _process(delta: float) -> bool:
quit(1)
return true
print("half a second later, still first: %s" % still)
# --- 6. a REAL tap, through the input path ------------------
# Everything above calls the handlers directly, which is how a
# whole class of bug kept getting missed: the crafter logic was
# fine and the BUTTON was inert, blocked by a modal guard. This
# taps the control the way a touch does.
game_state.withdraw_to_fleet(20)
var stock_before: int = game_state.building_stock(crafter_id)
var store_button: Control = scene.get_node("UI/CraftMenu/StoreOreButton")
for pressed in [true, false]:
var ev: InputEventScreenTouch = InputEventScreenTouch.new()
ev.pressed = pressed
ev.position = store_button.size / 2.0
store_button._gui_input(ev)
if game_state.building_stock(crafter_id) <= stock_before:
print("stock %d -> %d after tapping Store ore" % [
stock_before, game_state.building_stock(crafter_id)
])
print("TEST_CRAFTER_FEEDBACK: FAIL (tapping the store button did nothing)")
quit(1)
return true
print("real tap on Store ore moved %d ore into the crafter" % [
game_state.building_stock(crafter_id) - stock_before
])
# And the same tap must still work after the build menu has been
# opened and closed, which used to block every button forever.
controller._on_build_pressed()
controller._show_building_info(GameState.BUILDING_SHIP_CRAFTER)
scene.get_node("UI/BuildMenu").visible = false
game_state.withdraw_to_fleet(10)
var stock_mid: int = game_state.building_stock(crafter_id)
for pressed2 in [true, false]:
var ev2: InputEventScreenTouch = InputEventScreenTouch.new()
ev2.pressed = pressed2
ev2.position = store_button.size / 2.0
store_button._gui_input(ev2)
if game_state.building_stock(crafter_id) <= stock_mid:
print("TEST_CRAFTER_FEEDBACK: FAIL (store button dead after the build menu was opened and closed)")
quit(1)
return true
print("still works after opening and closing the build menu")
print("TEST_CRAFTER_FEEDBACK: PASS")
quit(0)
return true