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