Skip to content

Commit e1df556

Browse files
authored
Merge pull request #554 from Gaurav0/flakey_tests
Try to fix flakey tests
2 parents 7607b84 + d50d04f commit e1df556

9 files changed

Lines changed: 294 additions & 190 deletions

File tree

app/components/dummy-app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,7 @@ export default Ember.Component.extend(ResizeMixin, {
7474
if (oldIframe) {
7575
oldIframe.parentNode.removeChild(oldIframe);
7676
}
77+
78+
this.get('app').setCurrentIFrame(null);
7779
}
7880
});

app/components/twiddle-panes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export default Ember.Component.extend({
2525
},
2626

2727
willDestroyElement() {
28+
this._super(...arguments);
29+
2830
this.cleanupDrags();
2931
},
3032

app/mixins/app-builder.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,11 @@ export default Ember.Mixin.create({
3434
yield timeout(500);
3535
yield this.get('buildApp').perform();
3636
}
37-
}).restartable()
37+
}).restartable(),
38+
39+
willDestroyElement() {
40+
this._super(...arguments);
41+
42+
this.get('dependencyResolver.resolveAddonsTask').cancelAll();
43+
}
3844
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"ember-cli-sri": "~2.1.0",
6060
"ember-cli-test-loader": "~1.1.0",
6161
"ember-cli-uglify": "~1.2.0",
62-
"ember-concurrency": "~0.7.1",
62+
"ember-concurrency": "~0.8.2",
6363
"ember-data": "~2.11.0",
6464
"ember-disable-proxy-controllers": "1.0.1",
6565
"ember-export-application-global": "~1.1.1",

tests/acceptance/gist-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ test('own gist can be copied into a new one', function(assert) {
397397

398398
click("#live-reload");
399399
click('.test-copy-action');
400+
click(".run-now");
400401
waitForLoadedIFrame();
401402
});
402403

@@ -427,6 +428,7 @@ test('accessing /:gist/copy creates a new Twiddle with a copy of the gist', func
427428

428429
click("#live-reload");
429430
visit('/35de43cb81fc35ddffb2/copy');
431+
click(".run-now");
430432
waitForLoadedIFrame();
431433
});
432434

tests/acceptance/git-revision-test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ test('Able to copy a revision into new gist', function(assert) {
5858
click('.test-copy-action');
5959

6060
andThen(function() {
61+
click(".run-now");
6162
waitForLoadedIFrame();
6263
});
6364

@@ -87,9 +88,9 @@ test('Able to go from current version to revision and back via the UI', function
8788

8889
andThen(() => {
8990
assert.equal(outputContents('div'), 'Hello, World!');
90-
});
9191

92-
click("#live-reload");
92+
click("#live-reload");
93+
});
9394

9495
createGist({
9596
files: [
@@ -104,9 +105,11 @@ test('Able to go from current version to revision and back via the UI', function
104105
doNotCreateGist: true
105106
});
106107

107-
click(".test-version-action");
108-
click(".run-now");
109-
waitForLoadedIFrame();
108+
andThen(() => {
109+
click(".test-version-action");
110+
click(".run-now");
111+
waitForLoadedIFrame();
112+
});
110113

111114
andThen(() => {
112115
assert.equal(outputContents('div'), 'Hello, ...');

tests/helpers/module-for-acceptance.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Ember from 'ember';
33
import startApp from '../helpers/start-app';
44
import destroyApp from '../helpers/destroy-app';
55

6-
const { RSVP: { Promise } } = Ember;
6+
const { RSVP: { Promise }, run } = Ember;
77

88
export default function(name, options = {}) {
99
module(name, {
@@ -16,6 +16,7 @@ export default function(name, options = {}) {
1616
},
1717

1818
afterEach() {
19+
run.cancelTimers();
1920
let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
2021
return Promise.resolve(afterEach).then(() => destroyApp(this.application));
2122
}

tests/helpers/wait-for-loaded-iframe.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ export default function(app, url) {
1717
resolve();
1818
}
1919

20-
if (app.testHelpers.find('iframe').length === 0 && times++ < 10) {
20+
if (times++ >= 10) {
21+
run.cancelTimers();
22+
} else if (app.testHelpers.find('iframe').length === 0) {
2123
run.later(waitForRender, 10);
2224
return;
2325
}
2426
iframe_window = outputPane();
2527
if (iframe_window.document.readyState === 'complete') {
26-
onWindowLoad();
28+
resolve();
2729
} else {
2830
iframe_window.addEventListener('load', onWindowLoad);
2931
}

0 commit comments

Comments
 (0)