Skip to content

Commit

Permalink
fix timeouts in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Nov 13, 2024
1 parent fa3e6a2 commit e4a6fee
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@ember/jquery": "^1.1.0",
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "^2.4.2",
"@embroider/macros": "^1.16.9",
"@embroider/test-setup": "^0.43.5",
"@faker-js/faker": "^9.0.3",
"@glimmer/component": "^1.0.4",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 14 additions & 8 deletions tests/dummy/app/controllers/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { inject as service } from '@ember/service';
import { faker } from '@faker-js/faker';
import { tracked } from '@glimmer/tracking';
import { buildGridModel } from '../utils/grid-list';
import { isTesting } from '@embroider/macros';

export default class CatalogController extends Controller {
// Autocomplete
Expand Down Expand Up @@ -515,10 +516,12 @@ export default class CatalogController extends Controller {
@tracked progressTimer = null;
@tracked progressTimer2 = null;
@action progressStart() {
this.progressDeterminateValue = 30;
this.progressDeterminateValue2 = 30;
this.progressSetupTimer();
this.progressSetupTimer2();
if (!isTesting()) {
this.progressDeterminateValue = 30;
this.progressDeterminateValue2 = 30;
this.progressSetupTimer();
this.progressSetupTimer2();
}
}
progressSetupTimer() {
this.progressTimer = later(
Expand Down Expand Up @@ -549,8 +552,10 @@ export default class CatalogController extends Controller {
);
}
@action progressStop() {
cancel(this.progressTimer);
cancel(this.progressTimer2);
if (!isTesting()) {
cancel(this.progressTimer);
cancel(this.progressTimer2);
}
}

// Select
Expand Down Expand Up @@ -597,6 +602,7 @@ export default class CatalogController extends Controller {
return this.router.currentRouteName;
}

// Toast
toastDuration = 60000;
// Toast duration needs to be falsey so that we can take a snapshot with percy
// TODO we might be able to clean this up later when we remove use of `later()` in the codebase
toastDuration = false;
}
12 changes: 8 additions & 4 deletions tests/dummy/app/controllers/demo/grid-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { later } from '@ember/runloop';
import { A } from '@ember/array';
import EObject, { computed } from '@ember/object';
import { buildGridModel, randomColor, randomSpan } from '../../utils/grid-list';
import { isTesting } from '@embroider/macros';

export default Controller.extend({

Expand All @@ -18,11 +19,14 @@ export default Controller.extend({
basicRows: 6,

setupTimer() {
later(this, () => {
this.recalculateColorTiles();
// this will cause test waiters to never complete in tests
if(!isTesting()) {
later(this, () => {
this.recalculateColorTiles();

later(this, this.setupTimer);
}, 10 * 1000);
later(this, this.setupTimer);
}, 10 * 1000);
}
},

tiles: computed(function() {
Expand Down

0 comments on commit e4a6fee

Please sign in to comment.