discourse/spec/system/nested_hidden_posts_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

38 lines
1.3 KiB
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe "Nested view hidden posts" do
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:topic) { Fabricate(:topic, user: user) }
fab!(:op) { Fabricate(:post, topic: topic, user: user, post_number: 1) }
fab!(:hidden_reply) do
Fabricate(
:post,
topic: topic,
user: user,
raw: "This hidden reply should be visibly muted in nested view",
reply_to_post_number: nil,
hidden: true,
hidden_reason_id: Post.hidden_reasons[:flag_threshold_reached],
)
end
let(:nested_view) { PageObjects::Pages::NestedView.new }
before do
SiteSetting.nested_replies_enabled = true
Fabricate(:nested_topic, topic: topic)
sign_in(admin)
end
it "marks hidden posts with the same hidden classes used by the flat topic view" do
nested_view.visit_nested(topic)
hidden_post = find(".nested-post__article[data-post-number=\"#{hidden_reply.post_number}\"]")
hidden_post_classes = hidden_post.ancestor(".nested-post")["class"]
expect(hidden_post_classes).to include("post-hidden")
expect(hidden_post_classes).to include("post--hidden")
expect(hidden_post_classes).to include("nested-post--hidden")
end
end