Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
chore(angular): upgrade angular to version 1.3.
Browse files Browse the repository at this point in the history
This change updates Protractor's test application from 1.2.9 to 1.3.0-r0.

There is a significant behind-the-scenes change in the implementation of locating
elements and waiting for the page to be stable. If you are updating your application
to Angular 1.3, you may run into some changes you will need to make in your tests:

 - `by.binding` no longer allows using the surrounding `{{}}`. Previously, these
    were optional.
    Before: `var el = element(by.binding('{{foo}}'))`
    After: `var el = element(by.binding('foo'))`

 - Prefixes `ng_` and `x-ng-` are no longer allowed for models. Use `ng-model`.

 - `by.repeater` cannot find elements by row and column which are not children
   of the row. For example, if your template is
   `<div ng-repeat="foo in foos">{{foo.name}}</div>`
   Before: `var el = element(by.repeater('foo in foos').row(2).column('foo.name'))`
   After: You may either enclose `{{foo.name}}` in a child element or simply use:
   `var el = element(by.repeater('foo in foos').row(2))`
  • Loading branch information
juliemr committed Sep 5, 2014
1 parent ee82f9e commit 7bd2dde
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 52 deletions.
2 changes: 1 addition & 1 deletion lib/clientsidescripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ functions.findByModel = function(model, using, rootSelector) {

if (angular.getTestability) {
return angular.getTestability(using).
findModels(using, model);
findModels(using, model, true);
}
var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];
for (var p = 0; p < prefixes.length; ++p) {
Expand Down
6 changes: 3 additions & 3 deletions spec/basic/lib_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ describe('protractor library', function() {
it('should get the absolute URL', function() {
browser.get('index.html');
expect(browser.getLocationAbsUrl()).
toMatch('index.html#/form');
toMatch('/form');

element(by.linkText('repeater')).click();
expect(browser.getLocationAbsUrl()).
toMatch('index.html#/repeater');
toMatch('/repeater');
});

it('should navigate to another url with setLocation', function() {
Expand All @@ -105,7 +105,7 @@ describe('protractor library', function() {
browser.setLocation('/repeater');

expect(browser.getLocationAbsUrl()).
toMatch('index.html#/repeater');
toMatch('/repeater');
});
});
});
38 changes: 5 additions & 33 deletions spec/basic/locators_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('locators', function() {

describe('by binding', function() {
it('should find an element by binding', function() {
var greeting = element(by.binding('{{greeting}}'));
var greeting = element(by.binding('greeting'));

expect(greeting.getText()).toEqual('Hiya');
});
Expand All @@ -19,11 +19,11 @@ describe('locators', function() {
}
});

expect(element(by.binding('{{greeting}}'))).toHaveText('Hiya');
expect(element(by.binding('greeting'))).toHaveText('Hiya');
});

it('ElementFinder.then should resolve to itself', function() {
var elem = element(by.binding('{{greeting}}'));
var elem = element(by.binding('greeting'));

elem.then(function(elem2) {
expect(elem).toEqual(elem2);
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('locators', function() {

it('should find an element by binding with ng-bind-template attribute',
function() {
var name = element(by.binding('{{nickname|uppercase}}'));
var name = element(by.binding('nickname|uppercase'));

expect(name.getText()).toEqual('(ANNIE)');
});
Expand Down Expand Up @@ -116,12 +116,6 @@ describe('locators', function() {

element(by.model('check.x')).click();
expect(letterList.getText()).toBe('wx');

element(by.model('check.y')).click();
expect(letterList.getText()).toBe('wxy');

element(by.model('check.z')).click();
expect(letterList.getText()).toBe('wxyz');
});

it('should find multiple inputs', function() {
Expand Down Expand Up @@ -182,7 +176,7 @@ describe('locators', function() {
it('should find by partial match', function() {
var fullMatch = element(
by.repeater('baz in days | filter:\'T\'').
row(0).column('{{baz.initial}}'));
row(0).column('baz.initial'));
expect(fullMatch.getText()).toEqual('T');

var partialMatch = element(
Expand Down Expand Up @@ -274,28 +268,6 @@ describe('locators', function() {
expect(byCol.getText()).toEqual('W');
});

it('should find using ng_repeat', function() {
var byRow =
element(by.repeater('foo in days').row(2));
expect(byRow.getText()).toEqual('W');

var byCol =
element(by.repeater('foo in days').row(2).
column('foo'));
expect(byCol.getText()).toEqual('W');
});

it('should find using x-ng-repeat', function() {
var byRow =
element(by.repeater('qux in days').row(2));
expect(byRow.getText()).toEqual('W');

var byCol =
element(by.repeater('qux in days').row(2).
column('qux'));
expect(byCol.getText()).toEqual('W');
});

it('should determine if repeater elements are present', function() {
expect(element(by.repeater('allinfo in days').row(3)).isPresent()).
toBe(true);
Expand Down
5 changes: 5 additions & 0 deletions spec/basicConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ exports.config = {

baseUrl: env.baseUrl,

jasmineNodeOpts: {
isVerbose: true,
realtimeFailure: true
},

params: {
login: {
user: 'Jane',
Expand Down
8 changes: 3 additions & 5 deletions testapp/form/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ <h4>Selects</h4>
<h4>Checkboxes</h4>
<input ng-model="show" type="checkbox"/> Show?
<span id="shower" ng-show="show">Shown!!</span>
<input ng:model="check.w" ng-true-value="w" type="checkbox"/> W
<input data-ng-model="check.x" ng-true-value="x" type="checkbox"/> X
<input x-ng-model="check.y" ng-true-value="y" type="checkbox"/> Y
<input ng_model="check.z" ng-true-value="z" type="checkbox"/> Z
<input ng:model="check.w" ng-true-value="'w'" type="checkbox"/> W
<input data-ng-model="check.x" ng-true-value="'x'" type="checkbox"/> X

<span id="letterlist">{{check.w}}{{check.x}}{{check.y}}{{check.z}}</span>
<span id="letterlist">{{check.w}}{{check.x}}</span>
</div>

<div>
Expand Down
6 changes: 3 additions & 3 deletions testapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

<div>Angular seed app: v<span app-version></span></div>

<script src="lib/angular_v1.2.9/angular.min.js"></script>
<script src="lib/angular_v1.2.9/angular-animate.min.js"></script>
<script src="lib/angular_v1.2.9/angular-route.min.js"></script>
<script src="lib/angular_v1.3.0-rc0/angular.min.js"></script>
<script src="lib/angular_v1.3.0-rc0/angular-animate.min.js"></script>
<script src="lib/angular_v1.3.0-rc0/angular-route.min.js"></script>

<script src="components/app-version.js"></script>
<script src="async/async.js"></script>
Expand Down
29 changes: 29 additions & 0 deletions testapp/lib/angular_v1.3.0-rc0/angular-animate.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7bd2dde

Please sign in to comment.