Sped up tests by reducing reset button timeout whilst testing

no issue

- tests will wait for everything to settle before continuing or ending so the 2.5sec timeout on task button resets was adding a lot of extra time
- use Ember's environment to see if we're testing and reduce the reset timeout from 2500ms to 50ms
This commit is contained in:
Kevin Ansfield 2020-04-23 20:20:19 +01:00
parent 9074181461
commit 837753e225

View File

@ -1,4 +1,5 @@
import Component from '@ember/component';
import config from 'ghost-admin/config/environment';
import {computed} from '@ember/object';
import {isBlank} from '@ember/utils';
import {reads} from '@ember/object/computed';
@ -40,6 +41,8 @@ const GhTaskButton = Component.extend({
failureText: 'Retry',
failureClass: 'gh-btn-red',
isTesting: undefined,
// Allowed actions
action: () => {},
@ -101,6 +104,9 @@ const GhTaskButton = Component.extend({
init() {
this._super(...arguments);
this._initialPerformCount = this.get('task.performCount');
if (this.isTesting === undefined) {
this.isTesting = config.environment === 'test';
}
},
click() {
@ -167,7 +173,7 @@ const GhTaskButton = Component.extend({
}),
_resetButtonState: task(function* () {
yield timeout(2500);
yield timeout(this.isTesting ? 50 : 2500);
if (!this.get('task.last.isRunning')) {
// Reset last task to bring button back to idle state
yield this.set('task.last', null);