2024-07-01 10:40:37 +08:00
|
|
|
# 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
|
|
|
|
|
2024-11-20 04:38:13 +08:00
|
|
|
def select_image_with_keyboard(path)
|
|
|
|
label = @element.find("label.btn-default")
|
|
|
|
label.send_keys(:enter)
|
|
|
|
attach_file(path) { label.click }
|
|
|
|
end
|
|
|
|
|
2024-07-04 08:39:22 +08:00
|
|
|
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)
|
2024-07-01 10:40:37 +08:00
|
|
|
end
|
2024-08-14 15:34:34 +08:00
|
|
|
|
|
|
|
def remove_image
|
|
|
|
@element.find(".btn-danger").click
|
|
|
|
end
|
2024-11-20 04:38:13 +08:00
|
|
|
|
|
|
|
def remove_image_with_keyboard
|
|
|
|
delete_button = @element.find(".btn-danger")
|
|
|
|
delete_button.send_keys(:enter)
|
|
|
|
end
|
2024-07-01 10:40:37 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|