Skip to content

Commit 166a97f

Browse files
committed
Update shared examples for sorting
If sortable elements have a handle we need to account for it, so that drag and drop can be performed correctly.
1 parent ca8f01e commit 166a97f

File tree

1 file changed

+5
-1
lines changed
  • admin/lib/solidus_admin/testing_support/shared_examples

1 file changed

+5
-1
lines changed

admin/lib/solidus_admin/testing_support/shared_examples/moveable.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
RSpec.shared_examples_for "features: sortable" do
2323
let(:factory_attrs) { {} }
2424
let(:scope) { "body" }
25+
let(:handle) { nil }
2526

2627
before do
2728
create(factory, displayed_attribute => "First", position: 1, **factory_attrs)
@@ -35,7 +36,10 @@
3536
expect(find("[data-controller='sortable']").all(:xpath, "./*").last).to have_text("Second")
3637

3738
rows = find("[data-controller='sortable']").all(:xpath, "./*")
38-
rows[1].drag_to rows[0]
39+
target = rows[0]
40+
source = rows[1]
41+
source = source.find(handle) if handle
42+
source.drag_to target
3943

4044
expect(find("[data-controller='sortable']").all(:xpath, "./*").first).to have_text("Second")
4145
expect(find("[data-controller='sortable']").all(:xpath, "./*").last).to have_text("First")

0 commit comments

Comments
 (0)