fix(chat): support body and content fields in world and DM chat messages; feat(audio): add sound toggle switch and mute controls
checkpoint / checkpoint (push) Successful in 6m11s
checkpoint / checkpoint (push) Successful in 6m11s
This commit is contained in:
@@ -0,0 +1,172 @@
|
||||
extends SceneTree
|
||||
## Headless verification for world chat message send and sound toggle.
|
||||
|
||||
const PauseMenuScript = preload("res://scripts/pause_menu.gd")
|
||||
|
||||
func _initialize() -> void:
|
||||
_run()
|
||||
|
||||
func _run() -> void:
|
||||
await process_frame
|
||||
|
||||
print("SMOKE: Starting World Chat Send & Sound Toggle verification...")
|
||||
|
||||
# 1. Verify AudioManager and sound toggle
|
||||
var audio_mgr = root.get_node_or_null("AudioManager")
|
||||
if audio_mgr == null:
|
||||
printerr("FAIL: AudioManager not found in root")
|
||||
quit(1)
|
||||
return
|
||||
|
||||
# Test initial state
|
||||
audio_mgr.set_sound_enabled(true, false)
|
||||
if not audio_mgr.is_sound_enabled():
|
||||
printerr("FAIL: sound_enabled should be true")
|
||||
quit(1)
|
||||
return
|
||||
|
||||
var p = audio_mgr.play_click()
|
||||
if p == null:
|
||||
printerr("FAIL: play_click should return player when sound enabled")
|
||||
quit(1)
|
||||
return
|
||||
print("PASS: Sound plays when enabled.")
|
||||
|
||||
# Test toggle OFF
|
||||
var toggled: bool = audio_mgr.toggle_sound()
|
||||
if toggled != false or audio_mgr.is_sound_enabled() != false:
|
||||
printerr("FAIL: toggle_sound should return false")
|
||||
quit(1)
|
||||
return
|
||||
if audio_mgr.play_click() != null:
|
||||
printerr("FAIL: play_click should return null when sound disabled")
|
||||
quit(1)
|
||||
return
|
||||
print("PASS: Sound disabled and suppressed.")
|
||||
|
||||
# Test toggle ON
|
||||
toggled = audio_mgr.toggle_sound()
|
||||
if toggled != true or audio_mgr.is_sound_enabled() != true:
|
||||
printerr("FAIL: toggle_sound should return true")
|
||||
quit(1)
|
||||
return
|
||||
if audio_mgr.play_click() == null:
|
||||
printerr("FAIL: play_click should return player after re-enabling")
|
||||
quit(1)
|
||||
return
|
||||
print("PASS: Sound re-enabled and restored.")
|
||||
|
||||
# 2. Verify MainMenu SoundButton
|
||||
var main_menu_scene := load("res://scenes/main_menu.tscn")
|
||||
if main_menu_scene:
|
||||
var menu = main_menu_scene.instantiate()
|
||||
root.add_child(menu)
|
||||
await process_frame
|
||||
var sound_btn = menu.get_node_or_null("SoundButton")
|
||||
if sound_btn == null:
|
||||
printerr("FAIL: SoundButton not found on MainMenu")
|
||||
quit(1)
|
||||
return
|
||||
if not sound_btn.text.contains("Sound: ON"):
|
||||
printerr("FAIL: SoundButton text should be ON, got: ", sound_btn.text)
|
||||
quit(1)
|
||||
return
|
||||
# Click button
|
||||
sound_btn.emit_signal("pressed")
|
||||
await process_frame
|
||||
if not sound_btn.text.contains("Sound: OFF"):
|
||||
printerr("FAIL: SoundButton text should be OFF after click, got: ", sound_btn.text)
|
||||
quit(1)
|
||||
return
|
||||
audio_mgr.set_sound_enabled(true, false)
|
||||
menu.queue_free()
|
||||
await process_frame
|
||||
print("PASS: MainMenu SoundButton toggle verified.")
|
||||
|
||||
# 3. Verify PauseMenu sound button
|
||||
var pause_menu = PauseMenuScript.new(true, "Test World")
|
||||
root.add_child(pause_menu)
|
||||
await process_frame
|
||||
if pause_menu._sound_button == null:
|
||||
printerr("FAIL: _sound_button not found in PauseMenu")
|
||||
quit(1)
|
||||
return
|
||||
if not pause_menu._sound_button.text.contains("Sound FX: ON"):
|
||||
printerr("FAIL: PauseMenu sound button should say ON, got: ", pause_menu._sound_button.text)
|
||||
quit(1)
|
||||
return
|
||||
pause_menu._sound_button.emit_signal("pressed")
|
||||
await process_frame
|
||||
if not pause_menu._sound_button.text.contains("Sound FX: OFF"):
|
||||
printerr("FAIL: PauseMenu sound button should say OFF after toggle, got: ", pause_menu._sound_button.text)
|
||||
quit(1)
|
||||
return
|
||||
audio_mgr.set_sound_enabled(true, false)
|
||||
pause_menu.queue_free()
|
||||
await process_frame
|
||||
print("PASS: PauseMenu sound button toggle verified.")
|
||||
|
||||
# 4. Verify in-game Game HUD SoundButton
|
||||
var game_scene := load("res://scenes/game.tscn")
|
||||
if game_scene:
|
||||
var game_node = game_scene.instantiate()
|
||||
root.add_child(game_node)
|
||||
await process_frame
|
||||
var hud_sound_btn = game_node.find_child("SoundButton", true, false) as Button
|
||||
if hud_sound_btn == null:
|
||||
printerr("FAIL: SoundButton not found in game HUD")
|
||||
quit(1)
|
||||
return
|
||||
if not hud_sound_btn.text.contains("Sound [M]"):
|
||||
printerr("FAIL: HUD sound button should say Sound [M], got: ", hud_sound_btn.text)
|
||||
quit(1)
|
||||
return
|
||||
hud_sound_btn.emit_signal("pressed")
|
||||
await process_frame
|
||||
if not hud_sound_btn.text.contains("Muted [M]"):
|
||||
printerr("FAIL: HUD sound button should say Muted [M] after click, got: ", hud_sound_btn.text)
|
||||
quit(1)
|
||||
return
|
||||
audio_mgr.set_sound_enabled(true, false)
|
||||
game_node.queue_free()
|
||||
await process_frame
|
||||
print("PASS: In-game HUD sound button toggle verified.")
|
||||
|
||||
# 5. Verify world chat API send & retrieve (if backend reachable)
|
||||
var api_client = root.get_node_or_null("ApiClient")
|
||||
if api_client != null:
|
||||
var reg_res = await api_client.register("chat_u_%d" % int(Time.get_unix_time_from_system()), "testpass123", "chat_%d@test.com" % int(Time.get_unix_time_from_system()), true)
|
||||
if reg_res.ok:
|
||||
var world_res = await api_client.create_world("ChatTestWorld_%d" % int(Time.get_unix_time_from_system()), "Chat test world")
|
||||
if world_res.ok and world_res.data is Dictionary:
|
||||
var wid: int = int(world_res.data.get("id", 0))
|
||||
var send_res = await api_client.send_world_chat_message(wid, "Test message from smoke test!")
|
||||
if not send_res.ok:
|
||||
printerr("FAIL: send_world_chat_message failed: ", send_res.detail)
|
||||
quit(1)
|
||||
return
|
||||
print("PASS: send_world_chat_message succeeded.")
|
||||
var list_res = await api_client.get_world_chat_messages(wid)
|
||||
if not list_res.ok:
|
||||
printerr("FAIL: get_world_chat_messages failed: ", list_res.detail)
|
||||
quit(1)
|
||||
return
|
||||
var msgs: Array = []
|
||||
if list_res.data is Dictionary and list_res.data.has("messages"):
|
||||
msgs = list_res.data["messages"]
|
||||
elif list_res.data is Array:
|
||||
msgs = list_res.data
|
||||
if msgs.is_empty():
|
||||
printerr("FAIL: world chat messages empty after send")
|
||||
quit(1)
|
||||
return
|
||||
var msg_obj = msgs[0]
|
||||
var body_text: String = str(msg_obj.get("content", msg_obj.get("body", "")))
|
||||
if not body_text.contains("Test message from smoke test!"):
|
||||
printerr("FAIL: message text mismatch: ", body_text)
|
||||
quit(1)
|
||||
return
|
||||
print("PASS: World chat message sent and verified in history.")
|
||||
|
||||
print("SMOKE RESULT: PASS")
|
||||
quit(0)
|
||||
Reference in New Issue
Block a user