DEV: Don't leak auth methods between tests (#14708)

DEV: Don’t leak auth methods between tests (#14708)

diff --git a/app/assets/javascripts/discourse/app/models/login-method.js b/app/assets/javascripts/discourse/app/models/login-method.js
index bebb069..113482d 100644
--- a/app/assets/javascripts/discourse/app/models/login-method.js
+++ b/app/assets/javascripts/discourse/app/models/login-method.js
@@ -85,10 +85,8 @@ export function findAll() {
     return methods;
   }
 
-  methods = [];
-
-  Site.currentProp("auth_providers").forEach((provider) =>
-    methods.pushObject(LoginMethod.create(provider))
+  methods = Site.currentProp("auth_providers").map((provider) =>
+    LoginMethod.create(provider)
   );
 
   // exclude FA icon for Google, uses custom SVG
@@ -97,4 +95,8 @@ export function findAll() {
   return methods;
 }
 
+export function clearAuthMethods() {
+  methods = undefined;
+}
+
 export default LoginMethod;
diff --git a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
index d2c64d0..115de38 100644
--- a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
+++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
@@ -52,6 +52,7 @@ import {
   cleanUpComposerUploadProcessor,
 } from "discourse/components/composer-editor";
 import { resetLastEditNotificationClick } from "discourse/models/post-stream";
+import { clearAuthMethods } from "discourse/models/login-method";
 
 const LEGACY_ENV = !setupApplicationTest;
 
@@ -295,6 +296,8 @@ export function acceptance(name, optionsOrCallback) {
       cleanUpComposerUploadMarkdownResolver();
       cleanUpComposerUploadPreProcessor();
       resetLastEditNotificationClick();
+      clearAuthMethods();
+
       app._runInitializer("instanceInitializers", (initName, initializer) => {
         if (initializer && initializer.teardown) {
           initializer.teardown(this.container);

GitHub sha: facf7d6f566cac9fca921008dd15f35cedfbad77

This commit appears in #14708 which was approved by davidtaylorhq. It was merged by CvX.