Alan Guo Xiang Tan e3977f84a3
FIX: Incorrect topic tracking state count when a new category is created (#20506)
What is the problem?

We have a hidden site setting `show_category_definitions_in_topic_lists`
which is set to false by default. What this means is that category
definition topics are not shown in the topic list by default. Only the
category definition topic for the category being viewed will be shown.
However, we have a bug where we would show that a category has new
topics when a new child category along with its category definition
topic is created even though the topic list does not list the child
category's category definition topic.

What is the fix here?

This commit fixes the problem by shipping down an additional
`is_category_topic` attribute in `TopicTrackingStateItemSerializer` when
the `show_category_definitions_in_topic_lists` site setting has been set
to false. With the new attribute, we can then exclude counting child
categories' category definition topics when counting new and unread
counts for a category.
2023-03-06 10:13:10 +08:00

78 lines
2.0 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).click
self
end
# Edit Category Page
def has_form_template_enabled?
find(".d-toggle-switch .toggle-template-type", visible: false)["aria-checked"] == "true"
end
def has_d_editor?
page.has_selector?(".d-editor")
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
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