diff --git a/test/ui/components/array_editor/array_editor_test.gd b/test/ui/components/array_editor/array_editor_test.gd index 400a43f2..333e6a35 100644 --- a/test/ui/components/array_editor/array_editor_test.gd +++ b/test/ui/components/array_editor/array_editor_test.gd @@ -60,3 +60,41 @@ func test_array_window_opening() -> void: scene.array_window._on_close_requested() await assert_signal(signal_monitor).wait_until(500).is_emitted('about_to_popup') + +func test_create_reference_array() -> void: + var root = Pandora.create_category("Root") + var items = Pandora.create_category("Items", root) + var item = Pandora.create_entity("Item 1", items) + var npcs = Pandora.create_category("NPCs", root) + var items_prop: PandoraProperty = Pandora.create_property(npcs, "Items", "array") + items_prop.set_setting_override("Array Type", "reference") + var npc = Pandora.create_entity("Npc 1", npcs) + items_prop.set_setting_override("Array Type", "reference") + items_prop.set_setting_override("Category Filter", items.get_entity_id()) + var ref = PandoraReference.new(item.get_entity_id(), PandoraReference.Type.ENTITY).save_data() + npc.get_entity_property("Items").set_default_value([ref]) + + Pandora.save_data() + Pandora._clear() + Pandora.load_data() + + var scene = auto_free(load(__source).instantiate()) + var runner = scene_runner(scene) + var signal_monitor = monitor_signals(scene.array_window) + await runner.simulate_frames(1) + + scene.set_property(npc.get_entity_property("Items")) + + await runner.simulate_frames(10, 5) + + runner.set_mouse_pos(scene.edit_button.position + Vector2(10, 10)) + runner.simulate_mouse_button_pressed(MOUSE_BUTTON_LEFT) + + await runner.simulate_frames(10, 5) + + runner.set_mouse_pos(scene.array_window.array_manager.close_button.position + Vector2(10, 10)) + runner.simulate_mouse_button_pressed(MOUSE_BUTTON_LEFT) + + scene.array_window._on_close_requested() + + await assert_signal(signal_monitor).wait_until(500).is_not_emitted('item_removed', [ref])