Skip to content

Commit

Permalink
test(array): added failing test for previous version
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelipemartins committed Sep 30, 2023
1 parent 98adcbc commit d05fa33
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/ui/components/array_editor/array_editor_test.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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])

0 comments on commit d05fa33

Please sign in to comment.