DEV: sticky avatar was retained during tests (#14969)

DEV: sticky avatar was retained during tests (#14969)

diff --git a/app/assets/javascripts/discourse/app/initializers/sticky-avatars.js b/app/assets/javascripts/discourse/app/initializers/sticky-avatars.js
index 401a831..2fa8c87 100644
--- a/app/assets/javascripts/discourse/app/initializers/sticky-avatars.js
+++ b/app/assets/javascripts/discourse/app/initializers/sticky-avatars.js
@@ -5,6 +5,10 @@ export default {
   after: "inject-objects",
 
   initialize(container) {
-    StickyAvatars.init(container);
+    this._stickyAvatars = StickyAvatars.init(container);
+  },
+
+  teardown() {
+    this._stickyAvatars?.destroy();
   },
 };
diff --git a/app/assets/javascripts/discourse/app/lib/sticky-avatars.js b/app/assets/javascripts/discourse/app/lib/sticky-avatars.js
index 31f03da..4b39516 100644
--- a/app/assets/javascripts/discourse/app/lib/sticky-avatars.js
+++ b/app/assets/javascripts/discourse/app/lib/sticky-avatars.js
@@ -11,7 +11,7 @@ export default class StickyAvatars {
   prevOffset = -1;
 
   static init(container) {
-    new this(container).init();
+    return new this(container).init();
   }
 
   constructor(container) {
@@ -29,6 +29,12 @@ export default class StickyAvatars {
     appEvents.on("page:topic-loaded", this._initIntersectionObserver);
 
     addWidgetCleanCallback("post-stream", this._clearIntersectionObserver);
+
+    return this;
+  }
+
+  destroy() {
+    this.container = null;
   }
 
   @bind

GitHub sha: 035822d9e04b6c898fb3029c91df5a3db307f1ce

This commit appears in #14969 which was merged by jjaffeux.