mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 17:02:45 +08:00
FIX: Dismiss unread posts in subcategories (#29671)
When a parent category shows topics from subcategories, dismissing should dismiss posts in both parent and subcategories. Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
This commit is contained in:
parent
f62ed063fb
commit
9b691853e0
|
@ -207,7 +207,7 @@ export default class DiscoveryListController extends Controller {
|
|||
this.bulkSelectHelper.dismissRead(operationType, {
|
||||
categoryId: this.model.category?.id,
|
||||
tagName: this.model.tag?.id,
|
||||
includeSubcategories: this.model.noSubcategories,
|
||||
includeSubcategories: !this.model.noSubcategories,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
describe "Viewing top topics on categories page", type: :system do
|
||||
describe "Viewing categories page", type: :system do
|
||||
fab!(:user)
|
||||
fab!(:category)
|
||||
fab!(:topic) { Fabricate(:topic, category: category) }
|
||||
|
@ -8,27 +8,50 @@ describe "Viewing top topics on categories page", type: :system do
|
|||
let(:category_list) { PageObjects::Components::CategoryList.new }
|
||||
let(:topic_view) { PageObjects::Components::TopicView.new }
|
||||
|
||||
it "displays and updates new counter" do
|
||||
skip(<<~TEXT)
|
||||
context "when viewing top topics" do
|
||||
it "displays and updates new counter" do
|
||||
skip(<<~TEXT)
|
||||
Flaky at the following step:
|
||||
|
||||
expect(category_list).to have_no_new_posts_badge
|
||||
expected `#<PageObjects::Components::CategoryList:0x00007fe27a3d2340>.has_no_new_posts_badge?` to be truthy, got false
|
||||
TEXT
|
||||
|
||||
sign_in(user)
|
||||
sign_in(user)
|
||||
|
||||
visit("/categories")
|
||||
visit("/categories")
|
||||
|
||||
category_list.click_new_posts_badge(count: 1)
|
||||
category_list.click_topic(topic)
|
||||
category_list.click_new_posts_badge(count: 1)
|
||||
category_list.click_topic(topic)
|
||||
|
||||
expect(topic_view).to have_read_post(post)
|
||||
expect(topic_view).to have_read_post(post)
|
||||
|
||||
category_list.click_logo
|
||||
category_list.click_category_navigation
|
||||
category_list.click_logo
|
||||
category_list.click_category_navigation
|
||||
|
||||
expect(category_list).to have_category(category)
|
||||
expect(category_list).to have_no_new_posts_badge
|
||||
expect(category_list).to have_category(category)
|
||||
expect(category_list).to have_no_new_posts_badge
|
||||
end
|
||||
end
|
||||
|
||||
context "when viewing the category's topic list" do
|
||||
let(:topic_list) { PageObjects::Components::TopicList.new }
|
||||
|
||||
context "when parent category has default_list_filter=none" do
|
||||
fab!(:parent_category) { Fabricate(:category_with_definition, default_list_filter: "none") }
|
||||
fab!(:subcategoryA) { Fabricate(:category_with_definition, parent_category: parent_category) }
|
||||
fab!(:topic) { Fabricate(:topic, category: subcategoryA) }
|
||||
fab!(:post) { create_post(topic: topic) }
|
||||
|
||||
it "lists the topic on the subcategory" do
|
||||
visit "/c/#{parent_category.slug}/#{subcategoryA.slug}"
|
||||
expect(topic_list).to have_topic(topic)
|
||||
end
|
||||
|
||||
it "does not list the topic on the parent category" do
|
||||
visit "/c/#{parent_category.slug}"
|
||||
expect(topic_list).to have_no_topic(topic)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,6 +53,29 @@ RSpec.describe "Dismissing New", type: :system do
|
|||
|
||||
using_session(:tab_1) { expect(topic_view).to have_tracking_status("regular") }
|
||||
end
|
||||
|
||||
context "when dismissing new on a category's topic list" do
|
||||
fab!(:category) { Fabricate(:category_with_definition) }
|
||||
fab!(:subcategory) { Fabricate(:category_with_definition, parent_category: category) }
|
||||
fab!(:category_topic) { Fabricate(:topic, category: category, user: user) }
|
||||
fab!(:category_post1) { create_post(user: user, topic: category_topic) }
|
||||
fab!(:category_post2) { create_post(topic: category_topic) }
|
||||
fab!(:subcategory_topic) { Fabricate(:topic, category: subcategory, user: user) }
|
||||
fab!(:subcategory_post1) { create_post(user: user, topic: subcategory_topic) }
|
||||
fab!(:subcategory_post2) { create_post(topic: subcategory_topic) }
|
||||
|
||||
it "should dismiss unread posts for the category and its subcategories" do
|
||||
sign_in(user)
|
||||
|
||||
visit("/c/#{category.id}/l/unread")
|
||||
|
||||
expect(topic_list_controls).to have_unread(count: 2)
|
||||
|
||||
topic_list_controls.dismiss_unread
|
||||
|
||||
expect(topic_list_controls).to have_unread(count: 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "when a user has a new topic" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user