Files
modbison/scripts/smoke_test_creator_studio_importer.gd
daddy 7ecf0d53bd
checkpoint / checkpoint (push) Failing after 3h14m9s
Complete M11 Creator Studio and M12 Trust & Safety for PC5
- Creator Studio: Visual behavior & property inspector, GLB model importer, binary persistence
- Trust & Safety: 18+ TOS confirmation (DOB removed), creator guidelines & briefing card on join, in-game reporting HUD
- Test Harness: Add --filter, --skip-backend, --skip-godot to run_checkpoint_tests.py
2026-09-17 23:13:57 +00:00

104 lines
3.6 KiB
GDScript

extends SceneTree
## Headless smoke test for Creator Studio In-Game Model (.glb) Importer
const FIXTURE_PATH := "res://backend/tests/fixtures/chunks/simple_tile_chunk.bin"
const TEST_GLB_PATH := "res://assets/avatars/back_backpack_01.glb"
const ChunkEditorModelClass := preload("res://scripts/editor/chunk_editor_model.gd")
const EditorObjectCatalogClass := preload("res://scripts/editor/object_catalog.gd")
const EditorCoreClass := preload("res://scripts/editor/editor_core.gd")
const PalettePanelClass := preload("res://scripts/editor/ui/palette_panel.gd")
const StaticObjectNodeClass := preload("res://scripts/static_object_node.gd")
const WorldObjectClass := preload("res://scripts/world_object.gd")
var passed := 0
var failed := 0
func _check(label: String, cond: bool) -> void:
if cond:
passed += 1
print(" PASS: ", label)
else:
failed += 1
printerr(" FAIL: ", label)
func _initialize() -> void:
await _run()
func _read_fixture() -> PackedByteArray:
var f := FileAccess.open(FIXTURE_PATH, FileAccess.READ)
if f == null:
push_error("Could not open fixture: " + FIXTURE_PATH)
return PackedByteArray()
return f.get_buffer(f.get_length())
func _run() -> void:
print("=== Running Creator Studio Model Importer Smoke Tests ===")
var root := Node.new()
root.name = "TestRoot"
get_root().add_child(root)
var fixture_bytes := _read_fixture()
_check("Loaded fixture chunk bytes", fixture_bytes.size() > 0)
var model := ChunkEditorModelClass.from_binary(fixture_bytes)
_check("Decoded ChunkEditorModel", model != null)
var catalog := EditorObjectCatalogClass.new()
var cat_err := catalog.load_catalog()
_check("Loaded EditorObjectCatalog", cat_err == OK)
var core := EditorCoreClass.new(model, catalog)
_check("Initialized EditorCore", core != null)
# 1. Test PalettePanel setup
var palette := PalettePanelClass.new()
root.add_child(palette)
await process_frame
palette.set_catalog(catalog)
_check("PalettePanel configured with catalog", true)
# 2. Test importing a .glb model into PalettePanel
_check("Source .glb exists on disk", FileAccess.file_exists(TEST_GLB_PATH))
var cat_id := palette.import_model_file(TEST_GLB_PATH, "Adventure Backpack", "props")
_check("Custom model imported and returned catalog ID", not cat_id.is_empty())
_check("Catalog now has custom object", catalog.has_object(cat_id))
var entry := catalog.resolve(cat_id)
_check("Custom entry has display_name", entry.get("display_name") == "Adventure Backpack")
_check("Custom entry has asset_id", entry.has("asset_id"))
# 3. Test placing the custom model via EditorCore
var obj_id := core.place_object(cat_id, Vector3(2.0, 4.0, 0.0))
_check("Placed custom model in world via EditorCore", not obj_id.is_empty())
var obj := model.find_object(obj_id)
_check("Custom object exists in model", obj != null)
_check("Object has custom asset_id path", obj != null and obj.asset_id == entry["asset_id"])
# 4. Test StaticObjectNode rendering the custom .glb
var wo := WorldObjectClass.new()
wo.id = obj.id
wo.type = obj.type
wo.asset_id = obj.asset_id
wo.position = obj.position
wo.rotation = obj.rotation
wo.scale = obj.scale
wo.properties = obj.properties.duplicate(true)
var static_node := StaticObjectNodeClass.new()
static_node.world_object = wo
root.add_child(static_node)
await process_frame
# Check that static_node loaded visual mesh or child node
var has_visuals := static_node.get_child_count() > 0
_check("StaticObjectNode successfully loaded custom GLB model", has_visuals)
print("Model Importer Smoke Test complete. Passed: %d, Failed: %d" % [passed, failed])
if failed > 0:
quit(1)
else:
quit(0)