Project

General

Profile

Actions

Patch #42244

closed

Fix random failures in IssuesTest#test_bulk_copy due to StaleElementReferenceError

Added by Katsuya HIDAKA 13 days ago. Updated 10 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

This patch addresses the issue where IssuesTest#test_bulk_copy fails randomly.

Error:
IssuesSystemTest#test_bulk_copy:
Selenium::WebDriver::Error::StaleElementReferenceError: stale element reference: stale element not found in the current frame
  (Session info: chrome=132.0.6834.159); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#stale-element-reference-exception
    test/system/issues_test.rb:510:in `block in test_bulk_copy'
    test/system/issues_test.rb:509:in `test_bulk_copy'

bin/rails test test/system/issues_test.rb:460

https://github.com/hidakatsuya/redmine/actions/runs/13212281635/job/36887301512

This StaleElementReferenceError is caused by the interference of DOM rewriting due to project change in page.find('#issue_project_id').select('OnlineStore').

  def test_bulk_copy
    # ...
    page.find('#issue_project_id').select('OnlineStore')
    # wait for ajax response
    assert page.has_select?('issue_project_id', selected: 'OnlineStore')
    # ...
    assert_difference 'Issue.count', 2 do
      submit_buttons[1].click
      # ...
  end

The existing implementation to wait for the project change assert page.has_select?('issue_project_id', selected: 'OnlineStore') is not working properly, so we will fix it as follows:

diff --git a/test/system/issues_test.rb b/test/system/issues_test.rb
index c23cbd27c..80ef25e0c 100644
--- a/test/system/issues_test.rb
+++ b/test/system/issues_test.rb
@@ -497,8 +497,9 @@ class IssuesSystemTest < ApplicationSystemTestCase
     assert_equal 'Copy', submit_buttons[0].value

     page.find('#issue_project_id').select('OnlineStore')
-    # wait for ajax response
-    assert page.has_select?('issue_project_id', selected: 'OnlineStore')
+    # Verify that the target version field has been rewritten by the OnlineStore project settings
+    # and wait for the project change to complete.
+    assert_select 'issue_fixed_version_id', options: ['(No change)', 'none', 'Alpha', 'Systemwide visible version']

     assert_selector 'input[type=submit]', count: 2
     submit_buttons = page.all('input[type=submit]')

Files

Actions

Also available in: Atom PDF