DEV: Speed up composer autocomplete tests (#17461)

It was pausing for 1s after each keyup event.
This commit is contained in:
Jarek Radosz 2022-07-13 13:47:45 +02:00 committed by GitHub
parent 1dc2b3d1bb
commit 605aafec30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 6 deletions

View File

@ -10,6 +10,7 @@ import afterTransition from "discourse/lib/after-transition";
import discourseDebounce from "discourse-common/lib/debounce";
import { headerOffset } from "discourse/lib/offset-calculator";
import positioningWorkaround from "discourse/lib/safari-hacks";
import { isTesting } from "discourse-common/config/environment";
const START_DRAG_EVENTS = ["touchstart", "mousedown"];
const DRAG_EVENTS = ["touchmove", "mousemove"];
@ -62,12 +63,15 @@ export default Component.extend(KeyEnterEscape, {
// One second from now, check to see if the last key was hit when
// we recorded it. If it was, the user paused typing.
cancel(this._lastKeyTimeout);
this._lastKeyTimeout = later(() => {
this._lastKeyTimeout = later(
() => {
if (lastKeyUp !== this._lastKeyUp) {
return;
}
this.appEvents.trigger("composer:find-similar");
}, 1000);
},
isTesting() ? 50 : 1000
);
},
@observes("composeState")