DEV: Clear NavItem.customNavItemHrefs between tests (#13025)

Identical callbacks can pile up during tests and cause all sort of weird problems that are difficult to debug. This commit clears registered callbacks after each test.
This commit is contained in:
Osama Sayegh 2021-05-11 12:54:37 +03:00 committed by GitHub
parent a7a2887df0
commit 9ec5f39764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -301,6 +301,10 @@ export function customNavItemHref(cb) {
NavItem.customNavItemHrefs.push(cb);
}
export function clearCustomNavItemHref() {
NavItem.customNavItemHrefs.clear();
}
export function addNavItem(item) {
NavItem.extraNavItemDescriptors.push(item);
}

View File

@ -39,6 +39,7 @@ import { setTopicList } from "discourse/lib/topic-list-tracker";
import sinon from "sinon";
import siteFixtures from "discourse/tests/fixtures/site-fixtures";
import { clearResolverOptions } from "discourse-common/resolver";
import { clearCustomNavItemHref } from "discourse/models/nav-item";
const LEGACY_ENV = !setupApplicationTest;
@ -260,6 +261,7 @@ export function acceptance(name, optionsOrCallback) {
resetUsernameDecorators();
resetOneboxCache();
resetCustomPostMessageCallbacks();
clearCustomNavItemHref();
setTopicList(null);
_clearSnapshots();
setURLContainer(null);