Skip to content

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

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

Jarek Radoszfacf7d6f566c
diff --git a/app/assets/javascripts/discourse/app/models/login-method.js b/app/assets/javascripts/discourse/app/models/login-method.js
index bebb069b93d..113482d8e0c 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 d2c64d00826..115de3833cc 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);