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: Moderate debates Hide #2542

Conversation

iagirre
Copy link

@iagirre iagirre commented Mar 21, 2018

References

Objectives

There was a flaky in the file spec/features/moderation/debates_spec.rb when hidding debates. The problem was a race condition that appeared after clicking the 'Hide' button.
This button hides a debate, and in the UI it fades using JS. If the test was fast enought and the expect assertion executes before the CSS class changes, Capybara won't find any id that matches #debates_#{debate.id}.faded; there is a div with id #debate_5, but it's not faded yet.

To make Capybara wait the stablished wait_time (capybara's max_wait_time, by default 2 secs), I changed the assertion. Instead of using have_css(...), I used find(...), that, according to this, waits for the element to appear in the screen.
So, it expects to find and object and then checks if that object has a text (the debate title in this case)

Visual Changes

There aren't, it's a flaky.

Notes

Nothing to mention.

The old method have_css didn't wait, apparently,
the Capybara's max_wait_time.
It has been changed in favor of find,
one that waits the stablished time for
an element to appear in the screen.
@bertocq bertocq changed the title Flaky spec: Moderate debates Hide Fix Flaky spec: Moderate debates Hide Mar 21, 2018
@bertocq
Copy link
Collaborator

bertocq commented Mar 21, 2018

Great @iagirre !

@bertocq bertocq merged commit 8f2c357 into consuldemocracy:master Mar 21, 2018
@aitbw aitbw deleted the backport-flaky-moderates-debates-hide branch April 5, 2018 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants