discourse/spec/system/page_objects/components/uppy_image_uploader.rb
chapoi f4d4f371e6
UX: fix border-radius on image upload inputs (#32935)
Noticed problems on themes that use border-radius (like Horizon), where
these get the button radius applied, which is too large since, despite
**functioning** like a button, they are essentially inputs and lean more
toward the input styling. Also removed `btn-default` as this element
couldn't be further from a default button if it tried.

| Before | After |
|--------|--------|
| ![CleanShot 2025-05-27 at 11 43
42@2x](https://github.com/user-attachments/assets/fa0aa793-e812-40ed-b142-f47158e2d01b)
| ![CleanShot 2025-05-27 at 11 42
01@2x](https://github.com/user-attachments/assets/bba289e7-3707-4725-925e-a993fec32da8)
|

---------

Co-authored-by: Ella <ella.estigoy@gmail.com>
2025-05-28 08:58:21 +02:00

47 lines
1.2 KiB
Ruby
Vendored

# 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").click }
end
def select_image_with_keyboard(path)
label = @element.find("label.btn")
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
@element.has_no_css?(".btn-danger")
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