122 lines
3.2 KiB
GDScript
122 lines
3.2 KiB
GDScript
extends SceneTree
|
|
## Headless smoke test for ChatUI scene and script.
|
|
|
|
func _initialize() -> void:
|
|
_run()
|
|
|
|
func _run() -> void:
|
|
await process_frame
|
|
|
|
print("SMOKE: Starting Chat UI verification...")
|
|
var scene_res := load("res://scenes/chat_ui.tscn")
|
|
if scene_res == null:
|
|
printerr("FAIL: Could not load res://scenes/chat_ui.tscn")
|
|
quit(1)
|
|
return
|
|
|
|
var ui: Control = scene_res.instantiate()
|
|
if ui == null:
|
|
printerr("FAIL: Could not instantiate ChatUI")
|
|
quit(1)
|
|
return
|
|
|
|
root.add_child(ui)
|
|
await process_frame
|
|
|
|
# Verify essential nodes
|
|
if ui.world_messages_container == null:
|
|
printerr("FAIL: world_messages_container is null")
|
|
quit(1)
|
|
return
|
|
|
|
if ui.dm_messages_container == null:
|
|
printerr("FAIL: dm_messages_container is null")
|
|
quit(1)
|
|
return
|
|
|
|
if ui.conv_list_container == null:
|
|
printerr("FAIL: conv_list_container is null")
|
|
quit(1)
|
|
return
|
|
|
|
if ui.report_dialog == null:
|
|
printerr("FAIL: report_dialog is null")
|
|
quit(1)
|
|
return
|
|
|
|
# Verify signal declaration
|
|
if not ui.has_signal("back_requested"):
|
|
printerr("FAIL: back_requested signal missing")
|
|
quit(1)
|
|
return
|
|
|
|
# Test message row creation with Report button
|
|
var mock_msg := {
|
|
"id": 101,
|
|
"author": {"username": "ChattyUser"},
|
|
"content": "Hello world! This is a test message."
|
|
}
|
|
ui._add_message_row(ui.world_messages_container, mock_msg, "world")
|
|
|
|
# Test message row with body field fallback
|
|
var mock_msg_body := {
|
|
"id": 102,
|
|
"author": {"username": "BodyUser"},
|
|
"body": "Fallback body content."
|
|
}
|
|
ui._add_message_row(ui.world_messages_container, mock_msg_body, "world")
|
|
|
|
if ui.world_messages_container.get_child_count() == 0:
|
|
printerr("FAIL: Message row was not added to world_messages_container")
|
|
quit(1)
|
|
return
|
|
|
|
var row: HBoxContainer = ui.world_messages_container.get_child(0)
|
|
var found_report := false
|
|
for child in row.get_children():
|
|
if child is Button and child.text == "Report":
|
|
found_report = true
|
|
break
|
|
|
|
if not found_report:
|
|
printerr("FAIL: Report button not found on message row")
|
|
quit(1)
|
|
return
|
|
|
|
var row2: HBoxContainer = ui.world_messages_container.get_child(1)
|
|
var lbl2: Label = row2.get_child(0) as Label
|
|
if not lbl2 or not lbl2.text.contains("Fallback body content."):
|
|
printerr("FAIL: Fallback body text was not displayed in message row")
|
|
quit(1)
|
|
return
|
|
print("PASS: Message row with body fallback verified.")
|
|
|
|
print("PASS: Message row with Report button verified.")
|
|
|
|
# Test report dialog preparation
|
|
ui._open_report_dialog(101, "world", "Hello world! This is a test message.")
|
|
if ui._reporting_message_id != 101 or ui._reporting_conv_type != "world":
|
|
printerr("FAIL: Report dialog state not set correctly")
|
|
quit(1)
|
|
return
|
|
|
|
print("PASS: Report dialog setup verified.")
|
|
|
|
# Test real-time WS chat message hook
|
|
var mock_ws_event := {
|
|
"id": 102,
|
|
"author": {"username": "LiveUser"},
|
|
"content": "Real-time incoming message!"
|
|
}
|
|
ui._on_ws_chat_message("world", ui._current_world_id, mock_ws_event)
|
|
if ui.world_messages_container.get_child_count() < 2:
|
|
printerr("FAIL: Live WS message was not appended to world chat")
|
|
quit(1)
|
|
return
|
|
|
|
print("PASS: Real-time WS chat message append verified.")
|
|
|
|
ui.queue_free()
|
|
print("SMOKE RESULT: PASS")
|
|
quit(0)
|