mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 13:08:40 +08:00
Also, fix quoting logic so when a draft is closed it will be reloaded prior to adding quote. --------- Co-authored-by: Martin Brennan <martin@discourse.org>
145 lines
3.2 KiB
Ruby
Vendored
145 lines
3.2 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Components
|
|
class PhotoSwipe < PageObjects::Components::Base
|
|
attr_reader :component
|
|
|
|
SELECTOR = ".pswp"
|
|
CLOSE_BTN = ".pswp__button--close"
|
|
ZOOM_BTN = ".pswp__button--zoom"
|
|
NEXT_BTN = ".pswp__button--arrow--next"
|
|
PREV_BTN = ".pswp__button--arrow--prev"
|
|
DOWNLOAD_BTN = ".pswp__button--download-image"
|
|
ORIGINAL_IMAGE_BTN = ".pswp__button--original-image"
|
|
IMAGE_INFO_BTN = ".pswp__button--image-info"
|
|
QUOTE_BTN = ".pswp__button--quote-image"
|
|
COUNTER = ".pswp__custom-counter"
|
|
CAPTION = ".pswp__caption"
|
|
CAPTION_TITLE = ".pswp__caption-title"
|
|
CAPTION_DETAILS = ".pswp__caption-details"
|
|
UI_VISIBLE = ".pswp--ui-visible"
|
|
ACTIVE_IMG = ".pswp__item[aria-hidden='false'] .pswp__img"
|
|
|
|
def initialize
|
|
@component = find(SELECTOR)
|
|
end
|
|
|
|
def visible?
|
|
page.has_css?(SELECTOR)
|
|
end
|
|
|
|
def hidden?
|
|
page.has_no_css?(SELECTOR)
|
|
end
|
|
|
|
def next_button
|
|
component.find(NEXT_BTN)
|
|
end
|
|
|
|
def prev_button
|
|
component.find(PREV_BTN)
|
|
end
|
|
|
|
def image_info_button
|
|
component.find(IMAGE_INFO_BTN)
|
|
end
|
|
|
|
def quote_button
|
|
component.find(QUOTE_BTN)
|
|
end
|
|
|
|
def close_button
|
|
component.find(CLOSE_BTN)
|
|
end
|
|
|
|
def counter
|
|
component.find(COUNTER)
|
|
end
|
|
|
|
def has_counter?(text)
|
|
component.has_css?(COUNTER, text: text)
|
|
end
|
|
|
|
def has_no_counter?
|
|
component.has_no_css?(COUNTER)
|
|
end
|
|
|
|
def has_caption_title?(caption)
|
|
component.has_css?(CAPTION_TITLE, text: caption)
|
|
end
|
|
|
|
def has_caption_details?(details)
|
|
component.has_css?(CAPTION_DETAILS, text: details)
|
|
end
|
|
|
|
def has_no_caption?
|
|
component.has_no_css?(CAPTION)
|
|
end
|
|
|
|
def has_no_caption_details?
|
|
component.has_no_css?(CAPTION_DETAILS)
|
|
end
|
|
|
|
def has_next_button?
|
|
component.has_css?(NEXT_BTN)
|
|
end
|
|
|
|
def has_no_next_button?
|
|
component.has_no_css?(NEXT_BTN)
|
|
end
|
|
|
|
def has_prev_button?
|
|
component.has_css?(PREV_BTN)
|
|
end
|
|
|
|
def has_no_prev_button?
|
|
component.has_no_css?(PREV_BTN)
|
|
end
|
|
|
|
def has_download_button?
|
|
component.has_css?(DOWNLOAD_BTN)
|
|
end
|
|
|
|
def has_no_download_button?
|
|
component.has_no_css?(DOWNLOAD_BTN)
|
|
end
|
|
|
|
def has_original_image_button?
|
|
component.has_css?(ORIGINAL_IMAGE_BTN)
|
|
end
|
|
|
|
def has_no_original_image_button?
|
|
component.has_no_css?(ORIGINAL_IMAGE_BTN)
|
|
end
|
|
|
|
def has_image_info_button?
|
|
component.has_css?(IMAGE_INFO_BTN)
|
|
end
|
|
|
|
def has_no_image_info_button?
|
|
component.has_no_css?(IMAGE_INFO_BTN)
|
|
end
|
|
|
|
def has_quote_button?
|
|
component.has_css?(QUOTE_BTN)
|
|
end
|
|
|
|
def has_no_quote_button?
|
|
component.has_no_css?(QUOTE_BTN)
|
|
end
|
|
|
|
def has_ui_visible?
|
|
page.has_css?(UI_VISIBLE)
|
|
end
|
|
|
|
def has_no_ui_visible?
|
|
page.has_no_css?(UI_VISIBLE)
|
|
end
|
|
|
|
def has_image_source?(upload)
|
|
component.has_css?(ACTIVE_IMG + "[src$='#{upload.url}']")
|
|
end
|
|
end
|
|
end
|
|
end
|