Fix Flaky spec: Moderate debates Hide #2542
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 usinghave_css(...)
, I usedfind(...)
, 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.