Skip to content

Commit 09a283e

Browse files
committed
Update shared examples for sorting
Sortable elements might not always be inside a table, so we'll identify them by presence of "data-controller='sortable'" on their parent.
1 parent cbefbcc commit 09a283e

File tree

1 file changed

+7
-6
lines changed
  • admin/lib/solidus_admin/testing_support/shared_examples

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
RSpec.shared_examples_for "features: sortable" do
2323
let(:factory_attrs) { {} }
24+
let(:scope) { "body" }
2425

2526
before do
2627
create(factory, displayed_attribute => "First", position: 1, **factory_attrs)
@@ -29,12 +30,12 @@
2930
end
3031

3132
it "allows sorting via drag and drop" do
32-
row_1 = find_row("First")
33-
row_2 = find_row("Second")
33+
within(scope) do
34+
rows = find("[data-controller='sortable']").all(:xpath, "./*")
35+
rows[1].drag_to rows[0]
3436

35-
row_2.drag_to row_1
36-
37-
expect(find("table tbody tr:first-child")).to have_text("Second")
38-
expect(find("table tbody tr:last-child")).to have_text("First")
37+
expect(find("[data-controller='sortable']").all(:xpath, "./*").first).to have_text("Second")
38+
expect(find("[data-controller='sortable']").all(:xpath, "./*").last).to have_text("First")
39+
end
3940
end
4041
end

0 commit comments

Comments
 (0)