11import { verifyNoBrowserErrors } from 'angular2/src/testing/e2e_util' ;
22
33describe ( "WebWorker Router" , ( ) => {
4+ beforeEach ( ( ) => {
5+ // This test can't wait for Angular 2 as Testability is not available when using WebWorker
6+ browser . ignoreSynchronization = true ;
7+ browser . get ( '/' ) ;
8+ } ) ;
9+
410 afterEach ( ( ) => {
511 verifyNoBrowserErrors ( ) ;
612 browser . ignoreSynchronization = false ;
@@ -11,8 +17,6 @@ describe("WebWorker Router", () => {
1117 var baseUrl = "playground/src/web_workers/router/index.html" ;
1218
1319 it ( "should route on click" , ( ) => {
14- // This test can't wait for Angular 2 as Testability is not available when using WebWorker
15- browser . ignoreSynchronization = true ;
1620 browser . get ( baseUrl ) ;
1721
1822 waitForElement ( contentSelector ) ;
@@ -23,39 +27,38 @@ describe("WebWorker Router", () => {
2327 aboutBtn . click ( ) ;
2428 waitForUrl ( / \/ a b o u t / ) ;
2529 waitForElement ( contentSelector ) ;
30+ waitForElementText ( contentSelector , "About" ) ;
2631 content = element ( by . css ( contentSelector ) ) ;
27- waitForElementText ( content , "About" ) ;
2832 expect ( content . getText ( ) ) . toEqual ( "About" ) ;
2933 expect ( browser . getCurrentUrl ( ) ) . toMatch ( / \/ a b o u t / ) ;
3034
3135 let contactBtn = element ( by . css ( navSelector + " .contact" ) ) ;
3236 contactBtn . click ( ) ;
3337 waitForUrl ( / \/ c o n t a c t / ) ;
3438 waitForElement ( contentSelector ) ;
39+ waitForElementText ( contentSelector , "Contact" ) ;
3540 content = element ( by . css ( contentSelector ) ) ;
36- waitForElementText ( content , "Contact" ) ;
3741 expect ( content . getText ( ) ) . toEqual ( "Contact" ) ;
3842 expect ( browser . getCurrentUrl ( ) ) . toMatch ( / \/ c o n t a c t / ) ;
3943 } ) ;
4044
4145 it ( "should load the correct route from the URL" , ( ) => {
42- // This test can't wait for Angular 2 as Testability is not available when using WebWorker
43- browser . ignoreSynchronization = true ;
4446 browser . get ( baseUrl + "#/about" ) ;
4547
4648 waitForElement ( contentSelector ) ;
49+ waitForElementText ( contentSelector , "About" ) ;
4750 let content = element ( by . css ( contentSelector ) ) ;
48- waitForElementText ( content , "About" ) ;
4951 expect ( content . getText ( ) ) . toEqual ( "About" ) ;
5052 } ) ;
5153
5254 function waitForElement ( selector : string ) : void {
5355 browser . wait ( protractor . until . elementLocated ( by . css ( selector ) ) , 15000 ) ;
5456 }
5557
56- function waitForElementText ( elem : protractor . ElementFinder , expected : string ) : void {
58+ function waitForElementText ( contentSelector : string , expected : string ) : void {
5759 browser . wait ( ( ) => {
5860 let deferred = protractor . promise . defer ( ) ;
61+ var elem = element ( by . css ( contentSelector ) ) ;
5962 elem . getText ( ) . then ( ( text ) => { return deferred . fulfill ( text === expected ) ; } ) ;
6063 return deferred . promise ;
6164 } , 5000 ) ;
0 commit comments