Skip to content

A platform for community discussion. Free, open, simple.

Reset widget decorators after each test

Gerhard Schlager243ee565dcfb
diff --git a/app/assets/javascripts/discourse/widgets/widget.js.es6 b/app/assets/javascripts/discourse/widgets/widget.js.es6
index e81123c8ade..9349e4aba5b 100644
--- a/app/assets/javascripts/discourse/widgets/widget.js.es6
+++ b/app/assets/javascripts/discourse/widgets/widget.js.es6
@@ -32,6 +32,10 @@ export function applyDecorators(widget, type, attrs, state) {
return [];
}
+export function resetDecorators() {
+ Object.keys(_decorators).forEach(key => delete _decorators[key]);
+}
+
const _customSettings = {};
export function changeSetting(widgetName, settingName, newValue) {
_customSettings[widgetName] = _customSettings[widgetName] || {};
diff --git a/test/javascripts/helpers/qunit-helpers.js.es6 b/test/javascripts/helpers/qunit-helpers.js.es6
index 4a12fc22396..3e5125ad9a4 100644
--- a/test/javascripts/helpers/qunit-helpers.js.es6
+++ b/test/javascripts/helpers/qunit-helpers.js.es6
@@ -9,6 +9,7 @@ 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';
+import { resetDecorators } from 'discourse/widgets/widget';
export function currentUser() {
return Discourse.User.create(sessionFixtures['/session/current.json'].current_user);
@@ -99,6 +100,7 @@ export function acceptance(name, options) {
resetPluginApi();
clearRewrites();
initSearchData();
+ resetDecorators();
Discourse.reset();
}
});