Skip to content

Commit

Permalink
Fix flaky spec using Capybara::Node#synchronize
Browse files Browse the repository at this point in the history
This will keep clicking the Filter button until the promotions menu
appears. The problem this fixes is that a few milliseconds after
navigation, the JS controller that switches the filter bar out might not
have loaded.

Alternative fixes here:
solidusio#5782
solidusio#5783
  • Loading branch information
mamhoff committed Jun 12, 2024
1 parent 592fdb3 commit 64f2f16
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@
it "lists products", :js do
visit "/admin/orders"

click_button "Filter"
# Keep on clicking until the Promotions menu appears
page.document.synchronize do
click_button "Filter"

within("div[role=search]") do
expect(page).to have_content("Promotions")
end
end

within("div[role=search]") do
expect(page).to have_content("Promotions")
find(:xpath, "//summary[normalize-space(text())='Promotions']").click
end
check "10OFF"
Expand Down

0 comments on commit 64f2f16

Please sign in to comment.