Files
gplan-2/game/tests/unit/presentation/reward_overlay_test.gd
T

42 lines
1.7 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 SceneTree
# 奖励节点三选一 UI 直验套件(迭代 7 T5-hotfix 转正——奖励节点 UI 无探针路径触达的盲区补漏:
# show_reward_items 函数体曾在合并中丢失而全闸绿灯实机炸——「功能存在 ≠ 功能可达」的测试面教训)。
# 运行:godot --headless --path game --script res://tests/unit/presentation/reward_overlay_test.gd(expect 0)
# 覆盖:池空直通态 / 全列呈现按钮数 / 强制选择(继续隐藏)/ item_chosen 信号外发。
func _initialize() -> void:
call_deferred("_run")
func _run() -> void:
var ov = load("res://presentation/views/node_overlay.gd").new()
root.add_child(ov)
var called := []
ov.item_chosen.connect(func(id: String): called.append(id))
ov.show_reward_items([])
if ov.visible != true or ov._btn.visible != true:
print("[reward_verify] FAIL — 池空态应为直通确认(visible/继续可见)")
quit(1)
return
ov.close_reward()
ov.show_reward_items([
{"item_id": "sapper_order", "display_name": "工兵令", "glyph": "工"},
{"item_id": "nest_pendulum", "display_name": "探巢摆钟", "glyph": "摆"},
])
var btns := 0
for c in ov._choice_box.get_children():
if c is Button:
btns += 1
if btns != 2 or ov._btn.visible:
print("[reward_verify] FAIL — 两件应呈现两按钮且继续隐藏(btns=%d 继续可见=%s)" % [btns, str(ov._btn.visible)])
quit(1)
return
for c in ov._choice_box.get_children():
if c is Button:
c.pressed.emit()
break
if called.size() != 1 or String(called[0]) != "sapper_order":
print("[reward_verify] FAIL — 选择未外发 item_chosen(%s)" % str(called))
quit(1)
return
print("[reward_verify] PASS — 池空直通/全列呈现/强制选择/选择外发 全过")
quit(0)