Skip to content

Commit

Permalink
Disable chunked dom-repeat tests on IE due to CI rAF flakiness.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Dec 1, 2015
1 parent 230ce10 commit 7fe5e2b
Showing 1 changed file with 170 additions and 173 deletions.
343 changes: 170 additions & 173 deletions test/unit/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -3646,207 +3646,204 @@ <h4>x-repeat-chunked</h4>

});

suite('chunked rendering', function() {
// TODO(kschaaf): This test suite has proven to be flaky only on IE, only
// on CI (Sauce) presumably because of rAF handling in the CI environment
// disabling for IE for now to avoid Polymer tests being flaky
if (!/Trident/.test(navigator.userAgent)) {

// Patch requestAnimationFrame to setTimeout to reduce IE test flakiness on CI
var rAF;
suiteSetup(function() {
rAF = window.requestAnimationFrame;
window.requestAnimationFrame = setTimeout;
});
suiteTeardown(function() {
window.requestAnimationFrame = rAF;
});
suite('chunked rendering', function() {

test('basic chunked rendering', function(done) {
test('basic chunked rendering', function(done) {

var checkItemOrder = function(stamped) {
for (var i=0; i<stamped.length; i++) {
assert.equal(stamped[i].textContent, i);
}
};
var checkItemOrder = function(stamped) {
for (var i=0; i<stamped.length; i++) {
assert.equal(stamped[i].textContent, i);
}
};

var lastLength = 0;
var checkCount = function() {
var stamped = Polymer.dom(chunked.root).querySelectorAll('*:not(template)');
checkItemOrder(stamped);
if (stamped.length && lastLength === 0) {
// Initial rendering of initial count
assert.equal(stamped.length, 10);
} else {
// Remaining rendering incremenets
assert.isTrue(stamped.length > lastLength);
}
if (stamped.length < 100) {
lastLength = stamped.length;
checkUntilComplete();
} else {
// Final rendering at exact item count
assert.equal(stamped.length, 100);
done();
}
};
var checkUntilComplete = function() {
// On polyfilled MO, need to wait one setTimeout before rAF
if (MutationObserver._isPolyfilled) {
setTimeout(function() {
var lastLength = 0;
var checkCount = function() {
var stamped = Polymer.dom(chunked.root).querySelectorAll('*:not(template)');
checkItemOrder(stamped);
if (stamped.length && lastLength === 0) {
// Initial rendering of initial count
assert.equal(stamped.length, 10);
} else {
// Remaining rendering incremenets
assert.isTrue(stamped.length > lastLength);
}
if (stamped.length < 100) {
lastLength = stamped.length;
checkUntilComplete();
} else {
// Final rendering at exact item count
assert.equal(stamped.length, 100);
done();
}
};
var checkUntilComplete = function() {
// On polyfilled MO, need to wait one setTimeout before rAF
if (MutationObserver._isPolyfilled) {
setTimeout(function() {
requestAnimationFrame(checkCount);
});
} else {
requestAnimationFrame(checkCount);
});
} else {
requestAnimationFrame(checkCount);
}
};
}
};

chunked.items = chunked.preppedItems.slice();
checkUntilComplete();
chunked.items = chunked.preppedItems.slice();
checkUntilComplete();

});
});

test('mutations during chunked rendering', function(done) {
test('mutations during chunked rendering', function(done) {

var checkItemOrder = function(stamped) {
var last = -1;
for (var i=0; i<stamped.length; i++) {
var curr = parseFloat(stamped[i].textContent);
assert.isTrue(curr > last);
last = curr;
}
};
var checkItemOrder = function(stamped) {
var last = -1;
for (var i=0; i<stamped.length; i++) {
var curr = parseFloat(stamped[i].textContent);
assert.isTrue(curr > last);
last = curr;
}
};

var mutateArray = function(repeater, renderedCount) {
// The goal here is to remove & add some, and do it over
// the threshold of where we have currently rendered items, and
// ensure that the prop values of the newly inserted items are in
// ascending order so we can do a simple check in checkItemOrder
var overlap = 2;
var remove = 4;
var add = 6;
var start = renderedCount.length - overlap;
if (start + add < repeater.items.length) {
var end = start + remove;
var args = ['items', start, remove];
var startVal = repeater.items[start].prop;
var endVal = repeater.items[end].prop;
var delta = (endVal - startVal) / add;
for (var i=0; i<add; i++) {
args.push({prop: startVal + i*delta});
var mutateArray = function(repeater, renderedCount) {
// The goal here is to remove & add some, and do it over
// the threshold of where we have currently rendered items, and
// ensure that the prop values of the newly inserted items are in
// ascending order so we can do a simple check in checkItemOrder
var overlap = 2;
var remove = 4;
var add = 6;
var start = renderedCount.length - overlap;
if (start + add < repeater.items.length) {
var end = start + remove;
var args = ['items', start, remove];
var startVal = repeater.items[start].prop;
var endVal = repeater.items[end].prop;
var delta = (endVal - startVal) / add;
for (var i=0; i<add; i++) {
args.push({prop: startVal + i*delta});
}
repeater.splice.apply(repeater, args);
}
repeater.splice.apply(repeater, args);
}
};
};

var lastLength = 0;
var mutateCount = 5;
var checkCount = function() {
var stamped = Polymer.dom(chunked.root).querySelectorAll('*:not(template)');
checkItemOrder(stamped);
if (stamped.length && lastLength === 0) {
// Initial rendering of initial count
assert.equal(stamped.length, 10);
} else {
// Remaining rendering incremenets
assert.isTrue(stamped.length > lastLength);
}
if (stamped.length < chunked.items.length) {
if (mutateCount-- > 0) {
mutateArray(chunked, stamped);
var lastLength = 0;
var mutateCount = 5;
var checkCount = function() {
var stamped = Polymer.dom(chunked.root).querySelectorAll('*:not(template)');
checkItemOrder(stamped);
if (stamped.length && lastLength === 0) {
// Initial rendering of initial count
assert.equal(stamped.length, 10);
} else {
// Remaining rendering incremenets
assert.isTrue(stamped.length > lastLength);
}
lastLength = stamped.length;
checkUntilComplete();
} else {
// Final rendering at exact item count
assert.equal(stamped.length, chunked.items.length);
done();
}
};
var checkUntilComplete = function() {
// On polyfilled MO, need to wait one setTimeout before rAF
if (MutationObserver._isPolyfilled) {
setTimeout(function() {
if (stamped.length < chunked.items.length) {
if (mutateCount-- > 0) {
mutateArray(chunked, stamped);
}
lastLength = stamped.length;
checkUntilComplete();
} else {
// Final rendering at exact item count
assert.equal(stamped.length, chunked.items.length);
done();
}
};
var checkUntilComplete = function() {
// On polyfilled MO, need to wait one setTimeout before rAF
if (MutationObserver._isPolyfilled) {
setTimeout(function() {
requestAnimationFrame(checkCount);
});
} else {
requestAnimationFrame(checkCount);
});
} else {
requestAnimationFrame(checkCount);
}
};
}
};

chunked.items = chunked.preppedItems.slice();
checkUntilComplete();
chunked.items = chunked.preppedItems.slice();
checkUntilComplete();

});
});


test('mutations during chunked rendering, sort & filtered', function(done) {
test('mutations during chunked rendering, sort & filtered', function(done) {

var checkItemOrder = function(stamped) {
var last = Infinity;
for (var i=0; i<stamped.length; i++) {
var curr = parseFloat(stamped[i].textContent);
assert.isTrue(curr <= last);
assert.strictEqual(curr % 2, 0);
last = curr;
}
};
var checkItemOrder = function(stamped) {
var last = Infinity;
for (var i=0; i<stamped.length; i++) {
var curr = parseFloat(stamped[i].textContent);
assert.isTrue(curr <= last);
assert.strictEqual(curr % 2, 0);
last = curr;
}
};

var mutateArray = function(repeater, stamped) {
var start = parseInt(stamped[0].textContent);
var end = parseInt(stamped[stamped.length-1].textContent);
var mid = (end-start)/2;
for (var i=0; i<5; i++) {
chunked.push('items', {prop: mid + 1});
}
chunked.splice('items', Math.round(stamped.length/2), 3);
};
var mutateArray = function(repeater, stamped) {
var start = parseInt(stamped[0].textContent);
var end = parseInt(stamped[stamped.length-1].textContent);
var mid = (end-start)/2;
for (var i=0; i<5; i++) {
chunked.push('items', {prop: mid + 1});
}
chunked.splice('items', Math.round(stamped.length/2), 3);
};

var lastLength = 0;
var mutateCount = 5;
var checkCount = function() {
var stamped = Polymer.dom(chunked.root).querySelectorAll('*:not(template)');
checkItemOrder(stamped);
var filteredLength = chunked.items.filter(chunked.$.repeater.filter).length;
if (stamped.length && lastLength === 0) {
// Initial rendering of initial count
assert.equal(stamped.length, 10);
} else {
// Remaining rendering incremenets
if (stamped.length < filteredLength) {
assert.isTrue(stamped.length > lastLength);
var lastLength = 0;
var mutateCount = 5;
var checkCount = function() {
var stamped = Polymer.dom(chunked.root).querySelectorAll('*:not(template)');
checkItemOrder(stamped);
var filteredLength = chunked.items.filter(chunked.$.repeater.filter).length;
if (stamped.length && lastLength === 0) {
// Initial rendering of initial count
assert.equal(stamped.length, 10);
} else {
// Remaining rendering incremenets
if (stamped.length < filteredLength) {
assert.isTrue(stamped.length > lastLength);
}
}
}
if (stamped.length < filteredLength) {
if (mutateCount-- > 0) {
mutateArray(chunked, stamped);
if (stamped.length < filteredLength) {
if (mutateCount-- > 0) {
mutateArray(chunked, stamped);
}
lastLength = stamped.length;
checkUntilComplete();
} else {
assert.equal(stamped.length, filteredLength);
done();
}
lastLength = stamped.length;
checkUntilComplete();
} else {
assert.equal(stamped.length, filteredLength);
done();
}
};
var checkUntilComplete = function() {
// On polyfilled MO, need to wait one setTimeout before rAF
if (MutationObserver._isPolyfilled) {
setTimeout(function() {
};
var checkUntilComplete = function() {
// On polyfilled MO, need to wait one setTimeout before rAF
if (MutationObserver._isPolyfilled) {
setTimeout(function() {
requestAnimationFrame(checkCount);
});
} else {
requestAnimationFrame(checkCount);
});
} else {
requestAnimationFrame(checkCount);
}
};
}
};

chunked.$.repeater.sort = function(a, b) {
return b.prop - a.prop;
};
chunked.$.repeater.filter = function(a) {
return (a.prop % 2) === 0;
};
chunked.items = chunked.preppedItems.slice();
checkUntilComplete();
chunked.$.repeater.sort = function(a, b) {
return b.prop - a.prop;
};
chunked.$.repeater.filter = function(a) {
return (a.prop % 2) === 0;
};
chunked.items = chunked.preppedItems.slice();
checkUntilComplete();

});

});

});
}

</script>

Expand Down

0 comments on commit 7fe5e2b

Please sign in to comment.