2016-04-28 20:50:03 -04:00
|
|
|
import {verifyNoBrowserErrors} from '@angular/testing/src/e2e_util';
|
|
|
|
import {runClickBenchmark} from '@angular/testing/src/perf_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-20 16:46:37 -05:00
|
|
|
var expectedCellsPerRow = 27;
|
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) {
|
2016-08-26 18:44:05 -04:00
|
|
|
return browser.executeScript(
|
|
|
|
`return ` +
|
|
|
|
`document.querySelectorAll("${ selector }").length;`);
|
2015-06-19 13:18:44 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
var clickFirstOf = function(selector) {
|
|
|
|
return browser.executeScript(`document.querySelector("${ selector }").click();`);
|
|
|
|
};
|
|
|
|
|
|
|
|
var firstTextOf = function(selector) {
|
2016-08-26 18:44:05 -04:00
|
|
|
return browser.executeScript(
|
|
|
|
`return ` +
|
|
|
|
`document.querySelector("${ selector }").innerText;`);
|
2015-06-19 13:18:44 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// 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
|
2016-08-26 18:44:05 -04:00
|
|
|
firstTextOf(`${ stageButtons }:enabled`).then(function(text) {
|
|
|
|
expect(text).toEqual('Pitched');
|
|
|
|
clickFirstOf(`${ stageButtons }:enabled`).then(function() {
|
|
|
|
firstTextOf(`${ stageButtons }:enabled`).then(function(text) {
|
|
|
|
expect(text).toEqual('Won');
|
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#reset-btn').click();
|
|
|
|
$('#run-btn').click();
|
2015-05-30 00:40:15 -04:00
|
|
|
browser.wait(() => {
|
|
|
|
return $('#done').getText().then(function() { return true; }, function() { return false; });
|
|
|
|
}, 10000);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|