DEV: Add cleanup methods for composer extension hooks that tests can use (#13034)
This commit is contained in:
parent
21c301aa72
commit
63ca9e0650
|
@ -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"],
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue