Files
discourse/spec/system/page_objects/components/uppy_image_uploader.rb
Krzysztof Kotlarek 429a10b2b9 FIX: uploader lightbox preview for new images (#31762)
It is an old bug that preview is not working for newly uploaded images.
To fix it, we need to initialize lightbox when image is rendered and not
when component.

We have Qunit test when image is already available
https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/tests/integration/components/uppy-image-uploader-test.gjs#L28

System test was added to ensure lightbox is working right after image is
uploaded.

<img width="1236" alt="Screenshot 2025-03-12 at 10 23 18 am"
src="https://github.com/user-attachments/assets/3984306b-f351-4b35-936c-eb7f0e57ea9d"
/>

After fix


https://github.com/user-attachments/assets/1091cd55-b24b-4640-8e8f-a60c3426ff65
2025-03-18 10:01:55 +11:00

47 lines
1.2 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Components
class UppyImageUploader < PageObjects::Components::Base
def initialize(element)
@element = element
end
def select_image(path)
attach_file(path) { @element.find("label.btn-default").click }
end
def select_image_with_keyboard(path)
label = @element.find("label.btn-default")
label.send_keys(:enter)
attach_file(path) { label.click }
end
def has_uploaded_image?
# if there's a delete button (.btn-danger), then there must be an
# uploaded image.
# allow up to 10 seconds for the upload to finish in case this is
# called immediately after selecting an image.
@element.has_css?(".btn-danger", wait: 10)
end
def remove_image
@element.find(".btn-danger").click
end
def remove_image_with_keyboard
delete_button = @element.find(".btn-danger")
delete_button.send_keys(:enter)
end
def toggle_lightbox_preview
@element.find(".image-uploader-lightbox-btn").click
end
def has_lighbox_preview?
has_css?(".mfp-container")
end
end
end
end