Fix flaky Capybara tests with Chosen.js dropdowns #2453
Merged
+20
−10
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.
Summary
select_from_chosentest helper to be more reliableProblem
Two feature tests were failing locally due to race conditions when interacting with Chosen.js select dropdowns:
spec/features/member_feedback_spec.rb:60- Submitting feedbackspec/features/admin/manage_workshop_attendances_spec.rb:44- RSVPing membersThe original
select_from_chosenhelper tried to click the Chosen UI and type text, which was unreliable because:Solution
Rewrote
select_from_chosenhelper to:This approach:
Additional improvements:
Capybara.default_max_wait_timeto 5 seconds for better JS test stabilityTest Results
All tests pass with the same seed (63863) that previously caused failures.
Test plan
bundle exec rspecbundle exec rspec --seed 63863