Skip to content

Fix flaky add-all-chapters feature spec - #2863

Merged
mroderick merged 1 commit into
masterfrom
fix/add-all-chapters-flake
Sep 9, 2026
Merged

Fix flaky add-all-chapters feature spec#2863
mroderick merged 1 commit into
masterfrom
fix/add-all-chapters-flake

Conversation

@mroderick

Copy link
Copy Markdown
Collaborator

Summary

Fixes a flaky JavaScript feature spec. spec/features/admin/manage_event_spec.rb ("adding all chapters to an event with one click") asserted that the Chosen dropdown closes after clicking "Add to all". That assertion races with Chosen's focus handling and failed in CI (run 34354614220, Group 5), then passed on re-run of the identical commit.

The re-open comes from Chosen's own input_focus handler: for multiple selects it schedules container_mousedown() 50ms after a focus event on the search field while the dropdown is inactive. That re-opens the dropdown after the add-all click handler's chosen:close, and nothing closes it again. All chapters were already selected at that point, and the Save button sits below the dropdown, so the close assertion guarded nothing the scenario depends on.

  • Replace the negative have_no_css dropdown-closed assertion with a positive one: all chapters render as selected choices
  • Selection outcome stays covered; Save and flash assertions unchanged
Failure from CI
1) Managing events adding all chapters to an event with one click
   Failure/Error: expect(page).to have_no_css('#event_chapter_ids_chosen.chosen-with-drop')
     expected not to find visible css "#event_chapter_ids_chosen.chosen-with-drop",
     found 1 match: "iste9\net10\nlibero11\nconsequatur12\nAdd to all\niste9\n..."
   # ./spec/features/admin/manage_event_spec.rb:28

Note the found match shows all four chapters already selected while the dropdown was open.

The spec asserted the Chosen dropdown closed after clicking "Add to
all". Chosen's input_focus handler schedules container_mousedown 50ms
after a focus event on the search field while the dropdown is inactive,
which re-opens the dropdown after the spec's chosen:close. In CI this
left the dropdown open past the 5s Capybara wait and the negative CSS
assertion failed (run 34354614220, Group 5). The dropdown re-opened
with all chapters already selected, and the Save button sits below the
dropdown, so the assertion was not needed for the interaction.

Replace it with a positive assertion that all chapters render as
selected choices, which is the outcome the scenario tests.
@mroderick
mroderick marked this pull request as ready for review September 9, 2026 14:48
@mroderick
mroderick merged commit 002c76e into master Sep 9, 2026
10 checks passed
@mroderick
mroderick deleted the fix/add-all-chapters-flake branch September 9, 2026 18:16
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.

2 participants