diff --git a/app/assets/javascripts/discourse/app/components/composer-editor.js b/app/assets/javascripts/discourse/app/components/composer-editor.js index 84b6c137194..c1be68eda59 100644 --- a/app/assets/javascripts/discourse/app/components/composer-editor.js +++ b/app/assets/javascripts/discourse/app/components/composer-editor.js @@ -45,25 +45,35 @@ import userSearch from "discourse/lib/user-search"; const REBUILD_SCROLL_MAP_EVENTS = ["composer:resized", "composer:typed-reply"]; -const uploadHandlers = []; +let uploadHandlers = []; export function addComposerUploadHandler(extensions, method) { uploadHandlers.push({ extensions, method, }); } +export function cleanUpComposerUploadHandler() { + uploadHandlers = []; +} -const uploadProcessorQueue = []; -const uploadProcessorActions = {}; +let uploadProcessorQueue = []; +let uploadProcessorActions = {}; export function addComposerUploadProcessor(queueItem, actionItem) { uploadProcessorQueue.push(queueItem); Object.assign(uploadProcessorActions, actionItem); } +export function cleanUpComposerUploadProcessor() { + uploadProcessorQueue = []; + uploadProcessorActions = {}; +} -const uploadMarkdownResolvers = []; +let uploadMarkdownResolvers = []; export function addComposerUploadMarkdownResolver(resolver) { uploadMarkdownResolvers.push(resolver); } +export function cleanUpComposerUploadMarkdownResolver() { + uploadMarkdownResolvers = []; +} export default Component.extend({ classNameBindings: ["showToolbar:toolbar-visible", ":wmd-controls"], diff --git a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js index 826b5f24cd5..7a28a0b6845 100644 --- a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js +++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js @@ -40,6 +40,11 @@ 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"; +import { + cleanUpComposerUploadHandler, + cleanUpComposerUploadMarkdownResolver, + cleanUpComposerUploadProcessor, +} from "discourse/components/composer-editor"; const LEGACY_ENV = !setupApplicationTest; @@ -266,6 +271,9 @@ export function acceptance(name, optionsOrCallback) { _clearSnapshots(); setURLContainer(null); setDefaultOwner(null); + cleanUpComposerUploadHandler(); + cleanUpComposerUploadProcessor(); + cleanUpComposerUploadMarkdownResolver(); app._runInitializer("instanceInitializers", (initName, initializer) => { if (initializer && initializer.teardown) { initializer.teardown(this.container);