2015-10-13 03:29:13 -04:00
|
|
|
import {verifyNoBrowserErrors} from 'angular2/src/testing/e2e_util';
|
2015-05-30 00:40:15 -04:00
|
|
|
|
|
|
|
describe('ng2 naive infinite scroll benchmark', function() {
|
|
|
|
|
|
|
|
var URL = 'benchmarks/src/naive_infinite_scroll/index.html?appSize=3';
|
|
|
|
|
2015-05-30 11:17:27 -04:00
|
|
|
afterEach(verifyNoBrowserErrors);
|
2015-05-30 00:40:15 -04:00
|
|
|
|
|
|
|
it('should not throw errors', function() {
|
|
|
|
browser.get(URL);
|
|
|
|
var expectedRowCount = 18;
|
2015-11-16 14:15:28 -05:00
|
|
|
var expectedCellsPerRow = 28;
|
2015-05-30 00:40:15 -04:00
|
|
|
var allScrollItems = 'scroll-app #testArea scroll-item';
|
|
|
|
var cells = `${ allScrollItems } .row *`;
|
|
|
|
var stageButtons = `${ allScrollItems } .row stage-buttons button`;
|
|
|
|
|
2015-06-19 13:18:44 -04:00
|
|
|
var count = function(selector) {
|
|
|
|
return browser.executeScript(`return ` +
|
|
|
|
`document.querySelectorAll("${ selector }").length;`);
|
|
|
|
};
|
|
|
|
|
|
|
|
var clickFirstOf = function(selector) {
|
|
|
|
return browser.executeScript(`document.querySelector("${ selector }").click();`);
|
|
|
|
};
|
|
|
|
|
|
|
|
var firstTextOf = function(selector) {
|
|
|
|
return browser.executeScript(`return ` +
|
|
|
|
`document.querySelector("${ selector }").innerText;`);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Make sure rows are rendered
|
|
|
|
count(allScrollItems).then(function(c) { expect(c).toEqual(expectedRowCount); });
|
2015-05-30 00:40:15 -04:00
|
|
|
|
|
|
|
// Make sure cells are rendered
|
2015-05-30 11:17:27 -04:00
|
|
|
count(cells).then(function(c) { expect(c).toEqual(expectedRowCount * expectedCellsPerRow); });
|
2015-05-30 00:40:15 -04:00
|
|
|
|
|
|
|
// Click on first enabled button and verify stage changes
|
|
|
|
firstTextOf(`${ stageButtons }:enabled`)
|
|
|
|
.then(function(text) {
|
2015-05-30 11:17:27 -04:00
|
|
|
expect(text).toEqual('Pitched');
|
2015-05-30 00:40:15 -04:00
|
|
|
clickFirstOf(`${ stageButtons }:enabled`)
|
|
|
|
.then(function() {
|
|
|
|
firstTextOf(`${ stageButtons }:enabled`)
|
2015-05-30 11:17:27 -04:00
|
|
|
.then(function(text) { expect(text).toEqual('Won'); })
|
2015-05-30 00:40:15 -04:00
|
|
|
});
|
2015-06-19 13:18:44 -04:00
|
|
|
});
|
2015-05-30 00:40:15 -04:00
|
|
|
|
2015-06-19 13:18:44 -04:00
|
|
|
$("#reset-btn").click();
|
2015-05-30 00:40:15 -04:00
|
|
|
$("#run-btn").click();
|
|
|
|
browser.wait(() => {
|
|
|
|
return $('#done').getText().then(function() { return true; }, function() { return false; });
|
|
|
|
}, 10000);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|