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

This commit is contained in:
Rafael dos Santos Silva 2021-05-11 17:29:24 -03:00 committed by GitHub
parent 21c301aa72
commit 63ca9e0650
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 4 deletions

View File

@ -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"],

View File

@ -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);