From 39c35ee47d9fa244dccfb4ac92622dd778fa168d Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Sat, 16 Jul 2022 23:24:13 +0200 Subject: [PATCH] DEV: Clear tagsHtmlCallbacks after each test (#17530) Fixes leakage between tests --- app/assets/javascripts/discourse/app/lib/render-tags.js | 5 +++++ .../javascripts/discourse/tests/helpers/qunit-helpers.js | 2 ++ 2 files changed, 7 insertions(+) diff --git a/app/assets/javascripts/discourse/app/lib/render-tags.js b/app/assets/javascripts/discourse/app/lib/render-tags.js index d4aebe57edc..6f8aedf9e9f 100644 --- a/app/assets/javascripts/discourse/app/lib/render-tags.js +++ b/app/assets/javascripts/discourse/app/lib/render-tags.js @@ -17,6 +17,11 @@ export function addTagsHtmlCallback(callback, options) { callbacks.splice(i, 0, callback); } +export function clearTagsHtmlCallbacks() { + callbacks = null; + priorities = null; +} + export default function (topic, params) { let tags = topic.tags; let buffer = ""; diff --git a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js index a7b2cb44568..975e67078ed 100644 --- a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js +++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js @@ -69,6 +69,7 @@ import { clearTagDecorateCallbacks, clearTextDecorateCallbacks, } from "discourse/lib/to-markdown"; +import { clearTagsHtmlCallbacks } from "discourse/lib/render-tags"; import { clearToolbarCallbacks } from "discourse/components/d-editor"; export function currentUser() { @@ -194,6 +195,7 @@ export function testCleanup(container, app) { clearTextDecorateCallbacks(); clearResolverOptions(); clearLegacyResolverOptions(); + clearTagsHtmlCallbacks(); clearToolbarCallbacks(); }