diff --git a/Gemfile b/Gemfile index bb9da988..f17e990c 100644 --- a/Gemfile +++ b/Gemfile @@ -87,4 +87,5 @@ group :test do gem "selenium-webdriver" gem "minitest-stub_any_instance" gem "rails-controller-testing" + gem "minitest-retry" end diff --git a/Gemfile.lock b/Gemfile.lock index 7a9280e7..9c8e880c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -202,6 +202,8 @@ GEM mini_magick (4.13.2) mini_mime (1.1.5) minitest (5.25.1) + minitest-retry (0.2.3) + minitest (>= 5.0) minitest-stub_any_instance (1.0.3) mize (0.4.1) protocol (~> 2.0) @@ -493,6 +495,7 @@ DEPENDENCIES gemini-ai (~> 4.2.0) image_processing (~> 1.13.0) importmap-rails + minitest-retry minitest-stub_any_instance name_of_person omniauth (~> 2.1) diff --git a/test/system/conversations/messages/images_test.rb b/test/system/conversations/messages/images_test.rb index 3e96155d..af3f07d1 100644 --- a/test/system/conversations/messages/images_test.rb +++ b/test/system/conversations/messages/images_test.rb @@ -90,28 +90,21 @@ class ConversationMessagesImagesTest < ApplicationSystemTestCase visit_and_scroll_wait conversation_messages_path(@conversation) image_msg = find_messages.third - image_btn = image_msg.find_role("image-preview") + image_btn = image_msg.find_role("image-preview") loader = image_btn.find_role("image-loader") img = image_btn.find("img", visible: :all) modal_container = image_msg.find_role("image-modal") modal_loader = modal_container.find_role("image-loader") modal_img = modal_container.find("img", visible: :all) - assert_true "image loader should be visible", wait: 0.6 do + assert_true "image loader should be visible", wait: 3 do loader.visible? end refute img.visible? image_btn.click - 2.times do - sleep 0.1 - sleep 0.5 if !modal_loader.visible? - sleep 0.1 - image_btn.click if !modal_loader.visible? - end # TODO: sometimes modal has not popped up after clicking, why?? Try 2x times before failing the test. - - assert_true "modal image loader should be visible", wait: 0.6 do + assert_true "modal image loader should be visible", wait: 3 do modal_loader.visible? end refute modal_img.visible? diff --git a/test/test_helper.rb b/test/test_helper.rb index 5c9d5066..ad1acbf7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,6 +2,7 @@ require_relative "../config/environment" require "rails/test_help" require "minitest/autorun" +require "minitest/retry" require "pry" Dir[Rails.root.join("test/support/**/*.rb")].sort.each { |file| require file } @@ -20,6 +21,12 @@ def exists? end end +Minitest::Retry.use!( + retry_count: 3, + verbose: true, + exceptions_to_retry: [Net::ReadTimeout] +) + class ActionDispatch::IntegrationTest include Rails.application.routes.url_helpers