Files
discourse/plugins/chat/spec/requests/application_controller_spec.rb
Martin Brennan e26a1175d7 FEATURE: Initial version of experimental admin search (#31299)
This feature allows admins to find what they are
looking for in the admin interface via a search modal.
This replaces the admin sidebar filter
as the focus of the Ctrl+/ command, but the sidebar
filter can also still be used. Perhaps at some point
we may remove it or change the shortcut.

The search modal presents the following data for filtering:

* A list of all admin pages, the same as the sidebar,
   except also showing "third level" pages like
   "Email > Skipped"
* All site settings
* Themes
* Components
* Reports

Admins can also filter which types of items are shown in the modal,
for example hiding Settings if they know they are looking for a Page.

In this PR, I also have the following fixes:

* Site setting filters now clear when moving between
   filtered site setting pages, previously it was super
   sticky from Ember
* Many translations were moved around, instead of being
   in various namespaces for the sidebar links and the admin
   page titles and descriptions, now everything is under
   `admin.config` namespace, this makes it way easier to reuse
   this text for pages, search, and sidebar, and if you change it
   in one place then it is changed everywhere.

---------

Co-authored-by: Ella <ella.estigoy@gmail.com>
2025-02-21 11:59:24 +10:00

49 lines
1.3 KiB
Ruby

# frozen_string_literal: true
RSpec.describe ApplicationController do
fab!(:user)
fab!(:admin)
def preloaded_json
JSON.parse(
Nokogiri::HTML5.fragment(response.body).css("div#data-preloaded").first["data-preloaded"],
)
end
before do
SiteSetting.chat_enabled = true
SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:trust_level_0]
end
context "when user is admin" do
it "has correctly loaded preloaded data for visiblePlugins" do
sign_in(admin)
get "/latest"
expect(JSON.parse(preloaded_json["visiblePlugins"])).to include(
{
"name" => "chat",
"humanized_name" => "Chat",
"admin_route" => {
"label" => "chat.admin.title",
"location" => "chat",
"full_location" => "adminPlugins.show",
"use_new_show_route" => true,
"auto_generated" => false,
},
"enabled" => true,
"description" =>
"Adds chat functionality to your site so it can natively support both long-form and short-form communication needs of your online community",
},
)
end
end
context "when user is not admin" do
it "does not include preloaded data for visiblePlugins" do
sign_in(user)
get "/latest"
expect(preloaded_json["visiblePlugins"]).to eq(nil)
end
end
end