2022-11-10 21:00:12 +08:00
|
|
|
# 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)
|
2022-11-11 17:44:40 +08:00
|
|
|
page.visit("/c/#{category.id}")
|
2022-11-10 21:00:12 +08:00
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
def visit_settings(category)
|
2022-11-11 17:44:40 +08:00
|
|
|
page.visit("/c/#{category.slug}/edit/settings")
|
2022-11-10 21:00:12 +08:00
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2025-10-02 14:33:30 +03:00
|
|
|
def visit_general(category)
|
|
|
|
page.visit("/c/#{category.slug}/edit/general")
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2023-02-23 11:18:14 -08:00
|
|
|
def visit_edit_template(category)
|
|
|
|
page.visit("/c/#{category.slug}/edit/topic-template")
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2025-04-23 19:48:35 -07:00
|
|
|
def visit_edit_localizations(category)
|
|
|
|
page.visit("/c/#{category.slug}/edit/localizations")
|
|
|
|
end
|
|
|
|
|
2024-07-01 07:14:34 +05:30
|
|
|
def visit_categories
|
|
|
|
page.visit("/categories")
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
def visit_new_category
|
|
|
|
page.visit("/new-category")
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2024-08-28 16:11:16 +10:00
|
|
|
def visit_security(category)
|
|
|
|
page.visit("/c/#{category.slug}/edit/security")
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2025-07-01 18:39:47 -05:00
|
|
|
def visit_images(category)
|
|
|
|
page.visit("/c/#{category.slug}/edit/images")
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2022-11-10 21:00:12 +08:00
|
|
|
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
|
|
|
|
|
2022-11-11 17:44:40 +08:00
|
|
|
def toggle_setting(setting, text = "")
|
2023-05-28 14:15:10 +02:00
|
|
|
find(".edit-category-tab .#{setting} label.checkbox-label", text: text, visible: :all).click
|
2022-11-10 21:00:12 +08:00
|
|
|
self
|
|
|
|
end
|
2023-02-23 11:18:14 -08:00
|
|
|
|
|
|
|
# Edit Category Page
|
|
|
|
def has_form_template_enabled?
|
|
|
|
find(".d-toggle-switch .toggle-template-type", visible: false)["aria-checked"] == "true"
|
|
|
|
end
|
|
|
|
|
2023-05-05 07:45:53 +08:00
|
|
|
D_EDITOR_SELECTOR = ".d-editor"
|
|
|
|
|
2023-02-23 11:18:14 -08:00
|
|
|
def has_d_editor?
|
2023-05-05 07:45:53 +08:00
|
|
|
page.has_selector?(D_EDITOR_SELECTOR)
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_d_editor?
|
|
|
|
page.has_no_selector?(D_EDITOR_SELECTOR)
|
2023-02-23 11:18:14 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_selected_template?(template_name)
|
2023-07-06 14:42:59 +10:00
|
|
|
has_css?(".select-category-template .select-kit-header[data-name='#{template_name}']")
|
2023-02-23 11:18:14 -08:00
|
|
|
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
|
2023-03-06 10:13:10 +08:00
|
|
|
|
2023-05-10 12:34:39 -05:00
|
|
|
def new_topic_button
|
|
|
|
find("#create-topic")
|
|
|
|
end
|
|
|
|
|
2023-03-06 10:13:10 +08:00
|
|
|
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
|
2024-08-28 16:11:16 +10:00
|
|
|
|
|
|
|
def has_public_access_message?
|
|
|
|
page.has_content?(I18n.t("js.category.permissions.everyone_has_access"))
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_public_access_message?
|
|
|
|
page.has_no_content?(I18n.t("js.category.permissions.everyone_has_access"))
|
|
|
|
end
|
2025-04-23 19:48:35 -07:00
|
|
|
|
|
|
|
def has_setting_tab?(tab_name)
|
|
|
|
tab_css = ".edit-category-#{tab_name}"
|
|
|
|
page.has_css?(tab_css)
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_setting_tab?(tab_name)
|
|
|
|
tab_css = ".edit-category-#{tab_name}"
|
|
|
|
page.has_no_css?(tab_css)
|
|
|
|
end
|
2022-11-10 21:00:12 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|