2024-05-21 20:36:15 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
describe "glimmer topic list", type: :system do
|
|
|
|
fab!(:user)
|
2024-05-22 09:06:45 +08:00
|
|
|
fab!(:group) { Fabricate(:group, users: [user]) }
|
2024-05-21 20:36:15 +08:00
|
|
|
|
2024-06-27 02:04:33 +08:00
|
|
|
let(:topic_list) { PageObjects::Components::TopicList.new }
|
|
|
|
let(:topic_page) { PageObjects::Pages::Topic.new }
|
|
|
|
|
2024-05-21 20:36:15 +08:00
|
|
|
before do
|
2024-05-22 09:06:45 +08:00
|
|
|
SiteSetting.experimental_glimmer_topic_list_groups = group.name
|
2024-05-21 20:36:15 +08:00
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "/latest" do
|
|
|
|
it "shows the list" do
|
|
|
|
Fabricate.times(5, :topic)
|
|
|
|
visit("/latest")
|
|
|
|
|
|
|
|
expect(topic_list).to have_topics(count: 5)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-06-25 19:00:13 +08:00
|
|
|
describe "/new" do
|
|
|
|
it "shows the list and the toggle buttons" do
|
|
|
|
SiteSetting.experimental_new_new_view_groups = group.name
|
|
|
|
Fabricate(:topic)
|
|
|
|
Fabricate(:new_reply_topic, current_user: user)
|
|
|
|
|
|
|
|
visit("/new")
|
|
|
|
|
|
|
|
expect(topic_list).to have_topics(count: 2)
|
|
|
|
expect(page).to have_css(".topics-replies-toggle.--all")
|
|
|
|
expect(page).to have_css(".topics-replies-toggle.--topics")
|
|
|
|
expect(page).to have_css(".topics-replies-toggle.--replies")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-05-21 20:36:15 +08:00
|
|
|
describe "categories-with-featured-topics page" do
|
|
|
|
let(:category_list) { PageObjects::Components::CategoryList.new }
|
|
|
|
|
|
|
|
it "shows the list" do
|
|
|
|
SiteSetting.desktop_category_page_style = "categories_with_featured_topics"
|
|
|
|
category = Fabricate(:category)
|
|
|
|
topic = Fabricate(:topic, category: category)
|
|
|
|
topic2 = Fabricate(:topic)
|
|
|
|
CategoryFeaturedTopic.feature_topics
|
|
|
|
|
|
|
|
visit("/categories")
|
|
|
|
|
|
|
|
expect(category_list).to have_topic(topic)
|
|
|
|
expect(category_list).to have_topic(topic2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "suggested topics" do
|
|
|
|
it "shows the list" do
|
2024-05-22 09:06:45 +08:00
|
|
|
topic1 = Fabricate(:post).topic
|
2024-05-21 20:36:15 +08:00
|
|
|
topic2 = Fabricate(:post).topic
|
2024-06-25 19:47:53 +08:00
|
|
|
new_reply = Fabricate(:new_reply_topic, current_user: user, count: 3)
|
2024-05-22 09:06:45 +08:00
|
|
|
|
|
|
|
visit(topic1.relative_url)
|
2024-05-21 20:36:15 +08:00
|
|
|
|
|
|
|
expect(topic_page).to have_suggested_topic(topic2)
|
2024-05-22 09:06:45 +08:00
|
|
|
expect(page).to have_css("[data-topic-id='#{topic2.id}'] a.badge-notification.new-topic")
|
|
|
|
|
|
|
|
expect(topic_page).to have_suggested_topic(new_reply)
|
|
|
|
expect(
|
|
|
|
find("[data-topic-id='#{new_reply.id}'] a.badge-notification.unread-posts").text,
|
|
|
|
).to eq("3")
|
2024-05-21 20:36:15 +08:00
|
|
|
end
|
|
|
|
end
|
2024-06-27 02:04:33 +08:00
|
|
|
|
|
|
|
describe "topic highlighting" do
|
|
|
|
# TODO: Those require `Capybara.disable_animation = false`
|
|
|
|
|
|
|
|
skip "highlights newly received topics" do
|
|
|
|
Fabricate(:read_topic, current_user: user)
|
|
|
|
|
|
|
|
visit("/latest")
|
|
|
|
|
|
|
|
new_topic = Fabricate(:post).topic
|
|
|
|
TopicTrackingState.publish_new(new_topic)
|
|
|
|
|
|
|
|
topic_list.had_new_topics_alert?
|
|
|
|
topic_list.click_new_topics_alert
|
|
|
|
|
|
|
|
topic_list.has_highlighted_topic?(new_topic)
|
|
|
|
end
|
|
|
|
|
|
|
|
skip "highlights the previous topic after navigation" do
|
|
|
|
topic = Fabricate(:read_topic, current_user: user)
|
|
|
|
|
|
|
|
visit("/latest")
|
|
|
|
topic_list.visit_topic(topic)
|
|
|
|
expect(topic_page).to have_topic_title(topic.title)
|
|
|
|
page.go_back
|
|
|
|
|
|
|
|
topic_list.has_highlighted_topic?(topic)
|
|
|
|
end
|
|
|
|
end
|
2024-05-21 20:36:15 +08:00
|
|
|
end
|