fix tests, crsf token meta is not present on tests (#7733)

fix tests, crsf token meta is not present on tests (#7733)

diff --git a/app/assets/javascripts/discourse/initializers/csrf-token.js.es6 b/app/assets/javascripts/discourse/initializers/csrf-token.js.es6
index b76a8b7..34839a4 100644
--- a/app/assets/javascripts/discourse/initializers/csrf-token.js.es6
+++ b/app/assets/javascripts/discourse/initializers/csrf-token.js.es6
@@ -4,18 +4,19 @@ export default {
 
   initialize(container) {
     const session = container.lookup("session:main");
+    const meta = document.querySelector("meta[name=csrf-token]");
 
-    const csrfToken = document
-      .querySelector("meta[name=csrf-token]")
-      .getAttribute("content");
+    if (meta) {
+      const csrfToken = meta.getAttribute("content");
 
-    // Add a CSRF token to all AJAX requests
-    session.set("csrfToken", csrfToken);
+      // Add a CSRF token to all AJAX requests
+      session.set("csrfToken", csrfToken);
 
-    $.ajaxPrefilter((options, originalOptions, xhr) => {
-      if (!options.crossDomain) {
-        xhr.setRequestHeader("X-CSRF-Token", csrfToken);
-      }
-    });
+      $.ajaxPrefilter((options, originalOptions, xhr) => {
+        if (!options.crossDomain) {
+          xhr.setRequestHeader("X-CSRF-Token", csrfToken);
+        }
+      });
+    }
   }
 };

GitHub sha: 240b61e8

Revert "fix tests, crsf token meta is not present on tests (#7733)"