mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06:00
FIX: Keep topic context when redirecting to full search (#14846)
This commit is contained in:
parent
7fb693c8f6
commit
e90f506bf8
@ -204,6 +204,12 @@ export default createWidget("search-menu", {
|
|||||||
|
|
||||||
query += `q=${encodeURIComponent(searchData.term)}`;
|
query += `q=${encodeURIComponent(searchData.term)}`;
|
||||||
|
|
||||||
|
const searchContext = this.searchContext();
|
||||||
|
|
||||||
|
if (searchContext?.type === "topic") {
|
||||||
|
query += encodeURIComponent(` topic:${searchContext.id}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (query) {
|
if (query) {
|
||||||
params.push(query);
|
params.push(query);
|
||||||
}
|
}
|
||||||
|
@ -243,6 +243,44 @@ acceptance("Search - Anonymous", function (needs) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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 firstResult =
|
||||||
|
".search-menu .results .search-menu-assistant-item:first-child";
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
query(firstResult).textContent.trim(),
|
||||||
|
I18n.t("search.in_this_topic"),
|
||||||
|
"contenxtual topic search is first available option"
|
||||||
|
);
|
||||||
|
|
||||||
|
await fillIn("#search-term", "proper");
|
||||||
|
await focus("input#search-term");
|
||||||
|
await triggerKeyEvent(".search-menu", "keydown", 40);
|
||||||
|
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) {
|
test("topic search scope - special case when matching a single user", async function (assert) {
|
||||||
await visit("/t/internationalization-localization/280/1");
|
await visit("/t/internationalization-localization/280/1");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user