DEV: resets user search cache between tests (#13873)

The current behaviour was producing random tests failures which where consistently reproducible using `seed=32037592518471299633729129648744282271`

The cause of this error, is a previous test not giving any topicId or categoryId resulting in a cache key "undefined-undefined", just like a possibly previous test. Reseting cache between tests, seems the most straightforward and future proof solution
This commit is contained in:
Joffrey JAFFEUX 2021-07-28 15:32:49 +02:00 committed by GitHub
parent 2818ebd19f
commit b673fee946
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -12,6 +12,14 @@ let cache = {},
currentTerm,
oldSearch;
export function resetUserSearchCache() {
cache = {};
cacheKey = null;
cacheTime = null;
currentTerm = null;
oldSearch = null;
}
function performSearch(
term,
topicId,

View File

@ -34,6 +34,7 @@ import { resetDecorators as resetPostCookedDecorators } from "discourse/widgets/
import { resetTopicTitleDecorators } from "discourse/components/topic-title";
import { resetUsernameDecorators } from "discourse/helpers/decorate-username-selector";
import { resetWidgetCleanCallbacks } from "discourse/components/mount-widget";
import { resetUserSearchCache } from "discourse/lib/user-search";
import sessionFixtures from "discourse/tests/fixtures/session-fixtures";
import { setTopicList } from "discourse/lib/topic-list-tracker";
import sinon from "sinon";
@ -272,6 +273,7 @@ export function acceptance(name, optionsOrCallback) {
resetUsernameDecorators();
resetOneboxCache();
resetCustomPostMessageCallbacks();
resetUserSearchCache();
clearCustomNavItemHref();
setTopicList(null);
_clearSnapshots();