FIX: do not cancel search early in tests (#10445)

FIX: do not cancel search early in tests (#10445)

This is done to avoid cases where search would be cancelled before debounce.

diff --git a/app/assets/javascripts/discourse/app/lib/user-search.js b/app/assets/javascripts/discourse/app/lib/user-search.js
index 05d1741..2c4af36 100644
--- a/app/assets/javascripts/discourse/app/lib/user-search.js
+++ b/app/assets/javascripts/discourse/app/lib/user-search.js
@@ -1,10 +1,10 @@
+import { isTesting } from "discourse-common/config/environment";
 import discourseDebounce from "discourse/lib/debounce";
 import { CANCELLED_STATUS } from "discourse/lib/autocomplete";
 import { userPath } from "discourse/lib/url";
 import { emailValid } from "discourse/lib/utilities";
 import { Promise } from "rsvp";
 import { later, cancel } from "@ember/runloop";
-import { isTesting } from "discourse-common/config/environment";
 
 var cache = {},
   cacheKey,
@@ -182,12 +182,10 @@ export default function userSearch(options) {
 
     cacheKey = newCacheKey;
 
-    const clearPromise = later(
-      () => {
-        resolve(CANCELLED_STATUS);
-      },
-      isTesting() ? 250 : 5000
-    );
+    let clearPromise;
+    if (!isTesting()) {
+      clearPromise = later(() => resolve(CANCELLED_STATUS), 5000);
+    }
 
     if (skipSearch(term, options.allowEmails)) {
       resolve([]);

GitHub sha: 3e49c5b4

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