Rapid diffs spec fixes

What does this MR do and why?

Fixes failures of this variety:

  1) User comments on a diff when viewing comments when toggling inline comments in multiple files toggles comments
     Failure/Error: super
     Selenium::WebDriver::Error::StaleElementReferenceError:
       stale element reference: stale element not found in the current frame
         (Session info: chrome=151.0.7922.108); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#staleelementreferenceexception
       Screenshot: /tmp/capybara/user_comments_on_a_diff_when_viewing_comments_when_toggling_inline_comments_in_multiple_files_toggles_comments.png
       HTML: /tmp/capybara/user_comments_on_a_diff_when_viewing_comments_when_toggling_inline_comments_in_multiple_files_toggles_comments.html
...
rspec ./spec/features/merge_request/user_comments_on_diff_spec.rb:47 # User comments on a diff when viewing comments when toggling inline comments in multiple files toggles comments

Sample fail-on-retry (hard failure) jobs:

Sample pass-on-retry jobs:

There's been 88 first-attempt failures across 83 pipelines since 2026-09-12, 19 of which failed on retry.

There are two root causes, addressed in each of the first two commits:

  • select_parallel_view / select_inline_view need to wait for a rerender, which is streamed in. wait_for_requests isn't sufficient. Instead we mark the existing diff-files as old, start the view type change, wait for them to vanish, and wait for the new testid to appear. We just do the testid wait, per !256064 (comment 3855249163).
  • diff_file needs to return a reloadable element. Right now we're getting stale elements from the find(...).ancestor('diff-file'); the finded (found?) element is stale, and ancestor complains. Rewriting it as just one find fixes it; the returned element reloads itself when stale.

The third commit drops some now-unnecessary wait_for_requests.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Asherah Connor

Merge request reports

Loading
Loading