Skip to content

Commit

Permalink
chore(ci): update Protractor version, remove custom waits
Browse files Browse the repository at this point in the history
The latest Protractor version supports waiting for Angular2 applications,
so remove custom waiting logic.

Closes angular#3829
  • Loading branch information
juliemr committed Oct 7, 2015
1 parent 4ed642f commit e1c824c
Show file tree
Hide file tree
Showing 13 changed files with 697 additions and 236 deletions.
5 changes: 2 additions & 3 deletions modules/angular2/src/test_lib/perf_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var bind = benchpress.bind;
var Options = benchpress.Options;

export function runClickBenchmark(config) {
browser.ignoreSynchronization = !config.waitForAngular2;
var buttons = config.buttons.map(function(selector) { return $(selector); });
config.work = function() { buttons.forEach(function(button) { button.click(); }); };
return runBenchmark(config);
Expand All @@ -24,9 +25,7 @@ export function runBenchmark(config) {
});
}
var url = encodeURI(config.url + '?' + urlParams.join('&'));
var getter = config.waitForAngular2 !== false ? browser.get(url) :
browser.driver.get(browser.baseUrl + url);
return getter.then(function() {
return browser.get(url).then(function() {
return global['benchpressRunner'].sample({
id: config.id,
execute: config.work,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class SeleniumWebDriverAdapter extends WebDriverAdapter {

capabilities(): Promise<any> {
return this._convertPromise(
this._driver.getCapabilities().then((capsObject) => capsObject.toJSON()));
this._driver.getCapabilities().then((capsObject) => capsObject.serialize()));
}

logs(type: string): Promise<any> {
Expand Down
45 changes: 18 additions & 27 deletions modules/examples/e2e_test/async/async_spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';

function whenStable(rootSelector) {
// TODO(hankduan): remove this call once Protractor implements it
return browser.executeAsyncScript('var el = document.querySelector("' + rootSelector + '");' +
'window.getAngularTestability(el).whenStable(arguments[0]);');
};

describe('async', () => {
var URL = 'examples/src/async/index.html';

Expand All @@ -20,51 +14,48 @@ describe('async', () => {

it('should wait for asynchronous actions', () => {
var timeout = $('#delayedIncrement');
timeout.$('.action').click();

// At this point, the async action is still pending, so the count should
// still be 0.
expect(timeout.$('.val').getText()).toEqual('0');

whenStable('async-app')
.then(() => {
// whenStable should only be called when the async action finished,
// so the count should be 1 at this point.
expect(timeout.$('.val').getText()).toEqual('1');
});
timeout.$('.action').click();

// whenStable should only be called when the async action finished,
// so the count should be 1 at this point.
expect(timeout.$('.val').getText()).toEqual('1');
});

it('should notice when asynchronous actions are cancelled', () => {
var timeout = $('#delayedIncrement');
timeout.$('.action').click();

// At this point, the async action is still pending, so the count should
// still be 0.
expect(timeout.$('.val').getText()).toEqual('0');

browser.ignoreSynchronization = true;
timeout.$('.action').click();

timeout.$('.cancel').click();
whenStable('async-app')
.then(() => {
// whenStable should be called since the async action is cancelled. The
// count should still be 0;
expect(timeout.$('.val').getText()).toEqual('0');
});
browser.ignoreSynchronization = false;

// whenStable should be called since the async action is cancelled. The
// count should still be 0;
expect(timeout.$('.val').getText()).toEqual('0');
});

it('should wait for a series of asynchronous actions', () => {
var timeout = $('#multiDelayedIncrements');
timeout.$('.action').click();

// At this point, the async action is still pending, so the count should
// still be 0.
expect(timeout.$('.val').getText()).toEqual('0');

whenStable('async-app')
.then(() => {
// whenStable should only be called when all the async actions
// finished, so the count should be 10 at this point.
expect(timeout.$('.val').getText()).toEqual('10');
});
timeout.$('.action').click();

// whenStable should only be called when all the async actions
// finished, so the count should be 10 at this point.
expect(timeout.$('.val').getText()).toEqual('10');
});

afterEach(verifyNoBrowserErrors);
Expand Down
1 change: 0 additions & 1 deletion modules/examples/e2e_test/http/http_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('http', function() {

it('should fetch and display people', function() {
browser.get(URL);
browser.sleep(200);
expect(getComponentText('http-app', '.people')).toEqual('hello, Jeff');
});
});
Expand Down
1 change: 0 additions & 1 deletion modules/examples/e2e_test/jsonp/jsonp_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('jsonp', function() {

it('should fetch and display people', function() {
browser.get(URL);
browser.sleep(200);
expect(getComponentText('jsonp-app', '.people')).toEqual('hello, caitp');
});
});
Expand Down
1 change: 0 additions & 1 deletion modules/examples/e2e_test/material/dialog_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('md-dialog', function() {
openButton.click();

var dialog = element(by.css('.md-dialog'));
browser.sleep(500);

expect(dialog.isPresent()).toEqual(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@ import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
import {Promise} from 'angular2/src/core/facade/async';

describe('WebWorkers Kitchen Sink', function() {
afterEach(verifyNoBrowserErrors);
afterEach(() => {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});
var selector = "hello-app .greeting";
var URL = browser.baseUrl + "examples/src/web_workers/kitchen_sink/index.html";
var URL = "examples/src/web_workers/kitchen_sink/index.html";

it('should greet', () => {
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
browser.driver.get(URL);
browser.ignoreSynchronization = true;
browser.get(URL);

browser.wait(protractor.until.elementLocated(by.css(selector)), 15000);
expect(element.all(by.css(selector)).first().getText()).toEqual("hello world!");

});

it('should change greeting', () => {
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
browser.driver.get(URL);
browser.ignoreSynchronization = true;
browser.get(URL);

browser.wait(protractor.until.elementLocated(by.css(selector)), 15000);
element(by.css("hello-app .changeButton")).click();
Expand All @@ -27,7 +33,8 @@ describe('WebWorkers Kitchen Sink', function() {

it("should display correct key names", () => {
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
browser.driver.get(URL);
browser.ignoreSynchronization = true;
browser.get(URL);
browser.wait(protractor.until.elementLocated(by.css(".sample-area")), 15000);

var area = element.all(by.css(".sample-area")).first();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import {verifyNoBrowserErrors} from "angular2/src/test_lib/e2e_util";
import {PromiseWrapper} from "angular2/src/core/facade/async";

var URL = browser.baseUrl + 'examples/src/web_workers/message_broker/index.html';
var URL = 'examples/src/web_workers/message_broker/index.html';

describe("MessageBroker", function() {

afterEach(verifyNoBrowserErrors);
afterEach(() => {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});

it("should bootstrap", () => {
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
browser.driver.get(URL);
browser.ignoreSynchronization = true;
browser.get(URL);
waitForBootstrap();
expect(element(by.css("app h1")).getText()).toEqual("WebWorker MessageBroker Test");
});

it("should echo messages", () => {
const VALUE = "Hi There";
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
browser.driver.get(URL);
browser.ignoreSynchronization = true;
browser.get(URL);
waitForBootstrap();

var input = element.all(by.css("#echo_input")).first();
Expand Down
10 changes: 7 additions & 3 deletions modules/examples/e2e_test/web_workers/todo/todo_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
import {Promise} from 'angular2/src/core/facade/async';

describe('WebWorkers Todo', function() {
afterEach(verifyNoBrowserErrors);
afterEach(() => {
verifyNoBrowserErrors();
browser.ignoreSynchronization = false;
});

var URL = browser.baseUrl + "examples/src/web_workers/todo/index.html";
var URL = "examples/src/web_workers/todo/index.html";

it('should bootstrap', () => {
// This test can't wait for Angular 2 as Testability is not available when using WebWorker
browser.driver.get(URL);
browser.ignoreSynchronization = true;
browser.get(URL);

waitForBootstrap();
expect(element(by.css("#todoapp header")).getText()).toEqual("todos");
Expand Down

0 comments on commit e1c824c

Please sign in to comment.