FIX: Render 'In topic context' search results at the correct time (#23481)
This commit is contained in:
parent
22747e26fd
commit
daf8c32d0e
|
@ -9,6 +9,7 @@
|
||||||
@slug={{@slug}}
|
@slug={{@slug}}
|
||||||
@withInLabel={{@withInLabel}}
|
@withInLabel={{@withInLabel}}
|
||||||
@isIntersection={{true}}
|
@isIntersection={{true}}
|
||||||
|
@searchAllTopics={{true}}
|
||||||
@closeSearchMenu={{@closeSearchMenu}}
|
@closeSearchMenu={{@closeSearchMenu}}
|
||||||
@searchTermChanged={{@searchTermChanged}}
|
@searchTermChanged={{@searchTermChanged}}
|
||||||
@suggestionKeyword={{@suggestionKeyword}}
|
@suggestionKeyword={{@suggestionKeyword}}
|
||||||
|
@ -17,19 +18,23 @@
|
||||||
{{else if (eq this.suggestionType "categoryOrTag")}}
|
{{else if (eq this.suggestionType "categoryOrTag")}}
|
||||||
{{#each @results as |result|}}
|
{{#each @results as |result|}}
|
||||||
{{#if result.model}}
|
{{#if result.model}}
|
||||||
|
{{! render category }}
|
||||||
<SearchMenu::Results::AssistantItem
|
<SearchMenu::Results::AssistantItem
|
||||||
@category={{result.model}}
|
@category={{result.model}}
|
||||||
@slug={{get this.fullSlugForCategoryMap result.model.id}}
|
@slug={{get this.fullSlugForCategoryMap result.model.id}}
|
||||||
@withInLabel={{@withInLabel}}
|
@withInLabel={{@withInLabel}}
|
||||||
|
@searchAllTopics={{true}}
|
||||||
@closeSearchMenu={{@closeSearchMenu}}
|
@closeSearchMenu={{@closeSearchMenu}}
|
||||||
@searchTermChanged={{@searchTermChanged}}
|
@searchTermChanged={{@searchTermChanged}}
|
||||||
@suggestionKeyword={{@suggestionKeyword}}
|
@suggestionKeyword={{@suggestionKeyword}}
|
||||||
/>
|
/>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
{{! render tag }}
|
||||||
<SearchMenu::Results::AssistantItem
|
<SearchMenu::Results::AssistantItem
|
||||||
@tag={{result.name}}
|
@tag={{result.name}}
|
||||||
@slug={{concat this.prefix "#" result.name}}
|
@slug={{concat this.prefix "#" result.name}}
|
||||||
@withInLabel={{@withInLabel}}
|
@withInLabel={{@withInLabel}}
|
||||||
|
@searchAllTopics={{true}}
|
||||||
@closeSearchMenu={{@closeSearchMenu}}
|
@closeSearchMenu={{@closeSearchMenu}}
|
||||||
@searchTermChanged={{@searchTermChanged}}
|
@searchTermChanged={{@searchTermChanged}}
|
||||||
@suggestionKeyword={{@suggestionKeyword}}
|
@suggestionKeyword={{@suggestionKeyword}}
|
||||||
|
@ -43,6 +48,7 @@
|
||||||
@user={{this.user}}
|
@user={{this.user}}
|
||||||
@slug={{concat this.prefix "@" this.user.username}}
|
@slug={{concat this.prefix "@" this.user.username}}
|
||||||
@suffix={{i18n "search.in_topics_posts"}}
|
@suffix={{i18n "search.in_topics_posts"}}
|
||||||
|
@searchAllTopics={{true}}
|
||||||
@closeSearchMenu={{@closeSearchMenu}}
|
@closeSearchMenu={{@closeSearchMenu}}
|
||||||
@searchTermChanged={{@searchTermChanged}}
|
@searchTermChanged={{@searchTermChanged}}
|
||||||
@suggestionKeyword={{@suggestionKeyword}}
|
@suggestionKeyword={{@suggestionKeyword}}
|
||||||
|
@ -61,6 +67,7 @@
|
||||||
<SearchMenu::Results::AssistantItem
|
<SearchMenu::Results::AssistantItem
|
||||||
@user={{result}}
|
@user={{result}}
|
||||||
@slug={{concat this.prefix "@" result.username}}
|
@slug={{concat this.prefix "@" result.username}}
|
||||||
|
@searchAllTopics={{true}}
|
||||||
@closeSearchMenu={{@closeSearchMenu}}
|
@closeSearchMenu={{@closeSearchMenu}}
|
||||||
@searchTermChanged={{@searchTermChanged}}
|
@searchTermChanged={{@searchTermChanged}}
|
||||||
@suggestionKeyword={{@suggestionKeyword}}
|
@suggestionKeyword={{@suggestionKeyword}}
|
||||||
|
@ -72,6 +79,7 @@
|
||||||
<SearchMenu::Results::AssistantItem
|
<SearchMenu::Results::AssistantItem
|
||||||
@slug={{concat this.prefix item}}
|
@slug={{concat this.prefix item}}
|
||||||
@label={{item}}
|
@label={{item}}
|
||||||
|
@searchAllTopics={{true}}
|
||||||
@closeSearchMenu={{@closeSearchMenu}}
|
@closeSearchMenu={{@closeSearchMenu}}
|
||||||
@searchTermChanged={{@searchTermChanged}}
|
@searchTermChanged={{@searchTermChanged}}
|
||||||
@suggestionKeyword={{@suggestionKeyword}}
|
@suggestionKeyword={{@suggestionKeyword}}
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<SearchMenu::Results::RandomQuickTip />
|
<SearchMenu::Results::RandomQuickTip />
|
||||||
|
|
||||||
{{#if (and this.currentUser this.siteSettings.log_search_queries)}}
|
{{#if (and this.currentUser this.siteSettings.log_search_queries)}}
|
||||||
<SearchMenu::Results::RecentSearches
|
<SearchMenu::Results::RecentSearches
|
||||||
@closeSearchMenu={{@closeSearchMenu}}
|
@closeSearchMenu={{@closeSearchMenu}}
|
||||||
|
|
|
@ -653,6 +653,48 @@ acceptance("Search - Glimmer - with tagging enabled", function (needs) {
|
||||||
experimental_search_menu_groups_enabled: true,
|
experimental_search_menu_groups_enabled: true,
|
||||||
});
|
});
|
||||||
needs.settings({ tagging_enabled: true });
|
needs.settings({ tagging_enabled: true });
|
||||||
|
needs.pretender((server, helper) => {
|
||||||
|
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: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test("topic results - displays tags", async function (assert) {
|
test("topic results - displays tags", async function (assert) {
|
||||||
await visit("/");
|
await visit("/");
|
||||||
|
@ -669,6 +711,18 @@ acceptance("Search - Glimmer - with tagging enabled", function (needs) {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("initial options - topic search scope - selecting a tag defaults to searching 'in all topics'", async function (assert) {
|
||||||
|
await visit("/t/internationalization-localization/280/1");
|
||||||
|
await click("#search-button");
|
||||||
|
await fillIn("#search-term", "#dev");
|
||||||
|
await click(
|
||||||
|
".search-menu .results .search-menu-assistant .search-menu-assistant-item:nth-child(1)"
|
||||||
|
);
|
||||||
|
assert
|
||||||
|
.dom(".search-input .btn.search-context")
|
||||||
|
.doesNotExist("'in this topic' button is not shown");
|
||||||
|
});
|
||||||
|
|
||||||
test("initial results - displays tag shortcuts", async function (assert) {
|
test("initial results - displays tag shortcuts", async function (assert) {
|
||||||
await visit("/");
|
await visit("/");
|
||||||
await click("#search-button");
|
await click("#search-button");
|
||||||
|
@ -681,6 +735,85 @@ acceptance("Search - Glimmer - with tagging enabled", function (needs) {
|
||||||
const firstTag = query(`${firstItem} .search-item-tag`).textContent.trim();
|
const firstTag = query(`${firstItem} .search-item-tag`).textContent.trim();
|
||||||
assert.strictEqual(firstTag, "monkey");
|
assert.strictEqual(firstTag, "monkey");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("initial options - tag search scope - 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 .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("initial options - tag and category search scope - 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 .category-name")
|
||||||
|
.innerText,
|
||||||
|
"bug"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
query(".search-menu .results ul.search-menu-assistant .search-item-tag")
|
||||||
|
.innerText,
|
||||||
|
"dev",
|
||||||
|
"Tag is displayed"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("initial options - tag intersection search scope - 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("initial options - tag intersection search scope - 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"
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
acceptance("Search - Glimmer - assistant", function (needs) {
|
acceptance("Search - Glimmer - assistant", function (needs) {
|
||||||
|
@ -830,47 +963,6 @@ acceptance("Search - Glimmer - assistant", function (needs) {
|
||||||
return helper.response(searchFixtures["search/query"]);
|
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", () => {
|
server.get("/u/search/users", () => {
|
||||||
return helper.response({
|
return helper.response({
|
||||||
users: [
|
users: [
|
||||||
|
@ -910,85 +1002,6 @@ acceptance("Search - Glimmer - assistant", function (needs) {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("initial options - tag search scope - 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 .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("initial options - tag and category search scope - 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 .category-name")
|
|
||||||
.innerText,
|
|
||||||
"bug"
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.strictEqual(
|
|
||||||
query(".search-menu .results ul.search-menu-assistant .search-item-tag")
|
|
||||||
.innerText,
|
|
||||||
"dev",
|
|
||||||
"Tag is displayed"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("initial options - tag intersection search scope - 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("initial options - tag intersection search scope - 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("initial options - shows in: shortcuts", async function (assert) {
|
test("initial options - shows in: shortcuts", async function (assert) {
|
||||||
await visit("/");
|
await visit("/");
|
||||||
await click("#search-button");
|
await click("#search-button");
|
||||||
|
@ -1032,6 +1045,19 @@ acceptance("Search - Glimmer - assistant", function (needs) {
|
||||||
assert.strictEqual(query("#search-term").value, `@${firstUsername}`);
|
assert.strictEqual(query("#search-term").value, `@${firstUsername}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("initial options - topic search scope - selecting a tag defaults to searching 'in all topics'", async function (assert) {
|
||||||
|
await visit("/t/internationalization-localization/280/1");
|
||||||
|
await click("#search-button");
|
||||||
|
await fillIn("#search-term", "@");
|
||||||
|
await click(
|
||||||
|
".search-menu .results .search-menu-assistant .search-menu-assistant-item:nth-child(1)"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert
|
||||||
|
.dom(".search-input .btn.search-context")
|
||||||
|
.doesNotExist("'in this topic' button is not shown");
|
||||||
|
});
|
||||||
|
|
||||||
test("initial options - private message search scope - shows 'in messages' button when in an inbox", async function (assert) {
|
test("initial options - private message search scope - shows 'in messages' button when in an inbox", async function (assert) {
|
||||||
await visit("/u/charlie/messages");
|
await visit("/u/charlie/messages");
|
||||||
await click("#search-button");
|
await click("#search-button");
|
||||||
|
|
Loading…
Reference in New Issue