mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 19:53:53 -06:00
Fix randomly failing JS acceptance tests.
This commit is contained in:
parent
7aa56fc9d9
commit
87c334c063
@ -3,14 +3,18 @@ import { createWidget } from 'discourse/widgets/widget';
|
||||
import { h } from 'virtual-dom';
|
||||
import DiscourseURL from 'discourse/lib/url';
|
||||
|
||||
const searchData = {
|
||||
loading: false,
|
||||
results: {},
|
||||
noResults: false,
|
||||
term: undefined,
|
||||
typeFilter: null,
|
||||
invalidTerm: false
|
||||
};
|
||||
const searchData = {};
|
||||
|
||||
export function initSearchData() {
|
||||
searchData.loading = false;
|
||||
searchData.results = {};
|
||||
searchData.noResults = false;
|
||||
searchData.term = undefined;
|
||||
searchData.typeFilter = null;
|
||||
searchData.invalidTerm = false;
|
||||
}
|
||||
|
||||
initSearchData();
|
||||
|
||||
// Helps with debouncing and cancelling promises
|
||||
const SearchHelper = {
|
||||
@ -161,7 +165,7 @@ export default createWidget('search-menu', {
|
||||
html(attrs) {
|
||||
if (searchData.contextEnabled !== attrs.contextEnabled) {
|
||||
searchData.contextEnabled = attrs.contextEnabled;
|
||||
this.triggerSearch();
|
||||
if (searchData.term) this.triggerSearch();
|
||||
} else {
|
||||
searchData.contextEnabled = attrs.contextEnabled;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import { clearCache as clearOutletCache, resetExtraClasses } from 'discourse/lib
|
||||
import { clearHTMLCache } from 'discourse/helpers/custom-html';
|
||||
import { flushMap } from 'discourse/models/store';
|
||||
import { clearRewrites } from 'discourse/lib/url';
|
||||
import { initSearchData } from 'discourse/widgets/search-menu';
|
||||
|
||||
export function currentUser() {
|
||||
return Discourse.User.create(sessionFixtures['/session/current.json'].current_user);
|
||||
@ -97,6 +98,7 @@ export function acceptance(name, options) {
|
||||
clearHTMLCache();
|
||||
resetPluginApi();
|
||||
clearRewrites();
|
||||
initSearchData();
|
||||
Discourse.reset();
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user