This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/spec/system/page_objects/components/composer.rb
Alan Guo Xiang Tan b0407e6b9f
DEV: Port sidebar mobile view acceptance tests to system tests
The acceptance tests are flaky so I've decided to port them to system
test which makes them easier to work with and reason about.
2023-02-23 12:29:47 +08:00

63 lines
1.3 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Components
class Composer < PageObjects::Components::Base
COMPOSER_ID = "#reply-control"
def opened?
page.has_css?("#{COMPOSER_ID}.open")
end
def open_composer_actions
find(".composer-action-title .btn").click
self
end
def fill_title(title)
find("#{COMPOSER_ID} #reply-title").fill_in(with: title)
self
end
def fill_content(content)
composer_input.fill_in(with: content)
self
end
def type_content(content)
composer_input.send_keys(content)
self
end
def clear_content
fill_content("")
end
def has_content?(content)
composer_input.value == content
end
def select_action(action)
find(action(action)).click
self
end
def create
find("#{COMPOSER_ID} .btn-primary").click
end
def action(action_title)
".composer-action-title .select-kit-collection li[title='#{action_title}']"
end
def button_label
find("#{COMPOSER_ID} .btn-primary .d-button-label")
end
def composer_input
find("#{COMPOSER_ID} .d-editor .d-editor-input")
end
end
end
end