0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-12 05:37:26 +08:00
discourse/spec/system/page_objects/components/uppy_image_uploader.rb
David Battersby 45c2a725d0
DEV: remove magnific lightbox (#36375)
Now that we have transitioned lightbox to PhotoSwipe, we can remove the
Magnific library and the `SiteSetting.experimental_lightbox` code paths.

The site setting value will be fully removed from the database in a
follow up migration.

Internal ref - /t/165699
2025-12-03 09:57:53 +04:00

51 lines
1.3 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 close_lightbox_preview
find(".pswp__button--close").click
end
def has_lightbox_preview?
has_css?(".pswp--open")
end
end
end
end