mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 13:19:19 +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.
47 lines
1.4 KiB
Ruby
Vendored
47 lines
1.4 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
require_relative "../support/nested_replies_helpers"
|
|
|
|
RSpec.describe "Nested replies topic admin toggle" do
|
|
include NestedRepliesHelpers
|
|
|
|
fab!(:admin)
|
|
fab!(:topic) { Fabricate(:topic, user: admin) }
|
|
fab!(:op) { Fabricate(:post, topic: topic, user: admin, post_number: 1) }
|
|
fab!(:reply) { Fabricate(:post, topic: topic, user: Fabricate(:user), raw: "A reply") }
|
|
|
|
let(:topic_page) { PageObjects::Pages::Topic.new }
|
|
let(:nested_view) { PageObjects::Pages::NestedView.new }
|
|
|
|
before do
|
|
SiteSetting.nested_replies_enabled = true
|
|
sign_in(admin)
|
|
end
|
|
|
|
it "enables nested replies from the flat view and routes to nested" do
|
|
topic_page.visit_topic(topic)
|
|
|
|
topic_page.click_admin_menu_button
|
|
find(".topic-admin-nested-replies").click
|
|
|
|
expect(page).to have_current_path(%r{/t/#{topic.slug}/#{topic.id}})
|
|
expect(nested_view).to have_nested_view
|
|
|
|
topic.reload
|
|
expect(topic.reload.nested_topic).to be_present
|
|
end
|
|
|
|
it "disables nested replies from the nested view and routes to flat" do
|
|
Fabricate(:nested_topic, topic: topic)
|
|
|
|
nested_view.visit_nested(topic)
|
|
nested_view.open_admin_menu
|
|
find(".topic-admin-nested-replies").click
|
|
|
|
expect(page).to have_current_path(%r{/t/#{topic.slug}/#{topic.id}})
|
|
expect(nested_view).to have_no_nested_view
|
|
|
|
topic.reload
|
|
expect(topic.reload.nested_topic).to be_nil
|
|
end
|
|
end
|