From 3e49c5b4d875654f3357583828086fe8fee104be Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 19 Aug 2020 09:57:40 +0200 Subject: [PATCH] FIX: do not cancel search early in tests (#10445) This is done to avoid cases where search would be cancelled before debounce. --- .../javascripts/discourse/app/lib/user-search.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/discourse/app/lib/user-search.js b/app/assets/javascripts/discourse/app/lib/user-search.js index 05d1741761b..2c4af363017 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([]);