Skip to content

Commit

Permalink
fix(testing): Fixed race condition in WebWorker and Routing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jteplitz committed Jul 30, 2015
1 parent 5c21af9 commit eee2146
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
11 changes: 3 additions & 8 deletions modules/examples/e2e_test/routing/routing_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ function waitForElement(selector) {
browser.wait(EC.presenceOf($(selector)), 10000);
}

// returns a promise that resolves in the given number of milliseconds
function wait(time) {
var promise = new Promise((resolve, reject) => { setTimeout(resolve, time); });
return promise;
}

describe('routing inbox-app', function() {

afterEach(verifyNoBrowserErrors);
Expand Down Expand Up @@ -69,8 +63,9 @@ describe('routing inbox-app', function() {
waitForElement('#item-10');
element(by.css('#item-10')).click();
waitForElement('#record-id');
browser.wait(wait(500), 600);
expect(element(by.css('#record-id')).getText()).toEqual('ID: 10');
var recordId = element(by.css("#record-id"));
browser.wait(protractor.until.elementTextIs(recordId, "ID: 10"), 5000);
expect(recordId.getText()).toEqual('ID: 10');
});

it('should navigate back to the email inbox page when the back button is clicked', function() {
Expand Down
15 changes: 5 additions & 10 deletions modules/examples/e2e_test/web_workers/web_workers_spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
import {Promise} from 'angular2/src/facade/async';

// returns a promise that resolves in the given number of milliseconds
function wait(time) {
var promise = new Promise((resolve, reject) => { setTimeout(resolve, time); });
return promise;
}

describe('WebWorkers', function() {
afterEach(verifyNoBrowserErrors);
var selector = "hello-app .greeting";
Expand All @@ -23,9 +17,10 @@ describe('WebWorkers', function() {
browser.get(URL);

browser.wait(protractor.until.elementLocated(by.css(selector)), 5000);
element.all(by.css(".changeButton")).first().click();
browser.wait(wait(500), 600);
expect(element.all(by.css(selector)).first().getText()).toEqual("howdy world!");
element(by.css("hello-app .changeButton")).click();
var elem = element(by.css(selector));
browser.wait(protractor.until.elementTextIs(elem, "howdy world!"), 5000);
expect(elem.getText()).toEqual("howdy world!");
});

it("should display correct key names", () => {
Expand All @@ -34,9 +29,9 @@ describe('WebWorkers', function() {

var area = element.all(by.css(".sample-area")).first();
expect(area.getText()).toEqual('(none)');
browser.wait(wait(500), 600);

area.sendKeys('u');
browser.wait(protractor.until.elementTextIs(area, "U"), 5000);
expect(area.getText()).toEqual("U");
});
});

0 comments on commit eee2146

Please sign in to comment.