| 
									
										
										
										
											2017-02-22 18:13:21 +00:00
										 |  |  | 'use strict'; // necessary for es6 output in node
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { browser, by, element } from 'protractor'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe('Hierarchical dependency injection', () => { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   beforeAll(() => { | 
					
						
							|  |  |  |     browser.get(''); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('Heroes Scenario', () => { | 
					
						
							|  |  |  |     let page = { | 
					
						
							|  |  |  |       heroName: '', | 
					
						
							|  |  |  |       income: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // queries
 | 
					
						
							| 
									
										
										
										
											2017-08-22 21:31:15 +02:00
										 |  |  |       heroEl: element.all(by.css('app-heroes-list li')).get(0), // first hero
 | 
					
						
							|  |  |  |       heroCardEl: element(by.css('app-heroes-list app-hero-tax-return')), // first hero tax-return
 | 
					
						
							|  |  |  |       taxReturnNameEl: element.all(by.css('app-heroes-list app-hero-tax-return #name')).get(0), | 
					
						
							|  |  |  |       incomeInputEl: element.all(by.css('app-heroes-list app-hero-tax-return input')).get(0), | 
					
						
							|  |  |  |       cancelButtonEl: element(by.cssContainingText('app-heroes-list app-hero-tax-return button', 'Cancel')), | 
					
						
							|  |  |  |       closeButtonEl: element(by.cssContainingText('app-heroes-list app-hero-tax-return button', 'Close')), | 
					
						
							|  |  |  |       saveButtonEl: element(by.cssContainingText('app-heroes-list app-hero-tax-return button', 'Save')) | 
					
						
							| 
									
										
										
										
											2017-02-22 18:13:21 +00:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should list multiple heroes', () => { | 
					
						
							| 
									
										
										
										
											2017-08-22 21:31:15 +02:00
										 |  |  |       expect(element.all(by.css('app-heroes-list li')).count()).toBeGreaterThan(1); | 
					
						
							| 
									
										
										
										
											2017-02-22 18:13:21 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should show no hero tax-returns at the start', () => { | 
					
						
							| 
									
										
										
										
											2017-08-22 21:31:15 +02:00
										 |  |  |       expect(element.all(by.css('app-heroes-list li app-hero-tax-return')).count()).toBe(0); | 
					
						
							| 
									
										
										
										
											2017-02-22 18:13:21 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-22 21:31:15 +02:00
										 |  |  |     it('should open first hero in app-hero-tax-return view after click', () => { | 
					
						
							| 
									
										
										
										
											2017-02-22 18:13:21 +00:00
										 |  |  |       page.heroEl.getText() | 
					
						
							|  |  |  |         .then(val => { | 
					
						
							|  |  |  |           page.heroName = val; | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |         .then(() => page.heroEl.click()) | 
					
						
							|  |  |  |         .then(() => { | 
					
						
							|  |  |  |           expect(page.heroCardEl.isDisplayed()).toBe(true); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('hero tax-return should have first hero\'s name', () => { | 
					
						
							|  |  |  |       // Not `page.tax-returnNameInputEl.getAttribute('value')` although later that is essential
 | 
					
						
							|  |  |  |       expect(page.taxReturnNameEl.getText()).toEqual(page.heroName); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should be able to cancel change', () => { | 
					
						
							|  |  |  |       page.incomeInputEl.clear() | 
					
						
							|  |  |  |         .then(() => page.incomeInputEl.sendKeys('777')) | 
					
						
							|  |  |  |         .then(() => { | 
					
						
							|  |  |  |           expect(page.incomeInputEl.getAttribute('value')).toBe('777', 'income should be 777'); | 
					
						
							|  |  |  |           return page.cancelButtonEl.click(); | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |         .then(() => { | 
					
						
							|  |  |  |           expect(page.incomeInputEl.getAttribute('value')).not.toBe('777', 'income should not be 777'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should be able to save change', () => { | 
					
						
							|  |  |  |       page.incomeInputEl.clear() | 
					
						
							|  |  |  |         .then(() => page.incomeInputEl.sendKeys('999')) | 
					
						
							|  |  |  |         .then(() => { | 
					
						
							|  |  |  |           expect(page.incomeInputEl.getAttribute('value')).toBe('999', 'income should be 999'); | 
					
						
							|  |  |  |           return page.saveButtonEl.click(); | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |         .then(() => { | 
					
						
							|  |  |  |           expect(page.incomeInputEl.getAttribute('value')).toBe('999', 'income should still be 999'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should be able to close tax-return', () => { | 
					
						
							|  |  |  |       page.saveButtonEl.click() | 
					
						
							|  |  |  |         .then(() => { | 
					
						
							| 
									
										
										
										
											2017-08-22 21:31:15 +02:00
										 |  |  |           expect(element.all(by.css('app-heroes-list li app-hero-tax-return')).count()).toBe(0); | 
					
						
							| 
									
										
										
										
											2017-02-22 18:13:21 +00:00
										 |  |  |         }); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('Villains Scenario', () => { | 
					
						
							|  |  |  |     it('should list multiple villains', () => { | 
					
						
							| 
									
										
										
										
											2017-08-22 21:31:15 +02:00
										 |  |  |       expect(element.all(by.css('app-villains-list li')).count()).toBeGreaterThan(1); | 
					
						
							| 
									
										
										
										
											2017-02-22 18:13:21 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('Cars Scenario', () => { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('A-component should use expected services', () => { | 
					
						
							|  |  |  |       expect(element(by.css('a-car')).getText()).toContain('C1-E1-T1'); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('B-component should use expected services', () => { | 
					
						
							|  |  |  |       expect(element(by.css('b-car')).getText()).toContain('C2-E2-T1'); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('C-component should use expected services', () => { | 
					
						
							|  |  |  |       expect(element(by.css('c-car')).getText()).toContain('C3-E2-T1'); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | }); |