From aef5cebeedff63c243cc0d61b027f635e143fb56 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 19 Mar 2019 09:49:37 +1100 Subject: [PATCH] Fix flaky spec by waiting for modal animation Without waiting, `fill_in` can fail randomly: https://github.com/teamcapybara/capybara/issues/1890 --- spec/features/admin/customers_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/features/admin/customers_spec.rb b/spec/features/admin/customers_spec.rb index 7a2650d93f..da7d9ce942 100644 --- a/spec/features/admin/customers_spec.rb +++ b/spec/features/admin/customers_spec.rb @@ -184,6 +184,7 @@ feature 'Customers' do it 'updates the existing billing address' do expect(page).to have_content 'BILLING ADDRESS' first('#bill-address-link').click + wait_for_modal_fade_in expect(page).to have_content 'Edit Billing Address' expect(page).to have_select2 'country_id', selected: 'Australia' @@ -211,6 +212,7 @@ feature 'Customers' do expect(page).to have_content 'SHIPPING ADDRESS' first('#ship-address-link').click + wait_for_modal_fade_in expect(page).to have_content 'Edit Shipping Address' fill_in 'firstname', with: "First" @@ -235,6 +237,15 @@ feature 'Customers' do expect(ship_address.phone).to eq '12345678' expect(ship_address.city).to eq 'Melbourne' end + + # Modal animations are defined in: + # app/assets/javascripts/admin/utils/services/dialog_defaults.js.coffee + # + # Without waiting, `fill_in` can fail randomly: + # https://github.com/teamcapybara/capybara/issues/1890 + def wait_for_modal_fade_in(time = 0.4) + sleep time + end end describe "creating a new customer" do