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

Flaky spec: Ballots Groups Change my heading #3451

Closed
javierm opened this issue Apr 23, 2019 · 0 comments · Fixed by #3460
Closed

Flaky spec: Ballots Groups Change my heading #3451

javierm opened this issue Apr 23, 2019 · 0 comments · Fixed by #3460

Comments

@javierm
Copy link
Member

javierm commented Apr 23, 2019

Failure

Travis failed builds: Travis build 28983, job 2, Madrid's build 11441, job 9
and forked repo build 20, job 1
Messages:

Failures:
1) Ballots Groups Change my heading
     Failure/Error: investments.where(group: group).first.heading
     NoMethodError:
       undefined method `heading' for nil:NilClass
     # ./app/models/budget/ballot.rb:71:in `heading_for_group'
     # ./app/controllers/budgets/investments_controller.rb:158:in `load_assigned_heading'
     # ./app/controllers/budgets/investments_controller.rb:147:in `load_heading'
     # ------------------
     # --- Caused by: ---
     # Capybara::ElementNotFound:
     #   Unable to find visible css "#budget_investment_10"
     #   ./spec/support/common_actions/budgets.rb:8:in `add_to_ballot'

Another message:

 1) Ballots Groups Change my heading
     Failure/Error: expect(page).to have_content "Remove"
     Selenium::WebDriver::Error::StaleElementReferenceError:
       stale element reference: element is not attached to the page document
         (Session info: headless chrome=71.0.3578.80)
         (Driver info: chromedriver=2.36.540471 (9c759b81a907e70363c6312294d30b6ccccc2752),platform=Linux 4.4.0-101-generic x86_64)
     # ./spec/support/common_actions/budgets.rb:10:in `block in add_to_ballot'
     # ./spec/support/common_actions/budgets.rb:8:in `add_to_ballot'
     # ./spec/features/budgets/ballots_spec.rb:282:in `block (3 levels) in <top (required)>'

Cause

The code:

      within("#budget_investment_#{investment1.id}") do
        find(".remove a").click
      end

      visit budget_investments_path(budget, heading_id: new_york.id)

Generates a "normal" request after an AJAX request. A possible reason why the tests fails is we don't check the AJAX request has finished before visiting the new page, and so both requests enter a race condition.

Note this test only fails after upgrading to Rails 5, probably due to a different behaviour in AJAX calls during tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant