Files
modbison/scripts/smoke_test_chat_ui.gd

106 lines
2.6 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")
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
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)