diff --git a/public/docs/_examples/protractor-helpers.ts b/public/docs/_examples/protractor-helpers.ts index 03ada46a7e..9eae89b886 100644 --- a/public/docs/_examples/protractor-helpers.ts +++ b/public/docs/_examples/protractor-helpers.ts @@ -1,4 +1,4 @@ -import { browser } from 'protractor'; +import { browser, element, by } from 'protractor'; export var appLang = { appIsTs: false, @@ -35,3 +35,13 @@ export function setProtractorToNg1Mode(): void { // browser.addMockModule('disableNgAnimate', disableNgAnimate); } + +// Protractor doesn't support the UpgradeAdapter's asynchronous +// bootstrap with Angular 1 at the moment. Get around it by +// waiting for an element to get `ng-scope` class. +export function waitForNg1AsyncBootstrap() { + browser.ignoreSynchronization = true; + browser.driver.wait(function() { + return element(by.css('.ng-scope')).isPresent(); + }, 5000); +} diff --git a/public/docs/_examples/upgrade-adapter/e2e-spec.ts b/public/docs/_examples/upgrade-adapter/e2e-spec.ts index 77e98678f1..e6f4d7138b 100644 --- a/public/docs/_examples/upgrade-adapter/e2e-spec.ts +++ b/public/docs/_examples/upgrade-adapter/e2e-spec.ts @@ -1,20 +1,10 @@ 'use strict'; // necessary for es6 output in node import { browser, element, by } from 'protractor'; -import { setProtractorToNg1Mode } from '../protractor-helpers'; +import { setProtractorToNg1Mode, waitForNg1AsyncBootstrap } from '../protractor-helpers'; describe('Upgrade Tests', function () { - // Protractor doesn't support the UpgradeAdapter's asynchronous - // bootstrap with Angular 1 at the moment. Get around it by - // waiting for an element to get `ng-scope` class. - function waitForNg1AsyncBootstrap() { - browser.ignoreSynchronization = true; - browser.driver.wait(function() { - return element(by.css('.ng-scope')).isPresent(); - }, 5000); - } - describe('NG1 Auto-bootstrap', function() { beforeAll(function () { diff --git a/public/docs/_examples/upgrade-phonecat-2-hybrid/e2e-spec.ts.disabled b/public/docs/_examples/upgrade-phonecat-2-hybrid/e2e-spec.ts similarity index 86% rename from public/docs/_examples/upgrade-phonecat-2-hybrid/e2e-spec.ts.disabled rename to public/docs/_examples/upgrade-phonecat-2-hybrid/e2e-spec.ts index 0e27367ec8..3a5fb7307d 100644 --- a/public/docs/_examples/upgrade-phonecat-2-hybrid/e2e-spec.ts.disabled +++ b/public/docs/_examples/upgrade-phonecat-2-hybrid/e2e-spec.ts @@ -1,18 +1,17 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by } from 'protractor'; +import { setProtractorToNg1Mode, waitForNg1AsyncBootstrap } from '../protractor-helpers'; // Angular E2E Testing Guide: // https://docs.angularjs.org/guide/e2e-testing describe('PhoneCat Application', function() { - beforeAll(function() { - setProtractorToNg1Mode(); - }); - it('should redirect `index.html` to `index.html#!/phones', function() { browser.get('index.html'); + setProtractorToNg1Mode(); + waitForNg1AsyncBootstrap(); expect(browser.getLocationAbsUrl()).toBe('/phones'); }); @@ -20,6 +19,8 @@ describe('PhoneCat Application', function() { beforeEach(function() { browser.get('index.html#!/phones'); + setProtractorToNg1Mode(); + waitForNg1AsyncBootstrap(); }); it('should filter the phone list as a user types into the search box', function() { @@ -63,12 +64,12 @@ describe('PhoneCat Application', function() { ]); }); - it('should render phone specific links', function() { + fit('should render phone specific links', function() { let query = element(by.css('input')); query.sendKeys('nexus'); element.all(by.css('.phones li a')).first().click(); - browser.refresh(); // Not sure why this is needed but it is. The route change works fine. + waitForNg1AsyncBootstrap(); // Not sure why this is needed but it is. The route change works fine. expect(browser.getLocationAbsUrl()).toBe('/phones/nexus-s'); }); @@ -78,6 +79,8 @@ describe('PhoneCat Application', function() { beforeEach(function() { browser.get('index.html#!/phones/nexus-s'); + setProtractorToNg1Mode(); + waitForNg1AsyncBootstrap(); }); it('should display the `nexus-s` page', function() {