Skip to content

Conversation

@mroderick
Copy link
Collaborator

Summary

  • Fixes two failing feature tests that were timing-dependent when interacting with Chosen.js dropdowns
  • Rewrites the select_from_chosen test helper to be more reliable
  • All 777 tests now pass consistently

Problem

Two feature tests were failing locally due to race conditions when interacting with Chosen.js select dropdowns:

  1. spec/features/member_feedback_spec.rb:60 - Submitting feedback
  2. spec/features/admin/manage_workshop_attendances_spec.rb:44 - RSVPing members

The original select_from_chosen helper tried to click the Chosen UI and type text, which was unreliable because:

  • Dropdown animations might not be complete
  • Elements could be intercepted by other elements
  • Timing varied between local and CI environments

Solution

Rewrote select_from_chosen helper to:

  • Find the hidden select element and option by text
  • Set the value directly via JavaScript
  • Trigger Chosen's update events
  • Verify the selection was applied

This approach:

  • Bypasses UI timing issues entirely
  • Is faster and more reliable
  • Follows testing best practices for JS-enhanced form elements

Additional improvements:

  • Increased Capybara.default_max_wait_time to 5 seconds for better JS test stability
  • Added explicit waits for Chosen initialization in tests
  • Used the helper consistently across all Chosen dropdown interactions

Test Results

Finished in 2 minutes 46.7 seconds
777 examples, 0 failures

All tests pass with the same seed (63863) that previously caused failures.

Test plan

  • Run full test suite locally: bundle exec rspec
  • Run with specific seed that previously failed: bundle exec rspec --seed 63863
  • Run failing tests individually to verify fixes
  • Verify no regressions in other tests

Resolves issues with two failing feature tests that were timing-dependent
when interacting with Chosen.js select dropdowns.

Changes:
- Rewrote select_from_chosen helper to use JavaScript instead of simulating clicks
- Increased Capybara.default_max_wait_time to 5 seconds for JS tests
- Added explicit waits for Chosen dropdown initialization
- Used select_from_chosen helper consistently across tests

The new approach directly sets select values via JavaScript and triggers
Chosen's update events, avoiding race conditions from clicking and typing
into the animated dropdown UI.

All 777 tests now pass consistently with seed 63863.
@mroderick mroderick added the tests label Feb 1, 2026
@olleolleolle olleolleolle merged commit 6add0bd into codebar:master Feb 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants