Addresses unit-test flakiness in Safari

The gr-settings-view tests partially relied on timing for evaluating the
tests. If a browser acted too slowly in executing the test, the tests
would occasionally fail. This change removes timing from the test and
instead listens to a promise that the settings view now provides.

A gr-error-manager test relied on flushing the DOM for a response
content promise to be resolved. In Safari, this would frequently execute
out of the expected order. This change waits for the promise itself to
complete before continuing the test.

Change-Id: Id93ccc44bcf3baecdba53058e42dcebccfa4c326
This commit is contained in:
Wyatt Allen 2016-06-17 15:46:38 -07:00
parent 57e1d07b5e
commit afdd9e5d3f
3 changed files with 12 additions and 7 deletions

View File

@ -53,11 +53,11 @@ limitations under the License.
test('show normal server error', function(done) {
var showAlertStub = sinon.stub(element, '_showAlert');
element.fire('server-error', {response: {
status: 500,
text: function() { return Promise.resolve('ZOMG'); },
}});
flush(function() {
var textSpy = sinon.spy(function() { return Promise.resolve('ZOMG'); });
element.fire('server-error', {response: {status: 500, text: textSpy}});
assert.isTrue(textSpy.called);
textSpy.lastCall.returnValue.then(function() {
assert.isTrue(showAlertStub.calledOnce);
assert.isTrue(showAlertStub.lastCall.calledWithExactly(
'Server error: ZOMG'));

View File

@ -76,6 +76,11 @@
type: String,
value: null,
},
/**
* For testing purposes.
*/
_loadingPromise: Object,
},
observers: [
@ -107,7 +112,7 @@
promises.push(this.$.groupList.loadData());
Promise.all(promises).then(function() {
this._loadingPromise = Promise.all(promises).then(function() {
this._loading = false;
}.bind(this));
},

View File

@ -123,7 +123,7 @@ limitations under the License.
element = fixture('basic');
// Allow the element to render.
element.async(done, 1);
element._loadingPromise.then(done);
});
test('calls the title-change event', function() {