From 64f2f1669b5a28a453b7a24675abaa5c5a56ca66 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Wed, 12 Jun 2024 09:29:03 +0200 Subject: [PATCH] Fix flaky spec using Capybara::Node#synchronize 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: https://github.com/solidusio/solidus/pull/5782 https://github.com/solidusio/solidus/pull/5783 --- .../spec/features/solidus_admin/orders/index_spec.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/legacy_promotions/spec/features/solidus_admin/orders/index_spec.rb b/legacy_promotions/spec/features/solidus_admin/orders/index_spec.rb index 3dec15fffc..75ac5399d4 100644 --- a/legacy_promotions/spec/features/solidus_admin/orders/index_spec.rb +++ b/legacy_promotions/spec/features/solidus_admin/orders/index_spec.rb @@ -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"