From 8ff2bde5c4fbee9bc82aaa362b7246cc55cedcbd Mon Sep 17 00:00:00 2001
From: Katsuya Hidaka <hidakatsuya@gmail.com>
Date: Sat, 10 May 2025 15:30:21 +0900
Subject: Fix random failures in several system tests with Chrome 133 and later

---
 test/system/issues_test.rb    | 11 +++++++++++
 test/system/sudo_mode_test.rb |  3 ++-
 test/system/timelog_test.rb   |  3 +++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/test/system/issues_test.rb b/test/system/issues_test.rb
index 80ef25e0c..c161538e7 100644
--- a/test/system/issues_test.rb
+++ b/test/system/issues_test.rb
@@ -34,6 +34,8 @@ class IssuesSystemTest < ApplicationSystemTestCase
       find('input[name=commit]').click
     end
 
+    assert_text /Issue #\d+ created./
+
     # find created issue
     issue = Issue.find_by_subject("new test issue")
     assert_kind_of Issue, issue
@@ -86,6 +88,7 @@ class IssuesSystemTest < ApplicationSystemTestCase
     fill_in field2.name, :with => 'CF2 value'
     assert_difference 'Issue.count' do
       page.first(:button, 'Create').click
+      assert_text /Issue #\d+ created./
     end
 
     issue = Issue.order('id desc').first
@@ -125,6 +128,7 @@ class IssuesSystemTest < ApplicationSystemTestCase
     end
     assert_difference 'Issue.count' do
       find('input[name=commit]').click
+      assert_text /Issue #\d+ created./
     end
 
     issue = Issue.order('id desc').first
@@ -141,6 +145,7 @@ class IssuesSystemTest < ApplicationSystemTestCase
       attach_file 'attachments[dummy][file]', Rails.root.join('test/fixtures/files/testfile.txt')
       fill_in 'attachments[1][description]', :with => 'Some description'
       click_on 'Create'
+      assert_text /Issue #\d+ created./
     end
     assert_equal 1, issue.attachments.count
     assert_equal 'Some description', issue.attachments.first.description
@@ -163,6 +168,7 @@ class IssuesSystemTest < ApplicationSystemTestCase
       attach_file 'attachments[dummy][file]', Rails.root.join('test/fixtures/files/testfile.txt')
       fill_in 'attachments[1][description]', :with => 'Some description'
       click_on 'Create'
+      assert_text /Issue #\d+ created./
     end
     assert_equal 1, issue.attachments.count
     assert_equal 'Some description', issue.attachments.first.description
@@ -181,6 +187,7 @@ class IssuesSystemTest < ApplicationSystemTestCase
           click_on 'Create'
         end
         click_on 'Create'
+        assert_text /Issue #\d+ created./
       end
     end
 
@@ -200,6 +207,7 @@ class IssuesSystemTest < ApplicationSystemTestCase
     end
     assert_difference 'Issue.count' do
       click_button('Create')
+      assert_text /Issue #\d+ created./
     end
 
     issue = Issue.order('id desc').first
@@ -230,6 +238,7 @@ class IssuesSystemTest < ApplicationSystemTestCase
     fill_in 'Form update CF', :with => 'CF value'
     assert_no_difference 'Issue.count' do
       page.first(:button, 'Submit').click
+      assert_text 'Successful update.'
     end
     assert page.has_css?('#flash_notice')
     issue = Issue.find(1)
@@ -245,6 +254,7 @@ class IssuesSystemTest < ApplicationSystemTestCase
     page.find("#issue_status_id").select("Closed")
     assert_no_difference 'Issue.count' do
       page.first(:button, 'Submit').click
+      assert_text 'Successful update.'
     end
     assert page.has_css?('#flash_notice')
     assert_equal 5, issue.reload.status.id
@@ -267,6 +277,7 @@ class IssuesSystemTest < ApplicationSystemTestCase
 
     click_on 'Submit'
 
+    assert_text 'Successful update.'
     assert_equal 3, Issue.find(2).attachments.count
   end
 
diff --git a/test/system/sudo_mode_test.rb b/test/system/sudo_mode_test.rb
index 73e755acd..307d465ff 100644
--- a/test/system/sudo_mode_test.rb
+++ b/test/system/sudo_mode_test.rb
@@ -48,7 +48,6 @@ class SudoModeSystemTest < ApplicationSystemTestCase
         find('input[name=commit]').click
       end
 
-      assert_equal '/users', current_path
       assert page.has_content?("Confirm your password to continue")
       assert page.has_css?('form#sudo-form')
 
@@ -56,6 +55,8 @@ class SudoModeSystemTest < ApplicationSystemTestCase
         fill_in 'Password', :with => 'admin'
         click_button 'Submit'
       end
+
+      assert_text /User johnpaul created./
     end
   end
 
diff --git a/test/system/timelog_test.rb b/test/system/timelog_test.rb
index 57c521096..38c3ae19c 100644
--- a/test/system/timelog_test.rb
+++ b/test/system/timelog_test.rb
@@ -49,6 +49,8 @@ class TimelogTest < ApplicationSystemTestCase
     select 'QA', :from => 'Activity'
     page.first(:button, 'Submit').click
 
+    assert_text 'Successful update.'
+
     entries = TimeEntry.where(:id => [1, 2, 3]).to_a
     assert entries.all? {|entry| entry.hours == 8.5}
     assert entries.all? {|entry| entry.activity.name == 'QA'}
@@ -89,6 +91,7 @@ class TimelogTest < ApplicationSystemTestCase
     select 'Tracker', :from => 'Available Columns'
     page.first('input[type=button].move-right').click
     click_on 'Save'
+    assert_text 'Successful update.'
 
     # Display the list with updated settings
     visit '/time_entries'
-- 
2.45.2

