mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-18 20:40:03 +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.
62 lines
2 KiB
Ruby
Vendored
62 lines
2 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
RSpec.describe "Nested view post admin menu" 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) do
|
|
Fabricate(
|
|
:post,
|
|
topic: topic,
|
|
user: user,
|
|
post_number: 1,
|
|
raw: "Original OP content that is long enough to render",
|
|
)
|
|
end
|
|
fab!(:reply) { Fabricate(:post, topic: topic, user: user, raw: "Some reply body here") }
|
|
|
|
let(:nested_view) { PageObjects::Pages::NestedView.new }
|
|
|
|
before do
|
|
SiteSetting.nested_replies_enabled = true
|
|
Fabricate(:nested_topic, topic: topic)
|
|
end
|
|
|
|
def open_admin_menu_for(post)
|
|
selector = "[data-post-number='#{post.post_number}']"
|
|
within(selector) do
|
|
find(".show-more-actions").click if has_css?(".show-more-actions", wait: 2)
|
|
find(".post-action-menu__admin").click
|
|
end
|
|
end
|
|
|
|
context "as an admin" do
|
|
before { sign_in(admin) }
|
|
|
|
it "fires lockPost when clicking the admin menu item on a reply" do
|
|
nested_view.visit_nested(topic)
|
|
open_admin_menu_for(reply)
|
|
expect(page).to have_css("[data-content][data-identifier='admin-post-menu']")
|
|
find("[data-content][data-identifier='admin-post-menu'] .lock-post").click
|
|
|
|
try_until_success { expect(reply.reload.locked_by_id).to eq(admin.id) }
|
|
end
|
|
|
|
it "fires lockPost when clicking the admin menu item on the OP" do
|
|
nested_view.visit_nested(topic)
|
|
open_admin_menu_for(op)
|
|
expect(page).to have_css("[data-content][data-identifier='admin-post-menu']")
|
|
find("[data-content][data-identifier='admin-post-menu'] .lock-post").click
|
|
|
|
try_until_success { expect(op.reload.locked_by_id).to eq(admin.id) }
|
|
end
|
|
|
|
it "opens the change-owner modal when clicking the admin menu item" do
|
|
nested_view.visit_nested(topic)
|
|
open_admin_menu_for(reply)
|
|
find("[data-content][data-identifier='admin-post-menu'] .change-owner").click
|
|
|
|
expect(page).to have_css(".change-ownership-modal")
|
|
end
|
|
end
|
|
end
|