mirror of
https://github.com/discourse/discourse.git
synced 2026-08-08 17:53:55 +08:00
## What Draft spike for rendering nested replies through the normal topic route/controller/template (`/t/:slug/:id[/post_number]`) instead of a separate Ember `/n/...` browser page route. This keeps `/n/...` for internal JSON/API endpoints and legacy browser redirects, while using the canonical topic route for user-facing nested topic navigation. ## Changes - Add nested-topic loading/setup to `topic.fromParams` so `/t/...` can render the nested tree. - Render `<Nested>` from the topic template when the topic is in nested mode. - Keep the nested controller as the nested tree state owner, bridged from the topic route/controller. - Redirect legacy client-side `/n/...` browser routes to the corresponding `/t/...` routes. - Preserve nested context depth through model processing, controller state, and cache snapshots. - Update nested post/admin URLs, notifications, activity, copy links, and system specs to canonical `/t/...` browser URLs. - Split scroll-anchor persistence from full nested model cache snapshots to avoid expensive cache writes on scroll. - Add bounded scroll restoration retries for mobile browser-back focus restoration.
85 lines
2.9 KiB
Ruby
Vendored
85 lines
2.9 KiB
Ruby
Vendored
# 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
|
|
Fabricate(:nested_topic, topic: topic)
|
|
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
|