| 
									
										
										
										
											2017-03-13 18:08:23 -07:00
										 |  |  | import { browser, element, by, promise } from 'protractor'; | 
					
						
							| 
									
										
										
										
											2017-01-27 00:20:51 -08:00
										 |  |  | import { SitePage } from './app.po'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe('site App', function() { | 
					
						
							|  |  |  |   let page: SitePage; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   beforeEach(() => { | 
					
						
							| 
									
										
										
										
											2017-05-15 14:52:39 -07:00
										 |  |  |     SitePage.setWindowWidth(1050);   // Make the window wide enough to show the SideNav side-by-side.
 | 
					
						
							| 
									
										
										
										
											2017-01-27 00:20:51 -08:00
										 |  |  |     page = new SitePage(); | 
					
						
							| 
									
										
										
										
											2017-02-10 03:22:08 +02:00
										 |  |  |     page.navigateTo(); | 
					
						
							| 
									
										
										
										
											2017-01-27 00:20:51 -08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-02 12:10:47 -08:00
										 |  |  |   it('should show features text after clicking "Features"', () => { | 
					
						
							| 
									
										
										
										
											2017-03-27 16:38:14 +01:00
										 |  |  |     page.getLink('features').click(); | 
					
						
							|  |  |  |     expect(page.getDocViewerText()).toMatch(/Progressive web apps/i); | 
					
						
							| 
									
										
										
										
											2017-01-27 00:20:51 -08:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2017-02-07 12:57:18 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-15 00:37:41 -07:00
										 |  |  |   it('should show the tutorial index page at `/tutorial/` after jitterbugging through features', () => { | 
					
						
							| 
									
										
										
										
											2017-03-21 07:02:58 +00:00
										 |  |  |     // check that we can navigate directly to the tutorial page
 | 
					
						
							|  |  |  |     page.navigateTo('tutorial/'); | 
					
						
							|  |  |  |     expect(page.getDocViewerText()).toMatch(/Tutorial: Tour of Heroes/i); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // navigate to a different page
 | 
					
						
							|  |  |  |     page.getLink('features').click(); | 
					
						
							| 
									
										
										
										
											2017-05-24 23:08:21 -04:00
										 |  |  |     expect(page.getDocViewerText()).toMatch(/Progressive web apps/i); | 
					
						
							| 
									
										
										
										
											2017-03-21 07:02:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-15 00:37:41 -07:00
										 |  |  |     // Show the menu
 | 
					
						
							| 
									
										
										
										
											2017-03-29 14:13:40 -07:00
										 |  |  |     page.docsMenuLink.click(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-08 15:46:32 -07:00
										 |  |  |     // Tutorial folder should still be expanded because this test runs in wide mode
 | 
					
						
							| 
									
										
										
										
											2017-03-29 14:13:40 -07:00
										 |  |  |     // Navigate to the tutorial introduction via a link in the sidenav
 | 
					
						
							|  |  |  |     page.getNavItem(/introduction/i).click(); | 
					
						
							| 
									
										
										
										
											2017-03-21 07:02:58 +00:00
										 |  |  |     expect(page.getDocViewerText()).toMatch(/Tutorial: Tour of Heroes/i); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-22 20:24:40 +00:00
										 |  |  |   it('should render `{@example}` dgeni tags as `<code-example>` elements with HTML escaped content', () => { | 
					
						
							|  |  |  |     page.navigateTo('guide/component-styles'); | 
					
						
							|  |  |  |     const codeExample = element.all(by.css('code-example')).first(); | 
					
						
							| 
									
										
										
										
											2017-03-26 13:32:29 -07:00
										 |  |  |     expect(page.getInnerHtml(codeExample)).toContain('<h1>Tour of Heroes</h1>'); | 
					
						
							| 
									
										
										
										
											2017-03-22 20:24:40 +00:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2017-03-13 18:08:23 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-02 00:03:10 +03:00
										 |  |  |   describe('scrolling to the top', () => { | 
					
						
							|  |  |  |     it('should scroll to the top when navigating to another page', () => { | 
					
						
							|  |  |  |       page.navigateTo('guide/docs'); | 
					
						
							|  |  |  |       page.scrollToBottom(); | 
					
						
							|  |  |  |       page.getScrollTop().then(scrollTop => expect(scrollTop).toBeGreaterThan(0)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       page.navigateTo('guide/api'); | 
					
						
							|  |  |  |       page.getScrollTop().then(scrollTop => expect(scrollTop).toBe(0)); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should scroll to the top when navigating to the same page', () => { | 
					
						
							|  |  |  |       page.navigateTo('guide/docs'); | 
					
						
							|  |  |  |       page.scrollToBottom(); | 
					
						
							|  |  |  |       page.getScrollTop().then(scrollTop => expect(scrollTop).toBeGreaterThan(0)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       page.navigateTo('guide/docs'); | 
					
						
							|  |  |  |       page.getScrollTop().then(scrollTop => expect(scrollTop).toBe(0)); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-19 09:27:45 +01:00
										 |  |  |   describe('tutorial docs', () => { | 
					
						
							|  |  |  |     it('should not render a paragraph element inside the h1 element', () => { | 
					
						
							|  |  |  |       page.navigateTo('tutorial/toh-pt1'); | 
					
						
							|  |  |  |       expect(element(by.css('h1 p')).isPresent()).toBeFalsy(); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-13 18:08:23 -07:00
										 |  |  |   describe('google analytics', () => { | 
					
						
							|  |  |  |     beforeEach(done => page.gaReady.then(done)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should call ga', done => { | 
					
						
							|  |  |  |       page.ga() | 
					
						
							|  |  |  |         .then(calls => { | 
					
						
							|  |  |  |           expect(calls.length).toBeGreaterThan(2, 'ga calls'); | 
					
						
							|  |  |  |           done(); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should call ga with initial URL', done => { | 
					
						
							|  |  |  |       let path: string; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       page.locationPath() | 
					
						
							|  |  |  |         .then(p => path = p) | 
					
						
							|  |  |  |         .then(() => page.ga().then(calls => { | 
					
						
							|  |  |  |           expect(calls.length).toBeGreaterThan(2, 'ga calls'); | 
					
						
							|  |  |  |           expect(calls[1]).toEqual(['set', 'page', path]); | 
					
						
							|  |  |  |           done(); | 
					
						
							|  |  |  |         })); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Todo: add test to confirm tracking URL when navigate.
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-27 00:20:51 -08:00
										 |  |  | }); |