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

This is done to avoid cases where search would be cancelled before debounce.
This commit is contained in:
Joffrey JAFFEUX 2020-08-19 09:57:40 +02:00 committed by GitHub
parent fcfaa8b063
commit 3e49c5b4d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 7 deletions

View File

@ -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([]);