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