2023-06-21 11:42:30 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-11-14 23:06:12 +08:00
|
|
|
describe "Viewing categories page", type: :system do
|
2023-11-10 06:47:59 +08:00
|
|
|
fab!(:user)
|
|
|
|
fab!(:category)
|
2023-06-21 11:42:30 +08:00
|
|
|
fab!(:topic) { Fabricate(:topic, category: category) }
|
2023-07-18 07:35:47 +08:00
|
|
|
fab!(:post) { Fabricate(:post, topic: topic) }
|
2023-11-21 00:22:14 +08:00
|
|
|
let(:category_list) { PageObjects::Components::CategoryList.new }
|
|
|
|
let(:topic_view) { PageObjects::Components::TopicView.new }
|
2023-06-21 11:42:30 +08:00
|
|
|
|
2024-11-14 23:06:12 +08:00
|
|
|
context "when viewing top topics" do
|
|
|
|
it "displays and updates new counter" do
|
|
|
|
skip(<<~TEXT)
|
2023-07-18 07:26:12 +08:00
|
|
|
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
|
|
|
|
|
2024-11-14 23:06:12 +08:00
|
|
|
sign_in(user)
|
2023-06-21 11:42:30 +08:00
|
|
|
|
2024-11-14 23:06:12 +08:00
|
|
|
visit("/categories")
|
2023-06-21 11:42:30 +08:00
|
|
|
|
2024-11-14 23:06:12 +08:00
|
|
|
category_list.click_new_posts_badge(count: 1)
|
|
|
|
category_list.click_topic(topic)
|
2023-07-18 07:35:47 +08:00
|
|
|
|
2024-11-14 23:06:12 +08:00
|
|
|
expect(topic_view).to have_read_post(post)
|
2023-07-18 07:35:47 +08:00
|
|
|
|
2024-11-14 23:06:12 +08:00
|
|
|
category_list.click_logo
|
|
|
|
category_list.click_category_navigation
|
2023-06-21 11:42:30 +08:00
|
|
|
|
2024-11-14 23:06:12 +08:00
|
|
|
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
|
2023-06-21 11:42:30 +08:00
|
|
|
end
|
|
|
|
end
|