mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Page settings can be very long and the setting can be way out of viewport. This should ensure the setting can be found and clicked. This was for example causing this flakey in discourse-topic-voting: ``` Failures: 1) Voting enables voting in category topics and votes Failure/Error: find(".edit-category-tab .#{setting} label.checkbox-label", text: text).click Capybara::ElementNotFound: Unable to find css ".edit-category-tab .enable-topic-voting label.checkbox-label" [Screenshot Image]: /__w/discourse/discourse/tmp/capybara/failures_r_spec_example_groups_voting_enables_voting_in_category_topics_and_votes_873.png ~~~~~~~ JS LOGS ~~~~~~~ http://localhost:31341/favicon.ico - Failed to load resource: the server responded with a status of 404 (Not Found) ~~~~~ END JS LOGS ~~~~~ # ./vendor/bundle/ruby/3.2.0/gems/capybara-3.39.1/lib/capybara/node/finders.rb:312:in `block in synced_resolve' # ./vendor/bundle/ruby/3.2.0/gems/capybara-3.39.1/lib/capybara/node/base.rb:84:in `synchronize' # ./vendor/bundle/ruby/3.2.0/gems/capybara-3.39.1/lib/capybara/node/finders.rb:301:in `synced_resolve' # ./vendor/bundle/ruby/3.2.0/gems/capybara-3.39.1/lib/capybara/node/finders.rb:60:in `find' # ./vendor/bundle/ruby/3.2.0/gems/capybara-3.39.1/lib/capybara/session.rb:773:in `find' # ./vendor/bundle/ruby/3.2.0/gems/capybara-3.39.1/lib/capybara/dsl.rb:52:in `call' # ./vendor/bundle/ruby/3.2.0/gems/capybara-3.39.1/lib/capybara/dsl.rb:52:in `find' # ./spec/system/page_objects/pages/category.rb:34:in `toggle_setting' # ./plugins/discourse-topic-voting/spec/system/voting_spec.rb:39:in `block (2 levels) in <main>' # ./spec/rails_helper.rb:368:in `block (3 levels) in <top (required)>' # ./vendor/bundle/ruby/3.2.0/gems/timeout-0.3.2/lib/timeout.rb:189:in `block in timeout' # ./vendor/bundle/ruby/3.2.0/gems/timeout-0.3.2/lib/timeout.rb:36:in `block in catch' # ./vendor/bundle/ruby/3.2.0/gems/timeout-0.3.2/lib/timeout.rb:36:in `catch' # ./vendor/bundle/ruby/3.2.0/gems/timeout-0.3.2/lib/timeout.rb:36:in `catch' # ./vendor/bundle/ruby/3.2.0/gems/timeout-0.3.2/lib/timeout.rb:198:in `timeout' # ./spec/rails_helper.rb:364:in `block (2 levels) in <top (required)>' # ./spec/rails_helper.rb:356:in `block (2 levels) in <top (required)>' # ./vendor/bundle/ruby/3.2.0/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>' Finished in 7 minutes 18 seconds (files took 0 seconds to load) 445 examples, 1 failure, 17 pending, 1 error occurred outside of examples Failed examples: rspec ./plugins/discourse-topic-voting/spec/system/voting_spec.rb:27 # Voting enables voting in category topics and votes ```
88 lines
2.2 KiB
Ruby
88 lines
2.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Pages
|
|
class Category < PageObjects::Pages::Base
|
|
# keeping the various category related features combined for now
|
|
|
|
def visit(category)
|
|
page.visit("/c/#{category.id}")
|
|
self
|
|
end
|
|
|
|
def visit_settings(category)
|
|
page.visit("/c/#{category.slug}/edit/settings")
|
|
self
|
|
end
|
|
|
|
def visit_edit_template(category)
|
|
page.visit("/c/#{category.slug}/edit/topic-template")
|
|
self
|
|
end
|
|
|
|
def back_to_category
|
|
find(".edit-category-title-bar span", text: "Back to category").click
|
|
self
|
|
end
|
|
|
|
def save_settings
|
|
find("#save-category").click
|
|
self
|
|
end
|
|
|
|
def toggle_setting(setting, text = "")
|
|
find(".edit-category-tab .#{setting} label.checkbox-label", text: text, visible: :all).click
|
|
self
|
|
end
|
|
|
|
# Edit Category Page
|
|
def has_form_template_enabled?
|
|
find(".d-toggle-switch .toggle-template-type", visible: false)["aria-checked"] == "true"
|
|
end
|
|
|
|
D_EDITOR_SELECTOR = ".d-editor"
|
|
|
|
def has_d_editor?
|
|
page.has_selector?(D_EDITOR_SELECTOR)
|
|
end
|
|
|
|
def has_no_d_editor?
|
|
page.has_no_selector?(D_EDITOR_SELECTOR)
|
|
end
|
|
|
|
def has_selected_template?(template_name)
|
|
find(".select-category-template .select-kit-header")["data-name"] == template_name
|
|
end
|
|
|
|
def toggle_form_templates
|
|
find(".d-toggle-switch .d-toggle-switch__checkbox-slider").click
|
|
self
|
|
end
|
|
|
|
def select_form_template(template_name)
|
|
find(".select-category-template").click
|
|
find(".select-kit-collection .select-kit-row", text: template_name).click
|
|
find(".select-category-template").click
|
|
end
|
|
|
|
def new_topic_button
|
|
find("#create-topic")
|
|
end
|
|
|
|
CATEGORY_NAVIGATION_NEW_NAV_ITEM_SELECTOR = ".category-navigation .nav-item_new"
|
|
|
|
def has_no_new_topics?
|
|
page.has_no_css?(CATEGORY_NAVIGATION_NEW_NAV_ITEM_SELECTOR)
|
|
end
|
|
|
|
def has_new_topics?
|
|
page.has_css?(CATEGORY_NAVIGATION_NEW_NAV_ITEM_SELECTOR)
|
|
end
|
|
|
|
def click_new
|
|
page.find(CATEGORY_NAVIGATION_NEW_NAV_ITEM_SELECTOR).click
|
|
end
|
|
end
|
|
end
|
|
end
|