73 lines
2.2 KiB
GDScript
73 lines
2.2 KiB
GDScript
extends SceneTree
|
|
## Headless smoke test for WalletUI scene and script.
|
|
|
|
func _initialize() -> void:
|
|
_run()
|
|
|
|
func _run() -> void:
|
|
await process_frame
|
|
print("[SMOKE] Starting WalletUI smoke test...")
|
|
|
|
var scene = load("res://scenes/wallet_ui.tscn")
|
|
if not scene:
|
|
printerr("[FAIL] Could not load scenes/wallet_ui.tscn")
|
|
quit(1)
|
|
return
|
|
|
|
var ui: Control = scene.instantiate()
|
|
root.add_child(ui)
|
|
await process_frame
|
|
|
|
# Verify onready nodes
|
|
assert(ui.back_button != null, "Missing back_button")
|
|
assert(ui.refresh_button != null, "Missing refresh_button")
|
|
assert(ui.balance_label != null, "Missing balance_label")
|
|
assert(ui.buy_100_btn != null, "Missing buy_100_btn")
|
|
assert(ui.buy_500_btn != null, "Missing buy_500_btn")
|
|
assert(ui.buy_1000_btn != null, "Missing buy_1000_btn")
|
|
assert(ui.buy_5000_btn != null, "Missing buy_5000_btn")
|
|
assert(ui.tx_container != null, "Missing tx_container")
|
|
assert(ui.prev_page_btn != null, "Missing prev_page_btn")
|
|
assert(ui.next_page_btn != null, "Missing next_page_btn")
|
|
assert(ui.page_label != null, "Missing page_label")
|
|
|
|
# Test rendering empty transactions
|
|
ui.render_transactions([])
|
|
assert(ui.tx_container.get_child_count() == 1, "Should have 1 empty notice child")
|
|
|
|
# Test rendering sample transactions
|
|
var sample_txs = [
|
|
{
|
|
"id": 1,
|
|
"created_at": "2026-09-15T12:00:00Z",
|
|
"type": "credit_purchase",
|
|
"amount": 500,
|
|
"balance_after": 500,
|
|
"reference_type": "payment",
|
|
"reference_id": "sess_123"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"created_at": "2026-09-15T12:15:00Z",
|
|
"type": "marketplace_purchase",
|
|
"amount": -200,
|
|
"balance_after": 300,
|
|
"reference_type": "marketplace_listing",
|
|
"reference_id": "45"
|
|
}
|
|
]
|
|
ui.render_transactions(sample_txs)
|
|
assert(ui.tx_container.get_child_count() == 2, "Should have 2 transaction rows")
|
|
|
|
# Test paging logic
|
|
ui.total_tx_count = 45
|
|
ui.current_page = 0
|
|
ui._update_paging_controls()
|
|
assert(ui.prev_page_btn.disabled == true, "Prev should be disabled on page 0")
|
|
assert(ui.next_page_btn.disabled == false, "Next should be enabled on page 0")
|
|
assert("Page 1 of 3" in ui.page_label.text, "Page label text mismatch")
|
|
|
|
ui.queue_free()
|
|
print("[SMOKE] WalletUI smoke test PASSED")
|
|
quit(0)
|