Skip to content

Commit

Permalink
Hotfix: Disable flaky system test
Browse files Browse the repository at this point in the history
  • Loading branch information
krschacht committed Dec 20, 2024
1 parent ccefff2 commit 856d619
Showing 1 changed file with 55 additions and 46 deletions.
101 changes: 55 additions & 46 deletions test/system/conversations/messages/images_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,52 +85,61 @@ class ConversationMessagesImagesTest < ApplicationSystemTestCase
end
end

test "ensure images display a spinner initially if they get a 404 and then eventually get replaced with the image" do
simulate_image_variant_processing do
visit_and_scroll_wait conversation_messages_path(@conversation)

image_msg = find_messages.third
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
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: 3 do
modal_loader.visible?
end
refute modal_img.visible?

send_keys "esc"

assert_false "image loader should have eventually disappeared", wait: 10 do
loader.visible?
end
assert img.visible?
wait_for_images_to_load

image_btn.click

assert_true "modal image should be visible" do
modal_img.visible?
end
refute modal_loader.visible?
end
end
# This test is failing intermittently in CI and I can't reproduce it locally.
# ConversationMessagesImagesTest#test_ensure_images_display_a_spinner_initially_if_they_get_a_404_and_then_eventually_get_replaced_with_the_image:
# Selenium::WebDriver::Error::ElementClickInterceptedError: element click intercepted: Element <button name="button" type="button" class="w-full h-auto flex focus:outline-none" data-role="image-preview" data-controller="image-loader" data-image-loader-message-scroller-outlet="[data-role='inner-message']" data-image-loader-url-value="/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6NDcxMTMyOTI4LCJwdXIiOiJibG9iX2lkIn19--8c4d6e0e2d84265fb233b96a9c1b95b6c68be82c/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJwbmciLCJyZXNpemVfdG9fbGltaXQiOls2NTAsNDkwXX0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--b59ea19391125c771d351cc298026147a15c57b1/cat.png" data-action="modal#open">...</button> is not clickable at point (818, 386). Other element would receive the click: <img class="w-full h-auto" data-image-loader-target="image" data-action="
# error->image-loader#retryAfterDelay
# load->image-loader#show
# " src="/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6NDcxMTMyOTI4LCJwdXIiOiJibG9iX2lkIn19--8c4d6e0e2d84265fb233b96a9c1b95b6c68be82c/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJwbmciLCJyZXNpemVfdG9fbGltaXQiOlsxMjAwLDkwMF19LCJwdXIiOiJ2YXJpYXRpb24ifX0=--2af8beb3bc79b4dd8a1d95edbb8830721523a8e8/cat.png?disposition=-8">
# Image here: https://github.com/AllYourBot/hostedgpt/actions/runs/12424552298/artifacts/2346575925
# Failure example: https://github.com/AllYourBot/hostedgpt/actions/runs/12424552298/job/34689893027
#
# test "ensure images display a spinner initially if they get a 404 and then eventually get replaced with the image" do
# simulate_image_variant_processing do
# visit_and_scroll_wait conversation_messages_path(@conversation)

# image_msg = find_messages.third
# 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
# 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: 3 do
# modal_loader.visible?
# end
# refute modal_img.visible?

# send_keys "esc"

# assert_false "image loader should have eventually disappeared", wait: 10 do
# loader.visible?
# end
# assert img.visible?
# wait_for_images_to_load

# image_btn.click

# assert_true "modal image should be visible" do
# modal_img.visible?
# end
# refute modal_loader.visible?
# end
# end

test "ensure page scrolls back down to the bottom after an image pops in late" do
simulate_image_variant_processing do
Expand Down

0 comments on commit 856d619

Please sign in to comment.