fix: stabilise flaky TomSelect test helper#2648
Merged
Merged
Conversation
The SelectFromTomSelect helper had two issues causing flaky failures in CI: 1. ensure_tom_select_initialized hardcoded 'meeting_organisers' as the element ID, but this helper is also used with 'meeting_invitations_member'. Initializing the wrong element created a race condition. 2. wait: 5 for .ts-dropdown .option was too short for CI environments where the AJAX search request to /admin/members/search can be slow. Removed the fragile manual initialization workaround entirely - the real initialization via application.js + CDN script runs reliably. Increased timeouts for CI resilience.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes a flaky test in
Managing meeting invitationsthat intermittently failed in CI with:Root cause
The
SelectFromTomSelecttest helper had two issues:ensure_tom_select_initializedhardcodedmeeting_organisersas the element ID to manually initialize. This helper is called from pages usingmeeting_invitations_member(meeting invitations) andmeeting_organisers(meeting edit form). When called with the wrong ID, the manual init targeted a non-existent element, creating a race condition with the real init code.wait: 5for.ts-dropdown .optionwas too short for CI environments where the TomSelect AJAX search (/admin/members/search) can take longer than 5 seconds to respond.Changes
Removed
ensure_tom_select_initialized— This was a fragile workaround that tried to manually re-initialize TomSelect if the real init hadn't run yet. The real init (jQuery handler inapplication.jsrunning after CDN script loads) is reliable when given enough time. Manual init with a hardcoded element ID only made things worse.Increased timeout for
.ts-dropdown .optionfrom 5s to 10s — Gives CI more time for the AJAX search round-trip.Increased
.ts-wrapperwait from 10s to 15s — Extra margin for the CDN script to load and TomSelect to initialize in slow CI environments.Same cleanup applied to
remove_from_tom_selectfor consistency.Test Plan
bundle exec rspec— 1023 examples, 0 failuresmanaging_meeting_invitations_spec.rbpasses 5/5 consecutive runs locallymeeting_spec.rbpasses (also usesselect_from_tom_select)