0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/spec/system/nested_ignored_users_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

56 lines
1.7 KiB
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe "Nested view ignored users" do
fab!(:viewer) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:ignored_author) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:topic) { Fabricate(:topic, user: viewer) }
fab!(:op) { Fabricate(:post, topic: topic, user: viewer, post_number: 1) }
fab!(:ignored_reply) do
Fabricate(
:post,
topic: topic,
user: ignored_author,
reply_to_post_number: 1,
raw: "Secret reply content from an ignored user",
)
end
let(:nested_view) { PageObjects::Pages::NestedView.new }
before do
SiteSetting.nested_replies_enabled = true
Fabricate(:nested_topic, topic: topic)
Fabricate(:ignored_user, user: viewer, ignored_user: ignored_author)
sign_in(viewer)
end
it "shows an [ignored] placeholder in place of the reply body" do
nested_view.visit_nested(topic)
expect(nested_view).to have_ignored_placeholder_for(ignored_reply)
expect(page).to have_no_content("Secret reply content from an ignored user")
end
it "reveals the real content when the eye-slash avatar button is clicked" do
nested_view.visit_nested(topic)
expect(nested_view).to have_ignored_placeholder_for(ignored_reply)
nested_view.click_reveal_ignored(ignored_reply)
expect(nested_view).to have_no_ignored_placeholder_for(ignored_reply)
expect(page).to have_css(
"[data-post-number='#{ignored_reply.post_number}']",
text: "Secret reply content from an ignored user",
)
end
it "does not render an ignored placeholder for the OP even if the OP author is ignored" do
op.update!(user: ignored_author)
nested_view.visit_nested(topic)
expect(nested_view).to have_no_ignored_placeholder_for(op)
end
end