Fix flakiness in user_suggests_changes_on_diff_spec
What does this MR do and why?
spec/features/merge_request/user_suggests_changes_on_diff_spec.rb is the top flaky-test offender for ~"group::code review" over the last 30 days (flaky tests dashboard), with three examples quarantined in #601810.
Root cause
All three quarantined examples shared the same race in the Apply suggestion flow. The spec clicked the Apply suggestion dropdown toggle and then immediately clicked Apply — but Apply lives inside the disclosure dropdown panel (apply_suggestion.vue), which renders asynchronously after the toggle. When the second click landed before the panel mounted, the test failed.
What this MR changes
- Fixes the race (root cause): introduces an
apply_suggestionhelper that clicks the toggle, waits for the commit-message field to confirm the dropdown is open, then clicksApply. All five apply call sites now use it. - Hardens other flaky patterns flagged by the testing guidelines:
- Replaces
all(...).first.click/all[idx]with a waitinghave_css(..., count:)matcher before indexing. - Replaces
find('.js-...').clickwith semanticfind_by_testidfinders. - Routes the reply-field value assertion through a waiting finder.
- Replaces
- Removes the
quarantinetags from the three previously-flaky examples so they run in CI again.
Test plan
Verified locally — the full file passes, including the three formerly-quarantined examples (quarantined tests run locally since !ENV['CI']):
12 examples, 0 failuresRun twice to check for residual flakiness; both green. RuboCop and commit-message lint clean.
How to set up and validate locally
bundle exec rspec spec/features/merge_request/user_suggests_changes_on_diff_spec.rbMR acceptance checklist
- I have evaluated the MR acceptance checklist for this MR.