mirror of
https://github.com/discourse/discourse.git
synced 2026-08-10 04:58:31 -05:00
DEV: resets post menu extra buttons between tests (#13939)
This ensures we do not leak buttons in acceptance tests
This commit is contained in:
@@ -3,7 +3,11 @@ import ComposerEditor, {
|
||||
addComposerUploadMarkdownResolver,
|
||||
addComposerUploadProcessor,
|
||||
} from "discourse/components/composer-editor";
|
||||
import { addButton, removeButton } from "discourse/widgets/post-menu";
|
||||
import {
|
||||
addButton,
|
||||
apiExtraButtons,
|
||||
removeButton,
|
||||
} from "discourse/widgets/post-menu";
|
||||
import {
|
||||
addExtraIconRenderer,
|
||||
replaceCategoryLinkRenderer,
|
||||
@@ -428,6 +432,7 @@ class PluginApi {
|
||||
* ```
|
||||
**/
|
||||
addPostMenuButton(name, callback) {
|
||||
apiExtraButtons[name] = callback;
|
||||
addButton(name, callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,11 +36,20 @@ function animateHeart($elem, start, end, complete) {
|
||||
|
||||
const _builders = {};
|
||||
const _extraButtons = {};
|
||||
export let apiExtraButtons = {};
|
||||
|
||||
export function addButton(name, builder) {
|
||||
_extraButtons[name] = builder;
|
||||
}
|
||||
|
||||
export function resetPostMenuExtraButtons() {
|
||||
Object.keys(apiExtraButtons).forEach((button) => {
|
||||
removeButton(button);
|
||||
});
|
||||
|
||||
apiExtraButtons = {};
|
||||
}
|
||||
|
||||
export function removeButton(name) {
|
||||
if (_extraButtons[name]) {
|
||||
delete _extraButtons[name];
|
||||
|
||||
@@ -24,6 +24,7 @@ import createStore from "discourse/tests/helpers/create-store";
|
||||
import deprecated from "discourse-common/lib/deprecated";
|
||||
import { flushMap } from "discourse/models/store";
|
||||
import { initSearchData } from "discourse/widgets/search-menu";
|
||||
import { resetPostMenuExtraButtons } from "discourse/widgets/post-menu";
|
||||
import { isEmpty } from "@ember/utils";
|
||||
import { mapRoutes } from "discourse/mapping-router";
|
||||
import { resetCustomPostMessageCallbacks } from "discourse/controllers/topic";
|
||||
@@ -275,6 +276,7 @@ export function acceptance(name, optionsOrCallback) {
|
||||
resetOneboxCache();
|
||||
resetCustomPostMessageCallbacks();
|
||||
resetUserSearchCache();
|
||||
resetPostMenuExtraButtons();
|
||||
clearNavItems();
|
||||
setTopicList(null);
|
||||
_clearSnapshots();
|
||||
|
||||
Reference in New Issue
Block a user