Make tests pass on Chrome again
It seems that a number of the tests had started failing when run in Chrome. They were fine under PhantomJS, but the MegolmExport tests only work under Chrome, and I need them to work... Mostly the problems were timing-related, where assumptions made about how quickly the `then` handler on a promise would be called were no longer valid. Possibly Chrome 55 has made some changes to the relative priorities of setTimeout and sendMessage calls. One of the TimelinePanel tests was failing because it was expecting the contents of a div to take up more room than they actually were. It's possible this is something very environment-specific; hopefully the new value will work on a wider range of machines. Also some logging tweaks.
This commit is contained in:
parent
878e5593ba
commit
cd1cf09dc9
6 changed files with 56 additions and 21 deletions
|
@ -73,6 +73,7 @@ var Tester = React.createClass({
|
|||
|
||||
/* returns a promise which will resolve when the fill happens */
|
||||
awaitFill: function(dir) {
|
||||
console.log("ScrollPanel Tester: awaiting " + dir + " fill");
|
||||
var defer = q.defer();
|
||||
this._fillDefers[dir] = defer;
|
||||
return defer.promise;
|
||||
|
@ -80,7 +81,7 @@ var Tester = React.createClass({
|
|||
|
||||
_onScroll: function(ev) {
|
||||
var st = ev.target.scrollTop;
|
||||
console.log("Scroll event; scrollTop: " + st);
|
||||
console.log("ScrollPanel Tester: scroll event; scrollTop: " + st);
|
||||
this.lastScrollEvent = st;
|
||||
|
||||
var d = this._scrollDefer;
|
||||
|
@ -159,10 +160,29 @@ describe('ScrollPanel', function() {
|
|||
scrollingDiv = ReactTestUtils.findRenderedDOMComponentWithClass(
|
||||
tester, "gm-scroll-view");
|
||||
|
||||
// wait for a browser tick to let the initial paginates complete
|
||||
setTimeout(function() {
|
||||
done();
|
||||
}, 0);
|
||||
// we need to make sure we don't call done() until q has finished
|
||||
// running the completion handlers from the fill requests. We can't
|
||||
// just use .done(), because that will end up ahead of those handlers
|
||||
// in the queue. We can't use window.setTimeout(0), because that also might
|
||||
// run ahead of those handlers.
|
||||
const sp = tester.scrollPanel();
|
||||
let retriesRemaining = 1;
|
||||
const awaitReady = function() {
|
||||
return q().then(() => {
|
||||
if (sp._pendingFillRequests.b === false &&
|
||||
sp._pendingFillRequests.f === false
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (retriesRemaining == 0) {
|
||||
throw new Error("fillRequests did not complete");
|
||||
}
|
||||
retriesRemaining--;
|
||||
return awaitReady();
|
||||
});
|
||||
};
|
||||
awaitReady().done(done);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue