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

37 lines
876 B
Ruby

# frozen_string_literal: true
module PageObjects
module Components
class TopicList < PageObjects::Components::Base
TOPIC_LIST_BODY_SELECTOR = ".topic-list-body"
TOPIC_LIST_ITEM_SELECTOR = "#{TOPIC_LIST_BODY_SELECTOR} .topic-list-item"
def topic_list
TOPIC_LIST_BODY_SELECTOR
end
def has_topics?(count:)
page.has_css?(TOPIC_LIST_ITEM_SELECTOR, count: count)
end
def has_topic?(topic)
page.has_css?(topic_list_item_class(topic))
end
def has_no_topic?(topic)
page.has_no_css?(topic_list_item_class(topic))
end
def visit_topic_with_title(title)
find("#{TOPIC_LIST_BODY_SELECTOR} a", text: title).click
end
private
def topic_list_item_class(topic)
"#{TOPIC_LIST_ITEM_SELECTOR}[data-topic-id='#{topic.id}']"
end
end
end
end