Skip to content

Commit

Permalink
Ensure flaky test passes consistently (#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
bess authored Mar 28, 2024
1 parent 77d8ed4 commit c0a507b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 6 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require "rspec/rails"
# Add additional requires below this line. Rails is not loaded until this point!
require "axe-rspec"
require "capybara/rspec"
require "devise"
require "webmock/rspec"
WebMock.disable_net_connect!(allow_localhost: true,
Expand Down Expand Up @@ -37,6 +38,11 @@
rescue ActiveRecord::PendingMigrationError => e
abort e.to_s.strip
end

# Disable animations in system tests.
# This should make them faster and more reliable.
Capybara.disable_animation = true

RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
Expand Down
11 changes: 4 additions & 7 deletions spec/system/project_roles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,14 @@
click_on "btn-add-rw-user"
expect(page.find("#rw-user-uid-to-add").native.attribute("validationMessage")).to eq ""

page.find("#departments").find(:xpath, "option[3]").select_option

fill_in "directory", with: "test_project"
fill_in "title", with: "My test project"
expect(page).to have_content("Project Directory: /td-test-001/")
expect(page.find_all("input:invalid").count).to eq(0)
expect do
expect(page.find_all("input:invalid").count).to eq(0)
click_on "Submit"
# For some reason the above click on submit sometimes does not submit the form
# even though the inputs are all valid, so try it again...
if page.find_all("#btn-add-rw-user").count > 0
click_on "Submit"
end
click_button("Submit")
end.to have_enqueued_job(ActionMailer::MailDeliveryJob).exactly(1).times
expect(page).to have_content "New Project Request Received"
click_on "Return to Dashboard"
Expand Down

0 comments on commit c0a507b

Please sign in to comment.