Fix race condition in gr-reply-dialog_test.html

gr-reply-dialog_test.html fails when dom=shadow in Safari due to a race
condition. Polymer lazily performs local DOM mutations in some cases
for performance (in this case, the two calls to MockInteractions.tap()
were the culprit). flush() ensures that asynchronous changes have taken
place.

Bug: Issue 4573
Change-Id: I5a97ddcc7dd17933f763c4ef58235a0fdd8f5269
This commit is contained in:
Kasper Nilsson
2016-09-16 13:27:11 -07:00
parent beb55fc218
commit 4416acdf81

View File

@@ -382,21 +382,26 @@ limitations under the License.
});
test('only send labels that have changed', function(done) {
var saveReviewStub = sinon.stub(element, '_saveReview',
function(review) {
assert.deepEqual(review.labels, {Verified: -1});
return Promise.resolve({ok: true});
});
flush(function() {
var saveReviewStub = sinon.stub(element, '_saveReview',
function(review) {
assert.deepEqual(review.labels, {Verified: -1});
return Promise.resolve({ok: true});
});
element.addEventListener('send', function() {
saveReviewStub.restore();
done();
element.addEventListener('send', function() {
saveReviewStub.restore();
done();
});
// Without wrapping this test in flush(), the below two calls to
// MockInteractions.tap() cause a race in some situations in shadow DOM.
// The send button can be tapped before the others, causing the test to
// fail.
MockInteractions.tap(element.$$(
'iron-selector[data-label="Verified"] > ' +
'gr-button[data-value="-1"]'));
MockInteractions.tap(element.$$('.send'));
});
MockInteractions.tap(element.$$(
'iron-selector[data-label="Verified"] > ' +
'gr-button[data-value="-1"]'));
MockInteractions.tap(element.$$('.send'));
});
});
</script>