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:
parent
57e1d07b5e
commit
afdd9e5d3f
@ -53,11 +53,11 @@ limitations under the License.
|
|||||||
|
|
||||||
test('show normal server error', function(done) {
|
test('show normal server error', function(done) {
|
||||||
var showAlertStub = sinon.stub(element, '_showAlert');
|
var showAlertStub = sinon.stub(element, '_showAlert');
|
||||||
element.fire('server-error', {response: {
|
var textSpy = sinon.spy(function() { return Promise.resolve('ZOMG'); });
|
||||||
status: 500,
|
element.fire('server-error', {response: {status: 500, text: textSpy}});
|
||||||
text: function() { return Promise.resolve('ZOMG'); },
|
|
||||||
}});
|
assert.isTrue(textSpy.called);
|
||||||
flush(function() {
|
textSpy.lastCall.returnValue.then(function() {
|
||||||
assert.isTrue(showAlertStub.calledOnce);
|
assert.isTrue(showAlertStub.calledOnce);
|
||||||
assert.isTrue(showAlertStub.lastCall.calledWithExactly(
|
assert.isTrue(showAlertStub.lastCall.calledWithExactly(
|
||||||
'Server error: ZOMG'));
|
'Server error: ZOMG'));
|
||||||
|
@ -76,6 +76,11 @@
|
|||||||
type: String,
|
type: String,
|
||||||
value: null,
|
value: null,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For testing purposes.
|
||||||
|
*/
|
||||||
|
_loadingPromise: Object,
|
||||||
},
|
},
|
||||||
|
|
||||||
observers: [
|
observers: [
|
||||||
@ -107,7 +112,7 @@
|
|||||||
|
|
||||||
promises.push(this.$.groupList.loadData());
|
promises.push(this.$.groupList.loadData());
|
||||||
|
|
||||||
Promise.all(promises).then(function() {
|
this._loadingPromise = Promise.all(promises).then(function() {
|
||||||
this._loading = false;
|
this._loading = false;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
@ -123,7 +123,7 @@ limitations under the License.
|
|||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
|
|
||||||
// Allow the element to render.
|
// Allow the element to render.
|
||||||
element.async(done, 1);
|
element._loadingPromise.then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('calls the title-change event', function() {
|
test('calls the title-change event', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user