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: Admin budgets Manage groups and headings Create group #2696

Merged

Conversation

javierv
Copy link
Contributor

@javierv javierv commented Jun 23, 2018

References

Objectives

  • Fix the flaky spec in spec/features/admin/budgets_spec.rb:237: "Admin budgets Manage groups and headings Create group"

Explain why the test is flaky, or under which conditions/scenario it fails randomly

To show the form, the JavaScript function App.Forms.toggleLink() calls jQuery's toggle, which animates the way the form appears on the screen.

Sometimes Capybara clicks the button while it's still moving, resulting in no request being sent to the server.

Explain why your PR fixes it

By disabling CSS and jQuery animations in the test environment, the button shows up immediately at the right position, and Capybara always clicks it correctly.

Notes

  • The implementation uses a partial which is only rendered in the test environment. Using a rack middleware (see references), which is also an option the latest Capybara offers as a beta feature, might be another option.
  • These changes also fix a flaky spec in spec/features/admin/homepage/homepage_spec.rb:43 ("Homepage Feeds Debates"), which fails on my machine sometimes with the message: Capybara::ModalNotFound: Unable to find modal dialog (...) Selenium::WebDriver::Error::TimeOutError: timed out after 2 seconds.

Related links

There's a flaky test creating a group for a budget which takes place
because toggling a form using jQuery sometimes results in the button not
being correctly clicked by Capybara.

Checking the page with `expect(page).to have_button 'Create group'`
before clicking the button doesn't solve the problem; it looks like in
those cases Capybara waits for AJAX requests but not for JavaScript
animations.

See also issue consuldemocracy#2573.
@javierv javierv changed the title Don't use jQuery animations in tests. WIP Don't use jQuery animations in tests. Jun 23, 2018
@javierv javierv changed the title WIP Don't use jQuery animations in tests. Don't use jQuery animations in tests (Do not merge). Jun 23, 2018
@javierv javierv changed the title Don't use jQuery animations in tests (Do not merge). Don't use jQuery animations in tests (do not merge). Jun 23, 2018
@javierv javierv changed the title Don't use jQuery animations in tests (do not merge). Fix flaky spec #2573 (do not merge). Jun 23, 2018
@javierv javierv changed the title Fix flaky spec #2573 (do not merge). Fix flaky spec creating groups in budgets Jun 24, 2018
With this name, it's easier to understand what it does.
@javierv javierv changed the title Fix flaky spec creating groups in budgets Fix flaky spec: Admin budgets Manage groups and headings Create group Jul 6, 2018
@javierv javierv changed the title Fix flaky spec: Admin budgets Manage groups and headings Create group Fix flaky spec: Admin budgets Manage groups and headings Create group Jul 6, 2018
@voodoorai2000
Copy link
Member

Great solution and nice refactoring 😌

@voodoorai2000 voodoorai2000 merged commit a3a5971 into consuldemocracy:master Jul 12, 2018
@javierv javierv deleted the 2573-fix_flaky_budgets_spec branch July 12, 2018 15:09
@javierm javierm self-assigned this Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants