discourse/spec/models/sidebar_section_spec.rb
David Battersby 47c8197ea1
FEATURE: add drafts dropdown menu (#30277)
This change adds a new dropdown trigger next to the "New Topic" button.
When clicked a menu will display a list of topic/post drafts that can be
clicked to resume the draft within the composer.

The "New Topic" button will no longer change text to show "Open Draft"
when a draft topic exists, it will still attempt to load the existing
draft if one exists (this will change later when we support multiple
drafts in a separate PR).

The "My Posts" link in desktop sidebar will now be "My Drafts" and only
appear when the current user has existing drafts.
2025-01-13 13:33:57 +04:00

40 lines
1.1 KiB
Ruby

# frozen_string_literal: true
RSpec.describe SidebarSection do
fab!(:user)
fab!(:sidebar_section) { Fabricate(:sidebar_section, user: user) }
let(:community_section) do
SidebarSection.find_by(section_type: SidebarSection.section_types[:community])
end
it "uses system user for public sections" do
expect(sidebar_section.user_id).to eq(user.id)
sidebar_section.update!(public: true)
expect(sidebar_section.user_id).to eq(Discourse.system_user.id)
end
it "resets Community section to the default state" do
community_section.update!(title: "test")
community_section.sidebar_section_links.first.linkable.update!(name: "everything edited")
community_section.sidebar_section_links.last.destroy!
community_section.reset_community!
expect(community_section.reload.title).to eq("Community")
expect(community_section.sidebar_section_links.all.map { |link| link.linkable.name }).to eq(
[
"Topics",
"My Drafts",
"Review",
"Admin",
"Invite",
"Users",
"About",
"FAQ",
"Groups",
"Badges",
],
)
end
end