Skip to content

Commit

Permalink
try adding timeout retry & longer waits
Browse files Browse the repository at this point in the history
  • Loading branch information
krschacht committed Dec 4, 2024
1 parent 9a3d73d commit 285a80b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,5 @@ group :test do
gem "selenium-webdriver"
gem "minitest-stub_any_instance"
gem "rails-controller-testing"
gem "minitest-retry"
end
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 3 additions & 10 deletions test/system/conversations/messages/images_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
7 changes: 7 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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

Expand Down

0 comments on commit 285a80b

Please sign in to comment.