mirror of
https://github.com/discourse/discourse.git
synced 2025-03-24 08:05:40 +08:00
FIX: Search does not retrigger when context has changed. Take 2.
https://meta.discourse.org/t/using-the-search-this-topic-check-box-blocks-search-on-other-pages/56832/6?u=tgxworld
This commit is contained in:
parent
f5fe58384f
commit
658b55c406
@ -182,7 +182,6 @@ export default createWidget("search-menu", {
|
||||
},
|
||||
|
||||
html(attrs) {
|
||||
searchData.contextEnabled = attrs.contextEnabled;
|
||||
const searchContext = this.searchContext();
|
||||
|
||||
const shouldTriggerSearch =
|
||||
|
@ -1,5 +1,21 @@
|
||||
import { acceptance, logIn } from "helpers/qunit-helpers";
|
||||
acceptance("Search");
|
||||
import { fixturesByUrl } from "helpers/create-pretender";
|
||||
|
||||
const emptySearchContextCallbacks = [];
|
||||
|
||||
acceptance("Search", {
|
||||
pretend(server, helper) {
|
||||
server.get("/search/query", request => {
|
||||
if (request.queryParams["search_context[type]"] === undefined) {
|
||||
emptySearchContextCallbacks.forEach(callback => {
|
||||
callback.call();
|
||||
});
|
||||
}
|
||||
|
||||
return helper.response(fixturesByUrl["search/query.json"]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("search", async assert => {
|
||||
await visit("/");
|
||||
@ -73,10 +89,17 @@ QUnit.test("Search with context", async assert => {
|
||||
"it should highlight the search term"
|
||||
);
|
||||
|
||||
let callbackCalled = false;
|
||||
|
||||
emptySearchContextCallbacks.push(() => {
|
||||
callbackCalled = true;
|
||||
});
|
||||
|
||||
await visit("/");
|
||||
await click("#search-button");
|
||||
|
||||
assert.ok(!exists(".search-context input[type='checkbox']"));
|
||||
assert.ok(callbackCalled, "it triggers a new search");
|
||||
|
||||
await visit("/t/internationalization-localization/280/1");
|
||||
await click("#search-button");
|
||||
|
@ -819,7 +819,7 @@ export default {
|
||||
]
|
||||
}
|
||||
},
|
||||
"search/query": {
|
||||
"search/query.json": {
|
||||
posts: [
|
||||
{
|
||||
id: 3833,
|
||||
|
@ -33,14 +33,14 @@ export function success() {
|
||||
}
|
||||
|
||||
const loggedIn = () => !!Discourse.User.current();
|
||||
|
||||
const helpers = { response, success, parsePostData };
|
||||
export let fixturesByUrl;
|
||||
|
||||
export default function() {
|
||||
const server = new Pretender(function() {
|
||||
storePretender.call(this, helpers);
|
||||
flagPretender.call(this, helpers);
|
||||
const fixturesByUrl = fixturePretender.call(this, helpers);
|
||||
fixturesByUrl = fixturePretender.call(this, helpers);
|
||||
|
||||
this.get("/admin/plugins", () => response({ plugins: [] }));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user