diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 1602496b367..da6d184dedd 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -75,8 +75,7 @@ end # in spec/support/ and its subdirectories. Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } -require Rails.root.join("spec/system/page_objects/pages/base.rb") -require Rails.root.join("spec/system/page_objects/modals/base.rb") +Dir[Rails.root.join("spec/system/page_objects/**/base.rb")].each { |f| require f } Dir[Rails.root.join("spec/system/page_objects/**/*.rb")].each { |f| require f } Dir[Rails.root.join("spec/fabricators/*.rb")].each { |f| require f } diff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rb index c7b592fe778..6677d1a168b 100644 --- a/spec/support/system_helpers.rb +++ b/spec/support/system_helpers.rb @@ -15,6 +15,10 @@ module SystemHelpers visit "/session/#{user.encoded_username}/become" end + def sign_out + delete "/session" + end + def setup_system_test SiteSetting.login_required = false SiteSetting.content_security_policy = false diff --git a/spec/system/page_objects/components/base.rb b/spec/system/page_objects/components/base.rb new file mode 100644 index 00000000000..cb933c19688 --- /dev/null +++ b/spec/system/page_objects/components/base.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module PageObjects + module Components + class Base + include Capybara::DSL + include RSpec::Matchers + end + end +end diff --git a/spec/system/page_objects/components/composer.rb b/spec/system/page_objects/components/composer.rb new file mode 100644 index 00000000000..28dd6b88a2d --- /dev/null +++ b/spec/system/page_objects/components/composer.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +module PageObjects + module Components + class Composer < PageObjects::Components::Base + def open_new_topic + visit("/latest") + find("button#create-topic").click + self + end + + def open_composer_actions + find(".composer-action-title .btn").click + self + end + + def fill_title(title) + find("#reply-control #reply-title").fill_in(with: title) + self + end + + def fill_content(content) + find("#reply-control .d-editor-input").fill_in(with: content) + self + end + + def select_action(action) + find(action(action)).click + self + end + + def create + find("#reply-control .btn-primary").click + end + + def action(action_title) + ".composer-action-title .select-kit-collection li[title='#{action_title}']" + end + + def button_label + find("#reply-control .btn-primary .d-button-label") + end + end + end +end diff --git a/spec/system/page_objects/components/topic_list.rb b/spec/system/page_objects/components/topic_list.rb new file mode 100644 index 00000000000..83be6a93c27 --- /dev/null +++ b/spec/system/page_objects/components/topic_list.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module PageObjects + module Components + class TopicList < PageObjects::Components::Base + def topic_list + ".topic-list-body" + end + + def visit_topic_with_title(title) + find(".topic-list-body a", text: title).click + end + end + end +end