diff --git a/spec/support/double_click_helper.rb b/spec/support/double_click_helper.rb index 725964ba27..e409b3a6a4 100644 --- a/spec/support/double_click_helper.rb +++ b/spec/support/double_click_helper.rb @@ -17,13 +17,5 @@ # # # Assert something based on the double click. def ferrum_double_click(css_selector) - node = Capybara.page.driver.browser.at_css(css_selector) - x, y = node.find_position - mouse = node.page.mouse - mouse.move(x:, y:) - mouse.down - mouse.up - sleep(0.05) - mouse.down - mouse.up + Capybara.page.driver.browser.at_css(css_selector).click(mode: :double, delay: 0.05) end diff --git a/spec/system/distribution_system_spec.rb b/spec/system/distribution_system_spec.rb index a1371f0d1d..f8fcf5050e 100644 --- a/spec/system/distribution_system_spec.rb +++ b/spec/system/distribution_system_spec.rb @@ -915,17 +915,16 @@ click_button "Yes, it's correct" end + expect(page).to have_content("Distribution created!") + # Make sure the button is there before trying to double click it - expect(page.find('form[action*="/picked_up"] .btn.btn-success.btn-md')).to have_content("Distribution Complete") + expect(page).to have_button("Distribution Complete", visible: true) - # Double click on the Distribution complete button - ferrum_double_click('form[action*="/picked_up"] .btn.btn-success.btn-md') + # Double click on the Distribution Complete button + ferrum_double_click("form[action='#{distribution_path(id: organization.distributions.last.id)}/picked_up']") - # Capybara will be quick to determine that a screen doesn't have content. - # Make some positive assertions that only appears on the new screen to make - # sure it's loaded before asserting something isn't there. - expect(page).not_to have_content("Distribution Complete") - expect(page).to have_content("Complete") + expect(page).to have_content("This distribution has been marked as being completed!") + expect(page).not_to have_button("Distribution Complete") # If it tries to mark the distribution as completed twice, the second time # will fail (the distribution is already complete) and show this error