0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 06:24:48 +08:00
discourse/spec/system/nested_copy_link_spec.rb
Mark VanLandingham 63c4950c90
DEV: route nested view through topic route (#40820)
## 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.
2026-06-15 11:42:20 -05:00

61 lines
1.8 KiB
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe "Nested view copy link" do
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:topic) { Fabricate(:topic, user: user) }
fab!(:op) { Fabricate(:post, topic: topic, user: user, post_number: 1) }
let(:nested_view) { PageObjects::Pages::NestedView.new }
let(:cdp) { PageObjects::CDP.new }
fab!(:root_reply) do
Fabricate(:post, topic: topic, user: Fabricate(:user), raw: "Root reply content")
end
fab!(:child_reply) do
Fabricate(
:post,
topic: topic,
user: Fabricate(:user),
raw: "Child reply content",
reply_to_post_number: root_reply.post_number,
)
end
before do
SiteSetting.nested_replies_enabled = true
Fabricate(:nested_topic, topic: topic)
sign_in(user)
cdp.allow_clipboard
end
describe "copy link on OP" do
it "copies the nested URL" do
nested_view.visit_nested(topic)
nested_view.click_copy_link_on_op
expected = "#{Discourse.base_url}/t/#{topic.slug}/#{topic.id}/#{op.post_number}"
cdp.clipboard_has_text?(expected)
end
end
describe "copy link on a nested post" do
it "copies the nested URL" do
nested_view.visit_nested(topic)
nested_view.click_copy_link_on_post(root_reply)
expected = "#{Discourse.base_url}/t/#{topic.slug}/#{topic.id}/#{root_reply.post_number}"
cdp.clipboard_has_text?(expected)
end
end
describe "copy link in context=0 view" do
it "copies the standard nested URL without context param" do
nested_view.visit_nested_context(topic, post_number: child_reply.post_number, context: 0)
nested_view.click_copy_link_on_post(child_reply)
expected = "#{Discourse.base_url}/t/#{topic.slug}/#{topic.id}/#{child_reply.post_number}"
cdp.clipboard_has_text?(expected)
end
end
end