mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 04:42:19 +08:00
In nested view it adds an "activity log" link to open the modal. This contains whispers with action code, and small action posts, which are not rendered on the nested view.
84 lines
2.8 KiB
Ruby
84 lines
2.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "Nested view real-time updates" do
|
|
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
|
|
fab!(:other_user) { Fabricate(:user, refresh_auto_groups: true) }
|
|
fab!(:admin)
|
|
fab!(:topic) { Fabricate(:topic, user: user) }
|
|
fab!(:op) { Fabricate(:post, topic: topic, user: user, post_number: 1) }
|
|
fab!(:root_reply) do
|
|
Fabricate(:post, topic: topic, user: Fabricate(:user), raw: "Existing root reply")
|
|
end
|
|
|
|
let(:nested_view) { PageObjects::Pages::NestedView.new }
|
|
|
|
before do
|
|
SiteSetting.nested_replies_enabled = true
|
|
sign_in(user)
|
|
end
|
|
|
|
describe "new root post by another user" do
|
|
it "shows new replies notification banner and loads posts on click" do
|
|
nested_view.visit_nested(topic)
|
|
expect(nested_view).to have_nested_view
|
|
expect(nested_view).to have_root_post(root_reply)
|
|
|
|
# Create a root post via PostCreator which triggers MessageBus
|
|
PostCreator.create!(
|
|
other_user,
|
|
topic_id: topic.id,
|
|
raw: "A brand new root reply from another user",
|
|
)
|
|
|
|
expect(page).to have_css(".nested-view__new-replies-btn", wait: 10)
|
|
|
|
find(".nested-view__new-replies-btn").click
|
|
|
|
expect(page).to have_no_css(".nested-view__new-replies-btn")
|
|
expect(page).to have_content("A brand new root reply from another user")
|
|
end
|
|
end
|
|
|
|
describe "new child reply by another user" do
|
|
it "shows the new child in the tree" do
|
|
nested_view.visit_nested(topic)
|
|
expect(nested_view).to have_nested_view
|
|
expect(nested_view).to have_root_post(root_reply)
|
|
|
|
new_child =
|
|
PostCreator.create!(
|
|
other_user,
|
|
topic_id: topic.id,
|
|
reply_to_post_number: root_reply.post_number,
|
|
raw: "A child reply via message bus",
|
|
)
|
|
|
|
expect(page).to have_css(
|
|
"[data-post-number='#{new_child.post_number}']",
|
|
text: "A child reply via message bus",
|
|
wait: 10,
|
|
)
|
|
end
|
|
end
|
|
|
|
describe "small_action posts" do
|
|
it "does not insert close/open small_actions into the tree" do
|
|
nested_view.visit_nested(topic)
|
|
expect(nested_view).to have_root_post(root_reply)
|
|
|
|
small_action = topic.add_small_action(admin, "closed.enabled")
|
|
|
|
# A real reply published right after — once it surfaces, the small_action's
|
|
# message bus event has already been delivered (same channel, in order),
|
|
# so we can safely assert it never landed in the tree.
|
|
new_reply =
|
|
PostCreator.create!(other_user, topic_id: topic.id, raw: "Real reply that must show")
|
|
|
|
expect(page).to have_css(".nested-view__new-replies-btn", wait: 10)
|
|
find(".nested-view__new-replies-btn").click
|
|
|
|
expect(nested_view).to have_root_post(new_reply)
|
|
expect(page).to have_no_css("[data-post-number='#{small_action.post_number}']")
|
|
end
|
|
end
|
|
end
|