A platform for community discussion. Free, open, simple.
DEV: Make the Glimmer Search Menu the new default (#25092)
Isaac Janzen1f94da349b41
diff --git a/app/assets/javascripts/discourse/app/widgets/header.js b/app/assets/javascripts/discourse/app/widgets/header.jsindex 0657c9055fd..3f2cb996438 100644--- a/app/assets/javascripts/discourse/app/widgets/header.js+++ b/app/assets/javascripts/discourse/app/widgets/header.js@@ -521,7 +521,7 @@ export default createWidget("header", {const panels = [this.attach("header-buttons", attrs), headerIcons];if (state.searchVisible || this.search.visible) {- if (this.currentUser?.experimental_search_menu_groups_enabled) {+ if (this.siteSettings.experimental_search_menu) {this.search.inTopicContext =this.search.inTopicContext && inTopicRoute;panels.push(this.attach("glimmer-search-menu-wrapper"));@@ -731,7 +731,7 @@ export default createWidget("header", {focusSearchInput() {if (this.state.searchVisible &&- !this.currentUser?.experimental_search_menu_groups_enabled+ !this.siteSettings.experimental_search_menu) {schedule("afterRender", () => {const searchInput = document.querySelector("#search-term");diff --git a/app/assets/javascripts/discourse/tests/acceptance/glimmer-search-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/glimmer-search-mobile-test.jsindex 61c206a004d..4ea36862363 100644--- a/app/assets/javascripts/discourse/tests/acceptance/glimmer-search-mobile-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/glimmer-search-mobile-test.js@@ -9,9 +9,6 @@ import {acceptance("Search - Glimmer - Mobile", function (needs) {needs.mobileView();- needs.user({- experimental_search_menu_groups_enabled: true,- });test("search", async function (assert) {await visit("/");diff --git a/app/assets/javascripts/discourse/tests/acceptance/glimmer-search-test.js b/app/assets/javascripts/discourse/tests/acceptance/glimmer-search-test.jsindex f12cb72c377..7c813383f49 100644--- a/app/assets/javascripts/discourse/tests/acceptance/glimmer-search-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/glimmer-search-test.js@@ -15,18 +15,11 @@ import {exists,query,queryAll,- updateCurrentUser,} from "discourse/tests/helpers/qunit-helpers";import selectKit from "discourse/tests/helpers/select-kit-helper";import I18n from "discourse-i18n";acceptance("Search - Glimmer - Anonymous", function (needs) {- needs.user({- experimental_search_menu_groups_enabled: true,- });- needs.hooks.beforeEach(() => {- updateCurrentUser({ is_anonymous: true });- });needs.pretender((server, helper) => {server.get("/search/query", (request) => {if (request.queryParams.type_filter === DEFAULT_TYPE_FILTER) {@@ -439,9 +432,7 @@ acceptance("Search - Glimmer - Anonymous", function (needs) {});acceptance("Search - Glimmer - Authenticated", function (needs) {- needs.user({- experimental_search_menu_groups_enabled: true,- });+ needs.user();needs.settings({log_search_queries: true,allow_uncategorized_topics: true,@@ -742,9 +733,7 @@ acceptance("Search - Glimmer - Authenticated", function (needs) {});acceptance("Search - Glimmer - with tagging enabled", function (needs) {- needs.user({- experimental_search_menu_groups_enabled: true,- });+ needs.user();needs.settings({ tagging_enabled: true });needs.pretender((server, helper) => {server.get("/tag/dev/notifications", () => {@@ -912,10 +901,7 @@ acceptance("Search - Glimmer - with tagging enabled", function (needs) {});acceptance("Search - Glimmer - assistant", function (needs) {- needs.user({- experimental_search_menu_groups_enabled: true,- });-+ needs.user();needs.pretender((server, helper) => {server.get("/search/query", (request) => {if (request.queryParams["search_context[type]"] === "private_messages") {diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-test.jsdeleted file mode 100644index a82237039be..00000000000--- a/app/assets/javascripts/discourse/tests/acceptance/search-test.js+++ /dev/null@@ -1,1039 +0,0 @@-import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";-import { test } from "qunit";-import searchFixtures from "discourse/tests/fixtures/search-fixtures";-import {- acceptance,- count,- exists,- query,- queryAll,-} from "discourse/tests/helpers/qunit-helpers";-import selectKit from "discourse/tests/helpers/select-kit-helper";-import { DEFAULT_TYPE_FILTER } from "discourse/widgets/search-menu";-import I18n from "discourse-i18n";--acceptance("Search - Anonymous", function (needs) {- needs.pretender((server, helper) => {- server.get("/search/query", (request) => {- if (request.queryParams.type_filter === DEFAULT_TYPE_FILTER) {- // posts/topics are not present in the payload by default- return helper.response({- users: searchFixtures["search/query"]["users"],- categories: searchFixtures["search/query"]["categories"],- tags: searchFixtures["search/query"]["tags"],- groups: searchFixtures["search/query"]["groups"],- grouped_search_result:- searchFixtures["search/query"]["grouped_search_result"],- });- }- return helper.response(searchFixtures["search/query"]);- });-- server.get("/u/search/users", () => {- return helper.response({- users: [- {- username: "admin",- name: "admin",- avatar_template: "/images/avatar.png",- },- ],- });- });- });-- test("search", async function (assert) {- await visit("/");-- await click("#search-button");-- assert.ok(exists("#search-term"), "it shows the search input");- assert.ok(- exists(".show-advanced-search"),- "it shows full page search button"- );- assert.ok(- exists(".search-menu .results ul li.search-random-quick-tip"),- "shows random quick tip by default"- );-- await fillIn("#search-term", "dev");-- assert.ok(- !exists(".search-menu .results ul li.search-random-quick-tip"),- "quick tip no longer shown"- );-- assert.strictEqual(- query(- ".search-menu .results ul.search-menu-initial-options li:first-child .search-item-slug"- ).innerText.trim(),- `dev${I18n.t("search.in_topics_posts")}`,- "shows topic search as first dropdown item"- );-- assert.ok(- exists(".search-menu .search-result-category ul li"),- "shows matching category results"- );-- assert.ok(- exists(".search-menu .search-result-user ul li"),- "shows matching user results"- );-- await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");- await click(document.activeElement);-- assert.ok(- exists(".search-menu .search-result-topic ul li"),- "shows topic results"- );- assert.ok(- exists(".search-menu .results ul li .topic-title[data-topic-id]"),- "topic has data-topic-id"- );-- await click(".show-advanced-search");-- assert.strictEqual(- query(".full-page-search").value,- "dev",- "it goes to full search page and preserves the search term"- );-- assert.ok(- exists(".search-advanced-options"),- "advanced search is expanded"- );- });-- test("search button toggles search menu", async function (assert) {- await visit("/");-- await click("#search-button");- assert.ok(exists(".search-menu"));-- await click(".d-header"); // click outside- assert.ok(!exists(".search-menu"));-- await click("#search-button");- assert.ok(exists(".search-menu"));-- await click("#search-button"); // toggle same button- assert.ok(!exists(".search-menu"));- });-- test("search scope", async function (assert) {- const contextSelector = ".search-menu .results .search-menu-assistant-item";-- await visit("/tag/important");- await click("#search-button");-- assert.strictEqual(- queryAll(contextSelector)[0].firstChild.textContent.trim(),- `${I18n.t("search.in")} important`,- "contextual tag search is first available option with no term"- );-- await fillIn("#search-term", "smth");-- assert.strictEqual(- queryAll(contextSelector)[1].firstChild.textContent.trim(),- `smth ${I18n.t("search.in")} important`,- "tag-scoped search is second available option"- );-- await visit("/c/bug");- await click("#search-button");-- assert.strictEqual(- queryAll(contextSelector)[1].firstChild.textContent.trim(),- `smth ${I18n.t("search.in")} bug`,- "category-scoped search is first available option with no search term"- );-- assert.ok(- exists(`${contextSelector} span.badge-category__wrapper`),- "category badge is a span (i.e. not a link)"- );-- await visit("/t/internationalization-localization/280");- await click("#search-button");-- assert.strictEqual(- queryAll(contextSelector)[1].firstChild.textContent.trim(),- `smth ${I18n.t("search.in_this_topic")}`,- "topic-scoped search is first available option with no search term"- );-- await visit("/u/eviltrout");- await click("#search-button");-- assert.strictEqual(- queryAll(contextSelector)[1].firstChild.textContent.trim(),- `smth ${I18n.t("search.in_posts_by", {- username: "eviltrout",- })}`,- "user-scoped search is first available option with no search term"- );- });-- test("search scope for topics", async function (assert) {- await visit("/t/internationalization-localization/280/1");-- await click("#search-button");-- const firstResult =- ".search-menu .results .search-menu-assistant-item:first-child";-- assert.strictEqual(- query(firstResult).textContent.trim(),- I18n.t("search.in_this_topic"),- "contextual topic search is first available option with no search term"- );-- await fillIn("#search-term", "a proper");- await query("input#search-term").focus();- await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");- await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");-- await click(document.activeElement);- assert.ok(- exists(".search-menu .search-result-post ul li"),- "clicking second option scopes search to current topic"- );-- assert.strictEqual(- query("#post_7 span.highlighted").textContent.trim(),- "a proper",- "highlights the post correctly"- );-- assert.ok(- exists(".search-menu .search-context"),- "search context indicator is visible"- );- await click(".clear-search");- assert.strictEqual(query("#search-term").value, "", "clear button works");-- await click(".search-context");-- assert.ok(- !exists(".search-menu .search-context"),- "search context indicator is no longer visible"- );-- await fillIn("#search-term", "dev");- await query("input#search-term").focus();- await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");- await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");- await click(document.activeElement);-- assert.ok(- exists(".search-menu .search-context"),- "search context indicator is visible"- );-- await fillIn("#search-term", "");- await query("input#search-term").focus();- await triggerKeyEvent("input#search-term", "keydown", "Backspace");-- assert.ok(- !exists(".search-menu .search-context"),- "backspace resets search context"- );- });-- test("topic search scope - keep 'in this topic' filter in full page search", async function (assert) {- await visit("/t/internationalization-localization/280/1");-- await click("#search-button");-- const contextSelector = ".search-menu .results .search-menu-assistant-item";-- assert.strictEqual(- queryAll(contextSelector)[0].firstChild.textContent.trim(),- I18n.t("search.in_this_topic"),- "contextual topic search is first available option with no search term"- );-- await fillIn("#search-term", "proper");- await query("input#search-term").focus();- await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");- await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");- await click(document.activeElement);-- assert.ok(- exists(".search-menu .search-context"),- "search context indicator is visible"- );-- await click(".show-advanced-search");-- assert.strictEqual(- query(".full-page-search").value,- "proper topic:280",- "it goes to full search page and preserves search term + context"- );-- assert.ok(- exists(".search-advanced-options"),- "advanced search is expanded"- );- });-- test("topic search scope - special case when matching a single user", async function (assert) {- await visit("/t/internationalization-localization/280/1");-- await click("#search-button");- await fillIn("#search-term", "@admin");-- assert.strictEqual(count(".search-menu-assistant-item"), 2);-- assert.strictEqual(- query(- ".search-menu-assistant-item:first-child .search-item-user .label-suffix"- ).textContent.trim(),- I18n.t("search.in_topics_posts"),- "first result hints at global search"- );-- assert.strictEqual(- query(- ".search-menu-assistant-item:nth-child(2) .search-item-user .label-suffix"- ).textContent.trim(),- I18n.t("search.in_this_topic"),- "second result hints at search within current topic"- );- });-- test("Right filters are shown in full page search", async function (assert) {- const inSelector = selectKit(".select-kit#in");-- await visit("/search?expanded=true");-- await inSelector.expand();-- assert.ok(inSelector.rowByValue("first").exists());- assert.ok(inSelector.rowByValue("pinned").exists());- assert.ok(inSelector.rowByValue("wiki").exists());- assert.ok(inSelector.rowByValue("images").exists());-- assert.notOk(inSelector.rowByValue("unseen").exists());- assert.notOk(inSelector.rowByValue("posted").exists());- assert.notOk(inSelector.rowByValue("watching").exists());- assert.notOk(inSelector.rowByValue("tracking").exists());- assert.notOk(inSelector.rowByValue("bookmarks").exists());-- assert.notOk(exists(".search-advanced-options .in-likes"));- assert.notOk(exists(".search-advanced-options .in-private"));- assert.notOk(exists(".search-advanced-options .in-seen"));- });-});--acceptance("Search - Default sort order", function (needs) {- needs.user();- needs.settings({- search_default_sort_order: 1, // "latest"- });- needs.hooks.beforeEach(function () {- this.searchPreferencesManager = this.container.lookup(- "service:search-preferences-manager"- );- this.searchPreferencesManager.sortOrder = null;- });- needs.hooks.afterEach(function () {- this.searchPreferencesManager.sortOrder = null;- });-- test("Default sort order is used if there is no preference in user key value store", async function (assert) {- await visit("/search?q=discourse");-- const searchSortByDropdown = selectKit("#search-sort-by");- await searchSortByDropdown.expand();- assert.strictEqual(searchSortByDropdown.header().value(), "1");- });-- test("User preference from SearchPreferencesManager key value store is used if present", async function (assert) {- this.searchPreferencesManager = this.container.lookup(- "service:search-preferences-manager"- );- this.searchPreferencesManager.sortOrder = 2; // "likes"-- await visit("/search?q=discourse");-- const searchSortByDropdown = selectKit("#search-sort-by");- await searchSortByDropdown.expand();- assert.strictEqual(searchSortByDropdown.header().value(), "2");- });-});--acceptance("Search - Authenticated", function (needs) {- needs.user();- needs.settings({- log_search_queries: true,- allow_uncategorized_topics: true,- });-- needs.pretender((server, helper) => {- server.get("/search/query", (request) => {- if (request.queryParams.term.includes("empty")) {- return helper.response({- posts: [],- users: [],- categories: [],- tags: [],- groups: [],- grouped_search_result: {- more_posts: null,- more_users: null,- more_categories: null,- term: "plans test",- search_log_id: 1,- more_full_page_results: null,- can_create_topic: true,- error: null,- type_filter: null,- post_ids: [],- user_ids: [],- category_ids: [],- tag_ids: [],- group_ids: [],- },- });- }-- return helper.response(searchFixtures["search/query"]);- });-- server.get("/inline-onebox", () =>- helper.response({- "inline-oneboxes": [- {- url: "http://www.something.com",- title: searchFixtures["search/query"].topics[0].title,- },- ],- })- );- });-- test("Right filters are shown in full page search", async function (assert) {- const inSelector = selectKit(".select-kit#in");-- await visit("/search?expanded=true");-- await inSelector.expand();-- assert.ok(inSelector.rowByValue("first").exists());- assert.ok(inSelector.rowByValue("pinned").exists());- assert.ok(inSelector.rowByValue("wiki").exists());- assert.ok(inSelector.rowByValue("images").exists());-- assert.ok(inSelector.rowByValue("unseen").exists());- assert.ok(inSelector.rowByValue("posted").exists());- assert.ok(inSelector.rowByValue("watching").exists());- assert.ok(inSelector.rowByValue("tracking").exists());- assert.ok(inSelector.rowByValue("bookmarks").exists());-- assert.ok(exists(".search-advanced-options .in-likes"));- assert.ok(exists(".search-advanced-options .in-private"));- assert.ok(exists(".search-advanced-options .in-seen"));- });-- test("Works with empty result sets", async function (assert) {- await visit("/t/internationalization-localization/280");- await click("#search-button");- await fillIn("#search-term", "plans");- await query("input#search-term").focus();- await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");- await click(document.activeElement);-- assert.notStrictEqual(count(".search-menu .results .item"), 0);-- await fillIn("#search-term", "plans empty");- await triggerKeyEvent("#search-term", "keydown", 13);-- assert.strictEqual(count(".search-menu .results .item"), 0);- assert.strictEqual(count(".search-menu .results .no-results"), 1);- });-- test("search dropdown keyboard navigation", async function (assert) {- const container = ".search-menu .results";-- await visit("/");- await click("#search-button");- await fillIn("#search-term", "dev");-- assert.ok(exists(query(`${container} ul li`)), "has a list of items");-- await triggerKeyEvent("#search-term", "keydown", "Enter");- assert.ok(- exists(query(`${container} .search-result-topic`)),- "has topic results"- );-- await triggerKeyEvent("#search-term", "keydown", "ArrowDown");-- assert.strictEqual(- document.activeElement.getAttribute("href"),- query(`${container} li:first-child a`).getAttribute("href"),- "arrow down selects first element"- );-- await triggerKeyEvent("#search-term", "keydown", "ArrowDown");-- assert.strictEqual(- document.activeElement.getAttribute("href"),- query(`${container} li:nth-child(2) a`).getAttribute("href"),- "arrow down selects next element"- );-- await triggerKeyEvent("#search-term", "keydown", "ArrowDown");- await triggerKeyEvent("#search-term", "keydown", "ArrowDown");- await triggerKeyEvent("#search-term", "keydown", "ArrowDown");- await triggerKeyEvent("#search-term", "keydown", "ArrowDown");-- assert.strictEqual(- document.activeElement.getAttribute("href"),- "/search?q=dev",- "arrow down sets focus to more results link"- );-- await triggerKeyEvent(".search-menu", "keydown", "Escape");- assert.strictEqual(- document.activeElement,- query("#search-button"),- "Escaping search returns focus to search button"- );- assert.ok(!exists(".search-menu:visible"), "Esc removes search dropdown");-- await click("#search-button");- await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");- await triggerKeyEvent(".search-menu", "keydown", "ArrowUp");-- assert.strictEqual(- document.activeElement.tagName.toLowerCase(),- "input",- "arrow up sets focus to search term input"- );-- await triggerKeyEvent(".search-menu", "keydown", "Escape");- await click("#create-topic");- await click("#search-button");- await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");-- const firstLink = query(`${container} li:nth-child(1) a`).getAttribute(- "href"- );- await triggerKeyEvent(".search-menu", "keydown", "A");-- assert.strictEqual(- query("#reply-control textarea").value,- `${window.location.origin}${firstLink}`,- "hitting A when focused on a search result copies link to composer"- );-- await click("#search-button");- await triggerKeyEvent("#search-term", "keydown", "Enter");-- assert.ok(- exists(query(`${container} .search-result-topic`)),- "has topic results"- );-- await triggerKeyEvent("#search-term", "keydown", "Enter");-- assert.ok(- exists(query(`.search-container`)),- "second Enter hit goes to full page search"- );- assert.ok(- !exists(query(`.search-menu`)),- "search dropdown is collapsed after second Enter hit"- );-- // new search launched, Enter key should be reset- await click("#search-button");- assert.ok(exists(query(`${container} ul li`)), "has a list of items");- await triggerKeyEvent("#search-term", "keydown", "Enter");- assert.ok(exists(query(`.search-menu`)), "search dropdown is visible");- });-- test("search while composer is open", async function (assert) {- await visit("/t/internationalization-localization/280");- await click(".reply");- await fillIn(".d-editor-input", "a link");- await click("#search-button");- await fillIn("#search-term", "dev");-- await triggerKeyEvent("#search-term", "keydown", "Enter");- await triggerKeyEvent(".search-menu", "keydown", "ArrowDown");- await triggerKeyEvent("#search-term", "keydown", 65); // maps to lowercase a-- assert.ok(- query(".d-editor-input").value.includes("a link"),- "still has the original composer content"- );-- assert.ok(- query(".d-editor-input").value.includes(- searchFixtures["search/query"].topics[0].slug- ),- "adds link from search to composer"- );- });-- test("Shows recent search results", async function (assert) {- await visit("/");- await click("#search-button");-- assert.strictEqual(- query(- ".search-menu .search-menu-recent li:nth-of-type(1) .search-link"- ).textContent.trim(),- "yellow",- "shows first recent search"- );-- assert.strictEqual(- query(- ".search-menu .search-menu-recent li:nth-of-type(2) .search-link"- ).textContent.trim(),- "blue",- "shows second recent search"- );- });-});--acceptance("Search - with tagging enabled", function (needs) {- needs.user();- needs.settings({ tagging_enabled: true });-- test("displays tags", async function (assert) {- await visit("/");- await click("#search-button");- await fillIn("#search-term", "dev");- await triggerKeyEvent("#search-term", "keydown", 13);-- assert.strictEqual(- query(- ".search-menu .results ul li:nth-of-type(1) .discourse-tags"- ).textContent.trim(),- "devslow",- "tags displayed in search results"- );- });-- test("displays tag shortcuts", async function (assert) {- await visit("/");-- await click("#search-button");-- await fillIn("#search-term", "dude #monk");- await triggerKeyEvent("#search-term", "keyup", 51);-- const firstItem =- ".search-menu .results ul.search-menu-assistant .search-link";- assert.ok(exists(query(firstItem)));-- const firstTag = query(`${firstItem} .search-item-tag`).textContent.trim();- assert.strictEqual(firstTag, "monkey");- });-});--acceptance("Search - assistant", function (needs) {- needs.user();-- needs.pretender((server, helper) => {- server.get("/search/query", (request) => {- if (request.queryParams["search_context[type]"] === "private_messages") {- // return only one result for PM search- return helper.response({- posts: [- {- id: 3833,- name: "Bill Dudney",- username: "bdudney",- avatar_template:- "/user_avatar/meta.discourse.org/bdudney/{size}/8343_1.png",- uploaded_avatar_id: 8343,- created_at: "2013-02-07T17:46:57.469Z",- cooked:- "<p>I've gotten vagrant up and running with a development environment but it's taking forever to load.</p>\n\n<p>For example <a href=\"http://192.168.10.200:3000/\" rel=\"nofollow\">http://192.168.10.200:3000/</a> takes tens of seconds to load.</p>\n\n<p>I'm running the whole stack on a new rMBP with OS X 10.8.2.</p>\n\n<p>Any ideas of what I've done wrong? Or is this just a function of being on the bleeding edge?</p>\n\n<p>Thanks,</p>\n\n<p>-bd</p>",- post_number: 1,- post_type: 1,- updated_at: "2013-02-07T17:46:57.469Z",- like_count: 0,- reply_count: 1,- reply_to_post_number: null,- quote_count: 0,- incoming_link_count: 4422,- reads: 327,- score: 21978.4,- yours: false,- topic_id: 2179,- topic_slug: "development-mode-super-slow",- display_username: "Bill Dudney",- primary_group_name: null,- version: 2,- can_edit: false,- can_delete: false,- can_recover: false,- user_title: null,- actions_summary: [- {- id: 2,- count: 0,- hidden: false,- can_act: false,- },- {- id: 3,- count: 0,- hidden: false,- can_act: false,- },- {- id: 4,- count: 0,- hidden: false,- can_act: false,- },- {- id: 5,- count: 0,- hidden: true,- can_act: false,- },- {- id: 6,- count: 0,- hidden: false,- can_act: false,- },- {- id: 7,- count: 0,- hidden: false,- can_act: false,- },- {- id: 8,- count: 0,- hidden: false,- can_act: false,- },- ],- moderator: false,- admin: false,- staff: false,- user_id: 1828,- hidden: false,- hidden_reason_id: null,- trust_level: 1,- deleted_at: null,- user_deleted: false,- edit_reason: null,- can_view_edit_history: true,- wiki: false,- blurb:- "I've gotten vagrant up and running with a development environment but it's taking forever to load. For example http://192.168.10.200:3000/ takes...",- },- ],- topics: [- {- id: 2179,- title: "Development mode super slow",- fancy_title: "Development mode super slow",- slug: "development-mode-super-slow",- posts_count: 72,- reply_count: 53,- highest_post_number: 73,- image_url: null,- created_at: "2013-02-07T17:46:57.262Z",- last_posted_at: "2015-04-17T08:08:26.671Z",- bumped: true,- bumped_at: "2015-04-17T08:08:26.671Z",- unseen: false,- pinned: false,- unpinned: null,- visible: true,- closed: false,- archived: false,- bookmarked: null,- liked: null,- views: 9538,- like_count: 45,- has_summary: true,- archetype: "regular",- last_poster_username: null,- category_id: 7,- pinned_globally: false,- posters: [],- tags: ["dev", "slow"],- tags_descriptions: {- dev: "dev description",- slow: "slow description",- },- },- ],- grouped_search_result: {- term: "emoji",- post_ids: [3833],- },- });- }- return helper.response(searchFixtures["search/query"]);- });-- server.get("/tag/dev/notifications", () => {- return helper.response({- tag_notification: { id: "dev", notification_level: 2 },- });- });-- server.get("/tags/c/bug/1/dev/l/latest.json", () => {- return helper.response({- users: [],- primary_groups: [],- topic_list: {- can_create_topic: true,- draft: null,- draft_key: "new_topic",- draft_sequence: 1,- per_page: 30,- tags: [- {- id: 1,- name: "dev",- topic_count: 1,- },- ],- topics: [],- },- });- });-- server.get("/tags/intersection/dev/foo.json", () => {- return helper.response({- topic_list: {- can_create_topic: true,- draft: null,- draft_key: "new_topic",- draft_sequence: 1,- per_page: 30,- topics: [],- },- });- });-- server.get("/u/search/users", () => {- return helper.response({- users: [- {- username: "TeaMoe",- name: "TeaMoe",- avatar_template:- "https://avatars.discourse.org/v3/letter/t/41988e/{size}.png",- },- {- username: "TeamOneJ",- name: "J Cobb",- avatar_template:- "https://avatars.discourse.org/v3/letter/t/3d9bf3/{size}.png",- },- {- username: "kudos",- name: "Team Blogeto.com",- avatar_template:- "/user_avatar/meta.discourse.org/kudos/{size}/62185_1.png",- },- ],- });- });- });-- test("shows category shortcuts when typing #", async function (assert) {- await visit("/");-- await click("#search-button");-- await fillIn("#search-term", "#");- await triggerKeyEvent("#search-term", "keyup", 51);-- const firstCategory =- ".search-menu .results ul.search-menu-assistant .search-link";- assert.ok(exists(query(firstCategory)));-- const firstResultSlug = query(- `${firstCategory} .badge-category__name`- ).textContent.trim();-- await click(firstCategory);- assert.strictEqual(query("#search-term").value, `#${firstResultSlug}`);-- await fillIn("#search-term", "sam #");- await triggerKeyEvent("#search-term", "keyup", 51);-- assert.ok(exists(query(firstCategory)));- assert.strictEqual(- query(- ".search-menu .results ul.search-menu-assistant .search-item-prefix"- ).innerText,- "sam"- );-- await click(firstCategory);- assert.strictEqual(query("#search-term").value, `sam #${firstResultSlug}`);- });-- test("Shows category / tag combination shortcut when both are present", async function (assert) {- await visit("/tags/c/bug/dev");- await click("#search-button");-- assert.strictEqual(- query(- ".search-menu .results ul.search-menu-assistant .badge-category__name"- ).innerText,- "bug",- "Category is displayed"- );-- assert.strictEqual(- query(".search-menu .results ul.search-menu-assistant .search-item-tag")- .innerText,- "dev",- "Tag is displayed"- );- });-- test("Updates tag / category combination search suggestion when typing", async function (assert) {- await visit("/tags/c/bug/dev");- await click("#search-button");- await fillIn("#search-term", "foo bar");-- assert.strictEqual(- query(- ".search-menu .results ul.search-menu-assistant .search-item-prefix"- ).innerText,- "foo bar",- "Input is applied to search query"- );-- assert.strictEqual(- query(- ".search-menu .results ul.search-menu-assistant .badge-category__name"- ).innerText,- "bug"- );-- assert.strictEqual(- query(".search-menu .results ul.search-menu-assistant .search-item-tag")- .innerText,- "dev",- "Tag is displayed"- );- });-- test("Shows tag combination shortcut when visiting tag intersection", async function (assert) {- await visit("/tags/intersection/dev/foo");- await click("#search-button");-- assert.strictEqual(- query(".search-menu .results ul.search-menu-assistant .search-item-tag")- .innerText,- "tags:dev+foo",- "Tags are displayed"- );- });-- test("Updates tag intersection search suggestion when typing", async function (assert) {- await visit("/tags/intersection/dev/foo");- await click("#search-button");- await fillIn("#search-term", "foo bar");-- assert.strictEqual(- query(- ".search-menu .results ul.search-menu-assistant .search-item-prefix"- ).innerText,- "foo bar",- "Input is applied to search query"- );-- assert.strictEqual(- query(".search-menu .results ul.search-menu-assistant .search-item-tag")- .innerText,- "tags:dev+foo",- "Tags are displayed"- );- });-- test("shows in: shortcuts", async function (assert) {- await visit("/");- await click("#search-button");-- const firstTarget =- ".search-menu .results ul.search-menu-assistant .search-link .search-item-slug";-- await fillIn("#search-term", "in:");- await triggerKeyEvent("#search-term", "keyup", 51);- assert.strictEqual(query(firstTarget).innerText, "in:title");-- await fillIn("#search-term", "sam in:");- await triggerKeyEvent("#search-term", "keyup", 51);- assert.strictEqual(query(firstTarget).innerText, "sam in:title");-- await fillIn("#search-term", "in:mess");- await triggerKeyEvent("#search-term", "keyup", 51);- assert.strictEqual(query(firstTarget).innerText, "in:messages");- });-- test("shows users when typing @", async function (assert) {- await visit("/");-- await click("#search-button");-- await fillIn("#search-term", "@");- await triggerKeyEvent("#search-term", "keyup", 51);-- const firstUser =- ".search-menu .results ul.search-menu-assistant .search-item-user";- const firstUsername = query(firstUser).innerText.trim();- assert.strictEqual(firstUsername, "TeaMoe");-- await click(query(firstUser));- assert.strictEqual(query("#search-term").value, `@${firstUsername}`);- });-- test("shows 'in messages' button when in an inbox", async function (assert) {- await visit("/u/charlie/messages");- await click("#search-button");-- assert.ok(exists(".btn.search-context"), "it shows the button");-- await fillIn("#search-term", "");- await query("input#search-term").focus();- await triggerKeyEvent("input#search-term", "keydown", "Backspace");-- assert.notOk(exists(".btn.search-context"), "it removes the button");-- await click(".d-header");- await click("#search-button");- assert.ok(- exists(".btn.search-context"),- "it shows the button when reinvoking search"- );-- await fillIn("#search-term", "emoji");- await query("input#search-term").focus();- await triggerKeyEvent("#search-term", "keydown", "Enter");-- assert.strictEqual(- count(".search-menu .search-result-topic"),- 1,- "it passes the PM search context to the search query"- );- });-});diff --git a/app/assets/javascripts/discourse/tests/unit/lib/search-test.js b/app/assets/javascripts/discourse/tests/unit/lib/search-test.jsdeleted file mode 100644index 1f8336d9963..00000000000--- a/app/assets/javascripts/discourse/tests/unit/lib/search-test.js+++ /dev/null@@ -1,567 +0,0 @@-import { setupTest } from "ember-qunit";-import { module, test } from "qunit";-import {- reciprocallyRankedList,- searchContextDescription,- translateResults,-} from "discourse/lib/search";-import I18n from "discourse-i18n";--module("Unit | Utility | search", function (hooks) {- setupTest(hooks);-- test("unescapesEmojisInBlurbs", async function (assert) {- const source = {- posts: [- {- id: 160,- username: "pmusaraj",- avatar_template: "/user_avatar/localhost/pmusaraj/{size}/3_2.png",- created_at: "2019-07-22T03:47:04.864Z",- like_count: 1,- blurb: ":thinking: This here is a test of emojis in search blurbs.",- post_number: 1,- topic_id: 41,- },- ],- topics: [],- users: [],- categories: [],- tags: [],- groups: [],- grouped_search_result: false,- };-- const results = await translateResults(source);- const blurb = results.posts[0].get("blurb");-- assert.ok(blurb.includes("thinking.png"));- assert.ok(blurb.startsWith('<img width="20" height="20" src'));- assert.ok(!blurb.includes(":thinking:"));- });-- test("searchContextDescription", function (assert) {- assert.strictEqual(- searchContextDescription("topic"),- I18n.t("search.context.topic")- );- assert.strictEqual(- searchContextDescription("user", "silvio.dante"),- I18n.t("search.context.user", { username: "silvio.dante" })- );- assert.strictEqual(- searchContextDescription("category", "staff"),- I18n.t("search.context.category", { category: "staff" })- );- assert.strictEqual(- searchContextDescription("tag", "important"),- I18n.t("search.context.tag", { tag: "important" })- );- assert.strictEqual(- searchContextDescription("private_messages"),- I18n.t("search.context.private_messages")- );- assert.strictEqual(searchContextDescription("bad_type"), undefined);- });-- test("reciprocallyRankedList", async function (assert) {- const sourceA = [- {- id: 250,- name: "Bruce Wayne",- username: "batman",- topic_id: 96,- topic: {- id: 96,- title: "I like to fight crime",- },- },- {- id: 104,- name: "Steve Rogers",- username: "captain_america",- topic_id: 2,- topic: {- id: 2,- title: "What its like being frozen...",- },- },- {- id: 202,- name: "Peter Parker",- username: "spidey",- topic_id: 32,- topic: {- id: 32,- title: "My experience meeting the Avengers",- },- },- {- id: 290,- name: "Clark Kent",- username: "superman",- topic_id: 111,- topic: {- id: 111,- title: "My fear of Kryptonite",- },- },- ];-- const sourceB = [- {- id: 104,- name: "Tony Stark",- username: "ironman",- topic_id: 95,- topic: {- id: 95,- title: "What I learned from my father",- },- },- {- id: 246,- name: "The Joker",- username: "joker",- topic_id: 93,- topic: {- id: 93,- title: "Why don't you put a smile on that face...",- },- },- {- id: 104,- name: "Steve Rogers",- username: "captain_america",- topic_id: 2,- topic: {- id: 2,- title: "What its like being frozen...",- },- },- {- id: 245,- name: "Loki",- username: "loki",- topic_id: 92,- topic: {- id: 92,- title: "There is only one person you can trust",- },- },- ];-- const desiredMixedResults = [- {- id: 104,- itemKey: "2_2",- name: "Steve Rogers",- reciprocalRank: 0.30952380952380953,- topic: {- id: 2,- title: "What its like being frozen...",- },- topic_id: 2,- username: "captain_america",- },- {- id: 250,- itemKey: "96_96",- name: "Bruce Wayne",- reciprocalRank: 0.2,- topic: {- id: 96,- title: "I like to fight crime",- },- topic_id: 96,- username: "batman",- },- {- id: 104,- itemKey: "95_95",- name: "Tony Stark",- reciprocalRank: 0.2,- topic: {- id: 95,- title: "What I learned from my father",- },- topic_id: 95,- username: "ironman",- },- {- id: 246,- itemKey: "93_93",- name: "The Joker",- reciprocalRank: 0.16666666666666666,- topic: {- id: 93,- title: "Why don't you put a smile on that face...",- },- topic_id: 93,- username: "joker",- },- {- id: 202,- itemKey: "32_32",- name: "Peter Parker",- reciprocalRank: 0.14285714285714285,- topic: {- id: 32,- title: "My experience meeting the Avengers",- },- topic_id: 32,- username: "spidey",- },- {- id: 290,- itemKey: "111_111",- name: "Clark Kent",- reciprocalRank: 0.125,- topic: {- id: 111,- title: "My fear of Kryptonite",- },- topic_id: 111,- username: "superman",- },- {- id: 245,- itemKey: "92_92",- name: "Loki",- reciprocalRank: 0.125,- topic: {- id: 92,- title: "There is only one person you can trust",- },- topic_id: 92,- username: "loki",- },- ];-- const rankedList = reciprocallyRankedList(- [sourceA, sourceB],- ["topic_id", "topic_id"]- );-- assert.deepEqual(- rankedList,- desiredMixedResults,- "it correctly ranks the results using the reciprocal ranking algorithm"- );- });-- test("reciprocallyRankedList (varied lists with more sources)", async function (assert) {- const sourceA = [- {- id: 1,- name: "Tony Stark",- username: "ironman",- topic_id: 21,- topic: {- id: 21,- title: "I am iron man",- },- },- {- id: 2,- name: "Steve Rogers",- username: "captain_america",- topic_id: 22,- topic: {- id: 22,- title: "What its like being frozen...",- },- },- {- id: 3,- name: "Peter Parker",- username: "spidey",- topic_id: 23,- topic: {- id: 23,- title: "My experience meeting the Avengers",- },- },- {- id: 4,- name: "Stephen Strange",- username: "doctor_strange",- topic_id: 24,- topic: {- id: 24,- title: "14 mil different possible futures",- },- },- ];-- const sourceB = [- {- id: 5,- name: "Clark Kent",- username: "superman",- tid: 90,- topic: {- id: 90,- title: "I am not from this planet.",- fancy_title: "I am not from this planet.",- },- },- {- id: 6,- name: "Bruce Wayne",- username: "batman",- tid: 91,- topic: {- id: 91,- title: "It's not who I am underneath, but what I do that defines me.",- fancy_title: "It's what I do that defines me.",- },- },- {- id: 7,- name: "Steve Rogers",- username: "captain_america",- tid: 22,- topic: {- id: 22,- title: "What its like being frozen...",- fancy_title: "What its like being frozen...",- },- },- {- id: 8,- name: "Barry Allen",- username: "the_flash",- tid: 93,- topic: {- id: 93,- title: "Run Barry run!",- fancy_title: "Run barry run!",- },- },- ];-- const sourceC = [- {- id: 41,- tuid: 906,- name: "The Joker",- username: "joker",- user_id: 81,- flair_name: "DC",- topic: {- title: "I am not from this planet.",- can_edit: true,- },- },- {- id: 91,- tuid: 23,- name: "Peter Parker",- username: "spidey",- user_id: 80,- flair_name: "Marvel",- topic: {- title: "My experience meeting the Avengers.",- can_edit: false,- },- },- {- id: 42,- tuid: 96,- name: "Thanos",- username: "thanos",- user_id: 82,- flair_name: "Marvel",- topic: {- title: "Fine, I'll do it myself",- can_edit: true,- },- },- {- id: 43,- tuid: 97,- name: "Lex Luthor",- username: "lex",- user_id: 83,- flair_name: "DC",- topic: {- title:- "Devils don't come from the hell beneath us, they come from the sky",- can_edit: true,- },- },- ];-- const desiredMixedResults = [- {- id: 1,- itemKey: "21__",- name: "Tony Stark",- reciprocalRank: 0.2,- topic: {- id: 21,- title: "I am iron man",- },- topic_id: 21,- username: "ironman",- },- {- id: 5,- itemKey: "_90_",- name: "Clark Kent",- reciprocalRank: 0.2,- tid: 90,- topic: {- fancy_title: "I am not from this planet.",- id: 90,- title: "I am not from this planet.",- },- username: "superman",- },- {- flair_name: "DC",- id: 41,- itemKey: "__906",- name: "The Joker",- reciprocalRank: 0.2,- topic: {- can_edit: true,- title: "I am not from this planet.",- },- tuid: 906,- user_id: 81,- username: "joker",- },- {- id: 2,- itemKey: "22__",- name: "Steve Rogers",- reciprocalRank: 0.16666666666666666,- topic: {- id: 22,- title: "What its like being frozen...",- },- topic_id: 22,- username: "captain_america",- },- {- id: 6,- itemKey: "_91_",- name: "Bruce Wayne",- reciprocalRank: 0.16666666666666666,- tid: 91,- topic: {- fancy_title: "It's what I do that defines me.",- id: 91,- title: "It's not who I am underneath, but what I do that defines me.",- },- username: "batman",- },- {- flair_name: "Marvel",- id: 91,- itemKey: "__23",- name: "Peter Parker",- reciprocalRank: 0.16666666666666666,- topic: {- can_edit: false,- title: "My experience meeting the Avengers.",- },- tuid: 23,- user_id: 80,- username: "spidey",- },- {- id: 3,- itemKey: "23__",- name: "Peter Parker",- reciprocalRank: 0.14285714285714285,- topic: {- id: 23,- title: "My experience meeting the Avengers",- },- topic_id: 23,- username: "spidey",- },- {- id: 7,- itemKey: "_22_",- name: "Steve Rogers",- reciprocalRank: 0.14285714285714285,- tid: 22,- topic: {- fancy_title: "What its like being frozen...",- id: 22,- title: "What its like being frozen...",- },- username: "captain_america",- },- {- flair_name: "Marvel",- id: 42,- itemKey: "__96",- name: "Thanos",- reciprocalRank: 0.14285714285714285,- topic: {- can_edit: true,- title: "Fine, I'll do it myself",- },- tuid: 96,- user_id: 82,- username: "thanos",- },- {- id: 4,- itemKey: "24__",- name: "Stephen Strange",- reciprocalRank: 0.125,- topic: {- id: 24,- title: "14 mil different possible futures",- },- topic_id: 24,- username: "doctor_strange",- },- {- id: 8,- itemKey: "_93_",- name: "Barry Allen",- reciprocalRank: 0.125,- tid: 93,- topic: {- fancy_title: "Run barry run!",- id: 93,- title: "Run Barry run!",- },- username: "the_flash",- },- {- flair_name: "DC",- id: 43,- itemKey: "__97",- name: "Lex Luthor",- reciprocalRank: 0.125,- topic: {- can_edit: true,- title:- "Devils don't come from the hell beneath us, they come from the sky",- },- tuid: 97,- user_id: 83,- username: "lex",- },- ];-- const rankedList = reciprocallyRankedList(- [sourceA, sourceB, sourceC],- ["topic_id", "tid", "tuid"]- );-- assert.deepEqual(- rankedList,- desiredMixedResults,- "it correctly ranks the results using the reciprocal ranking algorithm"- );- });-});diff --git a/app/models/user.rb b/app/models/user.rbindex 6c27b09719f..ccb048f8a33 100644--- a/app/models/user.rb+++ b/app/models/user.rb@@ -1807,10 +1807,6 @@ class User < ActiveRecord::Basein_any_groups?(SiteSetting.experimental_new_new_view_groups_map)end- def experimental_search_menu_groups_enabled?- in_any_groups?(SiteSetting.experimental_search_menu_groups_map)- end-def watched_precedence_over_mutedif user_option.watched_precedence_over_muted.nil?SiteSetting.watched_precedence_over_muteddiff --git a/app/serializers/current_user_serializer.rb b/app/serializers/current_user_serializer.rbindex d012d70052d..7dea57562a7 100644--- a/app/serializers/current_user_serializer.rb+++ b/app/serializers/current_user_serializer.rb@@ -66,8 +66,7 @@ class CurrentUserSerializer < BasicUserSerializer:sidebar_tags,:sidebar_category_ids,:sidebar_sections,- :new_new_view_enabled?,- :experimental_search_menu_groups_enabled?+ :new_new_view_enabled?delegate :user_stat, to: :object, private: truedelegate :any_posts, :draft_count, :pending_posts_count, :read_faq?, to: :user_statdiff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex a6856ff2981..1885d5c984e 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -2490,7 +2490,6 @@ en:experimental_new_new_view_groups: 'EXPERIMENTAL: Enable a new topics list that combines unread and new topics and make the "Everything" link in the sidebar link to it.'enable_custom_sidebar_sections: "EXPERIMENTAL: Enable custom sidebar sections"experimental_topics_filter: "EXPERIMENTAL: Enables the experimental topics filter route at /filter"- experimental_search_menu_groups: "EXPERIMENTAL: Enables the new search menu that has been upgraded to use glimmer"enable_experimental_lightbox: "EXPERIMENTAL: Replace the default image lightbox with the revamped design."experimental_form_templates: "EXPERIMENTAL: Enable the form templates feature. <b>After enabled,</b> manage the templates at <a href='%{base_path}/admin/customize/form-templates'>Customize / Templates</a>."diff --git a/config/site_settings.yml b/config/site_settings.ymlindex 1f22b96a238..70373a058f6 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -2281,12 +2281,10 @@ developer:experimental_topics_filter:client: truedefault: false- experimental_search_menu_groups:- type: group_list- list_type: compact- default: ""- allow_any: false- refresh: true+ experimental_search_menu:+ client: true+ hidden: true+ default: truemax_sidebar_section_links:default: 50hidden: true@@ -2796,8 +2794,8 @@ uncategorized:hidden: truemax_api_invites:- default: 200- hidden: true+ default: 200+ hidden: trueoverridden_robots_txt:default: ""