81 lines
2.0 KiB
GDScript
81 lines
2.0 KiB
GDScript
extends SceneTree
|
|
## Headless smoke test for ProfileUI scene and script.
|
|
|
|
func _initialize() -> void:
|
|
_run()
|
|
|
|
func _run() -> void:
|
|
await process_frame
|
|
|
|
print("SMOKE: Starting Profile UI verification...")
|
|
var scene_res := load("res://scenes/profile_ui.tscn")
|
|
if scene_res == null:
|
|
printerr("FAIL: Could not load res://scenes/profile_ui.tscn")
|
|
quit(1)
|
|
return
|
|
|
|
var ui: Control = scene_res.instantiate()
|
|
if ui == null:
|
|
printerr("FAIL: Could not instantiate ProfileUI")
|
|
quit(1)
|
|
return
|
|
|
|
root.add_child(ui)
|
|
await process_frame
|
|
|
|
# Verify essential nodes
|
|
if ui.username_label == null or ui.bio_edit == null:
|
|
printerr("FAIL: username_label or bio_edit is null")
|
|
quit(1)
|
|
return
|
|
|
|
if ui.privacy_vbox == null or ui.favorites_container == null or ui.friends_container == null:
|
|
printerr("FAIL: container nodes are null")
|
|
quit(1)
|
|
return
|
|
|
|
# Verify signal declaration
|
|
if not ui.has_signal("back_requested"):
|
|
printerr("FAIL: back_requested signal missing")
|
|
quit(1)
|
|
return
|
|
|
|
# Test card population
|
|
ui._populate_card(99, "TestExplorer", "Just another world builder", 12)
|
|
if ui.username_label.text != "TestExplorer" or ui.bio_edit.text != "Just another world builder":
|
|
printerr("FAIL: Card population failed")
|
|
quit(1)
|
|
return
|
|
|
|
print("PASS: Profile card population verified.")
|
|
|
|
# Test favorites population
|
|
var mock_favs := [
|
|
{"id": 1, "name": "Sunset Plains"},
|
|
{"id": 2, "name": "Neon City Rooftops"}
|
|
]
|
|
ui._populate_favorites(mock_favs)
|
|
if ui.favorites_container.get_child_count() != 2:
|
|
printerr("FAIL: Favorites count mismatch")
|
|
quit(1)
|
|
return
|
|
|
|
print("PASS: Favorites list population verified.")
|
|
|
|
# Test friends population
|
|
var mock_friends := [
|
|
{"id": 10, "username": "Alice"},
|
|
{"id": 20, "username": "Bob"}
|
|
]
|
|
ui._populate_friends(mock_friends)
|
|
if ui.friends_container.get_child_count() != 2:
|
|
printerr("FAIL: Friends list count mismatch")
|
|
quit(1)
|
|
return
|
|
|
|
print("PASS: Friends list population verified.")
|
|
|
|
ui.queue_free()
|
|
print("SMOKE RESULT: PASS")
|
|
quit(0)
|