UX: Merge the simplified topic map (#27964)

Replaces the existing topic map with the experimental-topic-map made by @awesomerobot.

---------

Co-authored-by: awesomerobot <kris.aubuchon@discourse.org>
This commit is contained in:
Jan Cernik
2024-07-22 19:42:29 -03:00
committed by GitHub
parent 6039b513fe
commit a027ec4663
30 changed files with 1547 additions and 1020 deletions

View File

@ -2,7 +2,7 @@
#
describe "Topic Map", type: :system do
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:topic) { Fabricate(:topic, user: user, created_at: 1.day.ago) }
fab!(:topic) { Fabricate(:topic, user: user, created_at: 2.day.ago) }
fab!(:original_post) { Fabricate(:post, topic: topic, user: user, created_at: 1.day.ago) }
fab!(:other_user) { Fabricate(:user, refresh_auto_groups: true) }
@ -22,45 +22,46 @@ describe "Topic Map", type: :system do
# topic map only appears after at least 1 reply
expect(topic_page).to have_no_topic_map
Fabricate(:post, topic: topic, created_at: 1.day.ago)
Fabricate(:post, topic: topic, created_at: 2.day.ago)
Fabricate(:post, topic: topic, created_at: 1.day.ago, like_count: 3)
2.times { Fabricate(:post, topic: topic, created_at: 1.day.ago, like_count: 1) }
page.refresh
expect(topic_page).to have_topic_map
expect(topic_map).to have_no_users
# created avatar display
expect(topic_map.created_details).to have_selector("img[src=\"#{avatar_url(user, 24)}\"]")
expect(topic_map.created_relative_date).to eq "1d"
Fabricate(:post, topic: topic, created_at: 1.day.ago)
page.refresh
expect(topic_map.users_count).to eq 6
# replies, user count
# user count
expect {
Fabricate(:post, topic: topic, user: user, created_at: 1.day.ago)
sign_in(last_post_user)
topic_page.visit_topic_and_open_composer(topic)
topic_page.send_reply("this is a cool-cat post") # fabricating posts doesn't update the last post details
topic_page.visit_topic(topic)
}.to change(topic_map, :replies_count).by(2).and change(topic_map, :users_count).by(1)
}.to change(topic_map, :users_count).by(1)
#last reply avatar display
expect(topic_map.last_reply_details).to have_selector(
"img[src=\"#{avatar_url(last_post_user, 24)}\"]",
)
expect(topic_map.last_reply_relative_date).to eq "1m"
# bottom map, avatars details with post counts
expect(topic_map).to have_no_bottom_map
# avatars details with post counts
Fabricate(:post, topic: topic)
Fabricate(:post, user: user, topic: topic)
Fabricate(:post, user: last_post_user, topic: topic)
page.refresh
avatars = topic_map.avatars_details
expect(avatars.length).to eq 3 # max no. of avatars in a collapsed map
expect(avatars[0]).to have_selector("img[src=\"#{avatar_url(user, 48)}\"]")
expect(avatars[0].find(".post-count").text).to eq "3"
expect(avatars[1]).to have_selector("img[src=\"#{avatar_url(last_post_user, 48)}\"]")
expect(avatars[1].find(".post-count").text).to eq "2"
expect(avatars[2]).to have_no_css(".post-count")
topic_map.expand
expect(topic_map).to have_no_avatars_details_in_map
expect(topic_map.expanded_map_avatars_details.length).to eq 4
expect(topic_map).to have_bottom_map
avatars = topic_map.avatars_details
expect(avatars.length).to eq 5 # max no. of avatars in a collapsed map
expanded_avatars = topic_map.expanded_avatars_details
expect(expanded_avatars[0]).to have_selector("img[src=\"#{avatar_url(user, 48)}\"]")
expect(expanded_avatars[0].find(".post-count").text).to eq "3"
expect(expanded_avatars[1]).to have_selector("img[src=\"#{avatar_url(last_post_user, 48)}\"]")
expect(expanded_avatars[1].find(".post-count").text).to eq "2"
expect(expanded_avatars[2]).to have_no_css(".post-count")
expect(expanded_avatars.length).to eq 8
# views count
# TODO (martin) Investigate flakiness
@ -73,6 +74,6 @@ describe "Topic Map", type: :system do
# likes count
# expect(topic_map).to have_no_likes
# topic_page.click_like_reaction_for(original_post)
# expect(topic_map.likes_count).to eq 1
# expect(topic_map.likes_count).to eq 6
end
end