Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky spec by waiting for modal animation #3620

Merged
merged 1 commit into from
Mar 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions spec/features/admin/customers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
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'
Expand Down Expand Up @@ -211,6 +212,7 @@
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"
Expand All @@ -235,6 +237,15 @@
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
Expand Down