DEV: Add cleanup methods for composer extension hooks that tests can use (#13034)

DEV: Add cleanup methods for composer extension hooks that tests can use (#13034)

diff --git a/app/assets/javascripts/discourse/app/components/composer-editor.js b/app/assets/javascripts/discourse/app/components/composer-editor.js
index 84b6c13..c1be68e 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 826b5f2..7a28a0b 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);

GitHub sha: 63ca9e06

This commit appears in #13034 which was approved by eviltrout. It was merged by Falco.