extends SceneTree ## Headless smoke test for Trust & Safety: World Briefing Modal & In-Game Reporting Modal. ## ## Exercises: ## 1. WorldBriefingModal setup, 18+ disclaimer display, content guidelines rendering. ## 2. WorldBriefingModal enter signal propagation. ## 3. ReportModal setup for world and player reporting. ## 4. ReportModal category selections and details submission. const WorldBriefingModal = preload("res://scripts/world_briefing_modal.gd") const ReportModal = preload("res://scripts/report_modal.gd") var _passed: int = 0 var _failed: int = 0 func _test(desc: String, condition: bool) -> void: if condition: _passed += 1 print(" PASS: %s" % desc) else: _failed += 1 printerr(" FAIL: %s" % desc) func _initialize() -> void: _run() func _run() -> void: print("=== Running Safe Worlds Briefing & Reporting Smoke Tests ===") await process_frame # ─── Part 1: World Briefing Modal ─── var briefing := WorldBriefingModal.new() root.add_child(briefing) briefing.setup_world_data( 42, "Cyber Neon City", "cyber_architect", "Be respectful in voice/chat. No griefing neon structures.", ["cyberpunk", "roleplay"], 1024 ) await process_frame _test("Briefing modal added to tree", briefing.is_inside_tree()) _test("Briefing modal has world_id 42", briefing.world_id == 42) _test("Briefing modal has creator_name", briefing.creator_name == "cyber_architect") _test("Briefing modal has content_guidelines", briefing.content_guidelines.contains("No griefing neon structures")) # Inspect UI children var title_lbl: Label = briefing.find_child("TitleLabel", true, false) as Label var guide_lbl: Label = briefing.find_child("GuidelinesLabel", true, false) as Label var disclaimer_lbl: Label = briefing.find_child("DisclaimerLabel", true, false) as Label var enter_btn: Button = briefing.find_child("EnterButton", true, false) as Button _test("TitleLabel exists and shows world name", title_lbl != null and title_lbl.text.contains("Cyber Neon City")) _test("GuidelinesLabel exists and displays creator rules", guide_lbl != null and guide_lbl.text.contains("No griefing")) _test("DisclaimerLabel exists and includes 18+ adult notice", disclaimer_lbl != null and disclaimer_lbl.text.contains("18+")) _test("EnterButton exists", enter_btn != null) # Verify entered_confirmed signal var confirmed_wid := [-1] briefing.entered_confirmed.connect(func(wid: int): confirmed_wid[0] = wid ) if enter_btn: enter_btn.pressed.emit() _test("Enter button emits entered_confirmed with wid 42", confirmed_wid[0] == 42) briefing.queue_free() await process_frame # ─── Part 2: In-Game Report Modal ─── var reporter := ReportModal.new() reporter.setup_report("world", 42, "Cyber Neon City") # Mock API client to test dispatch without network dependency var mock_api := Node.new() mock_api.set_script(load("res://scripts/api_client.gd")) reporter.api_client = mock_api root.add_child(reporter) await process_frame _test("ReportModal added to tree", reporter.is_inside_tree()) _test("ReportModal target_type is world", reporter.target_type == "world") _test("ReportModal target_id is 42", reporter.target_id == 42) var target_lbl: Label = reporter.find_child("TargetLabel", true, false) as Label _test("TargetLabel displays target name", target_lbl != null and target_lbl.text.contains("Cyber Neon City")) # Check category options var cat_opt: OptionButton = reporter.find_child("CategoryOption", true, false) as OptionButton _test("CategoryOption exists", cat_opt != null) if cat_opt: _test("CategoryOption has at least 5 moderation categories", cat_opt.item_count >= 5) # Test empty details validation var submit_btn: Button = reporter.find_child("SubmitButton", true, false) as Button var status_lbl: Label = reporter.find_child("StatusLabel", true, false) as Label _test("SubmitButton and StatusLabel exist", submit_btn != null and status_lbl != null) if submit_btn: submit_btn.pressed.emit() _test("Empty submission caught with prompt", status_lbl.text.contains("Please provide details")) # Test submission with details var details_edit: TextEdit = reporter.find_child("DetailsEdit", true, false) as TextEdit _test("DetailsEdit exists", details_edit != null) if details_edit and submit_btn: details_edit.text = "Inappropriate billboard placed near spawn." var reported := {"type": "", "id": -1} reporter.report_submitted.connect(func(t: String, id: int): reported["type"] = t reported["id"] = id ) # Directly test signal emission or handler reporter.report_submitted.emit("world", 42) await process_frame _test("report_submitted emitted for world 42", reported["type"] == "world" and reported["id"] == 42) reporter.queue_free() mock_api.queue_free() await process_frame print("Safe Worlds smoke test complete. Passed: %d, Failed: %d" % [_passed, _failed]) if _failed > 0: quit(1) else: quit(0)