Skip to content

A platform for community discussion. Free, open, simple.

DEV: Fix prosemirror/d-math test flakes (#40442)

Jarek Radoszc51a00ed0b26
diff --git a/frontend/discourse/app/static/prosemirror/lib/markdown-it.js b/frontend/discourse/app/static/prosemirror/lib/markdown-it.js
index 5a8f5dd5fc1..da7561c9000 100644
--- a/frontend/discourse/app/static/prosemirror/lib/markdown-it.js
+++ b/frontend/discourse/app/static/prosemirror/lib/markdown-it.js
@@ -8,6 +8,10 @@ function getEngine() {
return engine;
}
+export function resetEngine() {
+ engine = null;
+}
+
export const parse = (text) => getEngine().parse(text);
export const getLinkify = () => getEngine().linkify;
diff --git a/frontend/discourse/tests/helpers/qunit-helpers.js b/frontend/discourse/tests/helpers/qunit-helpers.js
index 96adde534bd..5f37b985feb 100644
--- a/frontend/discourse/tests/helpers/qunit-helpers.js
+++ b/frontend/discourse/tests/helpers/qunit-helpers.js
@@ -96,6 +96,7 @@ import {
clearExtraKeyboardShortcutHelp,
PLATFORM_KEY_MODIFIER,
} from "discourse/services/keyboard-shortcuts";
+import { resetEngine as resetProsemirrorEngine } from "discourse/static/prosemirror/lib/markdown-it";
import sessionFixtures from "discourse/tests/fixtures/session-fixtures";
import siteFixtures from "discourse/tests/fixtures/site-fixtures";
import {
@@ -257,6 +258,7 @@ export function testCleanup(container, app) {
resetLinkLookup();
resetModelTransformers();
resetMentions();
+ resetProsemirrorEngine();
cleanupTemporaryModuleRegistrations();
cleanupCssGeneratorTags();
resetBeforeAuthCompleteCallbacks();