Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 3ace81b

Browse files
committed
fix(e2e tests): use prop() instead of attr() and quote attributes
Because of changes in jQuery, we need to use element().prop() instead of element().attr() to retrieve className and other element properties. Additionally all attribute selectors (e.g. input[name=value]) must have value quoted if it contains dots (".").
1 parent 9acf451 commit 3ace81b

File tree

8 files changed

+63
-61
lines changed

8 files changed

+63
-61
lines changed

docs/content/cookbook/advancedform.ngdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ master.$equals(form)}}">Save</button>
9090
expect(element(':button:contains(Cancel)').attr('disabled')).toBeFalsy();
9191
element(':button:contains(Cancel)').click();
9292
expect(element(':button:contains(Cancel)').attr('disabled')).toBeTruthy();
93-
expect(element(':input[name=form.name]').val()).toEqual('John Smith');
93+
expect(element(':input[name="form.name"]').val()).toEqual('John Smith');
9494
});
9595
</doc:scenario>
9696
</doc:example>

docs/content/cookbook/form.ngdoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@ ng:validate="regexp:zip"/><br/><br/>
6868
});
6969

7070
it('should validate zip', function(){
71-
expect(using('.example').element(':input[name=user.address.zip]').attr('className'))
71+
expect(using('.example').element(':input[name="user.address.zip"]').prop('className'))
7272
.not().toMatch(/ng-validation-error/);
7373
using('.example').input('user.address.zip').enter('abc');
74-
expect(using('.example').element(':input[name=user.address.zip]').attr('className'))
74+
expect(using('.example').element(':input[name="user.address.zip"]').prop('className'))
7575
.toMatch(/ng-validation-error/);
7676
});
7777

7878
it('should validate state', function(){
79-
expect(using('.example').element(':input[name=user.address.state]').attr('className'))
79+
expect(using('.example').element(':input[name="user.address.state"]').prop('className'))
8080
.not().toMatch(/ng-validation-error/);
8181
using('.example').input('user.address.state').enter('XXX');
82-
expect(using('.example').element(':input[name=user.address.state]').attr('className'))
82+
expect(using('.example').element(':input[name="user.address.state"]').prop('className'))
8383
.toMatch(/ng-validation-error/);
8484
});
8585
</doc:scenario>

src/Angular.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,8 @@ function isLeafNode (node) {
613613
* </doc:source>
614614
* <doc:scenario>
615615
it('should print that initialy the form object is NOT equal to master', function() {
616-
expect(element('.doc-example-live input[name=master.salutation]').val()).toBe('Hello');
617-
expect(element('.doc-example-live input[name=master.name]').val()).toBe('world');
616+
expect(element('.doc-example-live input[name="master.salutation"]').val()).toBe('Hello');
617+
expect(element('.doc-example-live input[name="master.name"]').val()).toBe('world');
618618
expect(element('.doc-example-live span').css('display')).toBe('inline');
619619
});
620620
@@ -705,8 +705,8 @@ function copy(source, destination){
705705
* </doc:source>
706706
* <doc:scenario>
707707
it('should print that initialy greeting is equal to the hardcoded value object', function() {
708-
expect(element('.doc-example-live input[name=greeting.salutation]').val()).toBe('Hello');
709-
expect(element('.doc-example-live input[name=greeting.name]').val()).toBe('world');
708+
expect(element('.doc-example-live input[name="greeting.salutation"]').val()).toBe('Hello');
709+
expect(element('.doc-example-live input[name="greeting.name"]').val()).toBe('world');
710710
expect(element('.doc-example-live span').css('display')).toBe('none');
711711
});
712712

src/directives.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -588,17 +588,17 @@ function ngClass(selector) {
588588
</doc:source>
589589
<doc:scenario>
590590
it('should check ng:class', function(){
591-
expect(element('.doc-example-live span').attr('className')).not().
591+
expect(element('.doc-example-live span').prop('className')).not().
592592
toMatch(/ng-input-indicator-wait/);
593593
594594
using('.doc-example-live').element(':button:first').click();
595595
596-
expect(element('.doc-example-live span').attr('className')).
596+
expect(element('.doc-example-live span').prop('className')).
597597
toMatch(/ng-input-indicator-wait/);
598598
599599
using('.doc-example-live').element(':button:last').click();
600600
601-
expect(element('.doc-example-live span').attr('className')).not().
601+
expect(element('.doc-example-live span').prop('className')).not().
602602
toMatch(/ng-input-indicator-wait/);
603603
});
604604
</doc:scenario>
@@ -637,9 +637,9 @@ angularDirective("ng:class", ngClass(function(){return true;}));
637637
</doc:source>
638638
<doc:scenario>
639639
it('should check ng:class-odd and ng:class-even', function(){
640-
expect(element('.doc-example-live li:first span').attr('className')).
640+
expect(element('.doc-example-live li:first span').prop('className')).
641641
toMatch(/ng-format-negative/);
642-
expect(element('.doc-example-live li:last span').attr('className')).
642+
expect(element('.doc-example-live li:last span').prop('className')).
643643
toMatch(/ng-input-indicator-wait/);
644644
});
645645
</doc:scenario>
@@ -678,9 +678,9 @@ angularDirective("ng:class-odd", ngClass(function(i){return i % 2 === 0;}));
678678
</doc:source>
679679
<doc:scenario>
680680
it('should check ng:class-odd and ng:class-even', function(){
681-
expect(element('.doc-example-live li:first span').attr('className')).
681+
expect(element('.doc-example-live li:first span').prop('className')).
682682
toMatch(/ng-format-negative/);
683-
expect(element('.doc-example-live li:last span').attr('className')).
683+
expect(element('.doc-example-live li:last span').prop('className')).
684684
toMatch(/ng-input-indicator-wait/);
685685
});
686686
</doc:scenario>
@@ -796,7 +796,7 @@ angularDirective("ng:hide", function(expression, element){
796796
it('should check ng:style', function(){
797797
expect(element('.doc-example-live span').css('color')).toBe('rgb(0, 0, 0)');
798798
element('.doc-example-live :button[value=set]').click();
799-
expect(element('.doc-example-live span').css('color')).toBe('red');
799+
expect(element('.doc-example-live span').css('color')).toBe('rgb(255, 0, 0)');
800800
element('.doc-example-live :button[value=clear]').click();
801801
expect(element('.doc-example-live span').css('color')).toBe('rgb(0, 0, 0)');
802802
});

src/filters.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
input('amount').enter('-1234');
6262
expect(binding('amount | currency')).toBe('($1,234.00)');
6363
expect(binding('amount | currency:"USD$"')).toBe('(USD$1,234.00)');
64-
expect(element('.doc-example-live .ng-binding').attr('className')).
64+
expect(element('.doc-example-live .ng-binding').prop('className')).
6565
toMatch(/ng-format-negative/);
6666
});
6767
</doc:scenario>

src/markups.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ angularTextMarkup('option', function(text, textNode, parentElement){
266266
</doc:source>
267267
<doc:scenario>
268268
it('should toggle button', function() {
269-
expect(element('.doc-example-live :button').attr('disabled')).toBeFalsy();
269+
expect(element('.doc-example-live :button').prop('disabled')).toBeFalsy();
270270
input('checked').check();
271-
expect(element('.doc-example-live :button').attr('disabled')).toBeTruthy();
271+
expect(element('.doc-example-live :button').prop('disabled')).toBeTruthy();
272272
});
273273
</doc:scenario>
274274
</doc:example>
@@ -296,9 +296,9 @@ angularTextMarkup('option', function(text, textNode, parentElement){
296296
</doc:source>
297297
<doc:scenario>
298298
it('should check both checkBoxes', function() {
299-
expect(element('.doc-example-live #checkSlave').attr('checked')).toBeFalsy();
299+
expect(element('.doc-example-live #checkSlave').prop('checked')).toBeFalsy();
300300
input('master').check();
301-
expect(element('.doc-example-live #checkSlave').attr('checked')).toBeTruthy();
301+
expect(element('.doc-example-live #checkSlave').prop('checked')).toBeTruthy();
302302
});
303303
</doc:scenario>
304304
</doc:example>
@@ -332,9 +332,9 @@ angularTextMarkup('option', function(text, textNode, parentElement){
332332
</doc:source>
333333
<doc:scenario>
334334
it('should toggle multiple', function() {
335-
expect(element('.doc-example-live #select').attr('multiple')).toBeFalsy();
335+
expect(element('.doc-example-live #select').prop('multiple')).toBeFalsy();
336336
input('checked').check();
337-
expect(element('.doc-example-live #select').attr('multiple')).toBeTruthy();
337+
expect(element('.doc-example-live #select').prop('multiple')).toBeTruthy();
338338
});
339339
</doc:scenario>
340340
</doc:example>
@@ -362,9 +362,9 @@ angularTextMarkup('option', function(text, textNode, parentElement){
362362
</doc:source>
363363
<doc:scenario>
364364
it('should toggle readonly attr', function() {
365-
expect(element('.doc-example-live :text').attr('readonly')).toBeFalsy();
365+
expect(element('.doc-example-live :text').prop('readonly')).toBeFalsy();
366366
input('checked').check();
367-
expect(element('.doc-example-live :text').attr('readonly')).toBeTruthy();
367+
expect(element('.doc-example-live :text').prop('readonly')).toBeTruthy();
368368
});
369369
</doc:scenario>
370370
</doc:example>
@@ -395,9 +395,9 @@ angularTextMarkup('option', function(text, textNode, parentElement){
395395
</doc:source>
396396
<doc:scenario>
397397
it('should select Greetings!', function() {
398-
expect(element('.doc-example-live #greet').attr('selected')).toBeFalsy();
398+
expect(element('.doc-example-live #greet').prop('selected')).toBeFalsy();
399399
input('checked').check();
400-
expect(element('.doc-example-live #greet').attr('selected')).toBeTruthy();
400+
expect(element('.doc-example-live #greet').prop('selected')).toBeTruthy();
401401
});
402402
</doc:scenario>
403403
</doc:example>

src/validators.js

+29-29
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ extend(angularValidator, {
6161
<doc:scenario>
6262
it('should invalidate non ssn', function(){
6363
var textBox = element('.doc-example-live :input');
64-
expect(textBox.attr('className')).not().toMatch(/ng-validation-error/);
64+
expect(textBox.prop('className')).not().toMatch(/ng-validation-error/);
6565
expect(textBox.val()).toEqual('123-45-6789');
6666
input('ssn').enter('123-45-67890');
67-
expect(textBox.attr('className')).toMatch(/ng-validation-error/);
67+
expect(textBox.prop('className')).toMatch(/ng-validation-error/);
6868
});
6969
</doc:scenario>
7070
</doc:example>
@@ -102,17 +102,17 @@ extend(angularValidator, {
102102
<doc:scenario>
103103
it('should invalidate number', function(){
104104
var n1 = element('.doc-example-live :input[name=n1]');
105-
expect(n1.attr('className')).not().toMatch(/ng-validation-error/);
105+
expect(n1.prop('className')).not().toMatch(/ng-validation-error/);
106106
input('n1').enter('1.x');
107-
expect(n1.attr('className')).toMatch(/ng-validation-error/);
107+
expect(n1.prop('className')).toMatch(/ng-validation-error/);
108108
var n2 = element('.doc-example-live :input[name=n2]');
109-
expect(n2.attr('className')).not().toMatch(/ng-validation-error/);
109+
expect(n2.prop('className')).not().toMatch(/ng-validation-error/);
110110
input('n2').enter('9');
111-
expect(n2.attr('className')).toMatch(/ng-validation-error/);
111+
expect(n2.prop('className')).toMatch(/ng-validation-error/);
112112
var n3 = element('.doc-example-live :input[name=n3]');
113-
expect(n3.attr('className')).not().toMatch(/ng-validation-error/);
113+
expect(n3.prop('className')).not().toMatch(/ng-validation-error/);
114114
input('n3').enter('201');
115-
expect(n3.attr('className')).toMatch(/ng-validation-error/);
115+
expect(n3.prop('className')).toMatch(/ng-validation-error/);
116116
});
117117
</doc:scenario>
118118
</doc:example>
@@ -156,17 +156,17 @@ extend(angularValidator, {
156156
<doc:scenario>
157157
it('should invalidate integer', function(){
158158
var n1 = element('.doc-example-live :input[name=n1]');
159-
expect(n1.attr('className')).not().toMatch(/ng-validation-error/);
159+
expect(n1.prop('className')).not().toMatch(/ng-validation-error/);
160160
input('n1').enter('1.1');
161-
expect(n1.attr('className')).toMatch(/ng-validation-error/);
161+
expect(n1.prop('className')).toMatch(/ng-validation-error/);
162162
var n2 = element('.doc-example-live :input[name=n2]');
163-
expect(n2.attr('className')).not().toMatch(/ng-validation-error/);
163+
expect(n2.prop('className')).not().toMatch(/ng-validation-error/);
164164
input('n2').enter('10.1');
165-
expect(n2.attr('className')).toMatch(/ng-validation-error/);
165+
expect(n2.prop('className')).toMatch(/ng-validation-error/);
166166
var n3 = element('.doc-example-live :input[name=n3]');
167-
expect(n3.attr('className')).not().toMatch(/ng-validation-error/);
167+
expect(n3.prop('className')).not().toMatch(/ng-validation-error/);
168168
input('n3').enter('100.1');
169-
expect(n3.attr('className')).toMatch(/ng-validation-error/);
169+
expect(n3.prop('className')).toMatch(/ng-validation-error/);
170170
});
171171
</doc:scenario>
172172
</doc:example>
@@ -200,9 +200,9 @@ extend(angularValidator, {
200200
<doc:scenario>
201201
it('should invalidate date', function(){
202202
var n1 = element('.doc-example-live :input');
203-
expect(n1.attr('className')).not().toMatch(/ng-validation-error/);
203+
expect(n1.prop('className')).not().toMatch(/ng-validation-error/);
204204
input('text').enter('123/123/123');
205-
expect(n1.attr('className')).toMatch(/ng-validation-error/);
205+
expect(n1.prop('className')).toMatch(/ng-validation-error/);
206206
});
207207
</doc:scenario>
208208
</doc:example>
@@ -238,9 +238,9 @@ extend(angularValidator, {
238238
<doc:scenario>
239239
it('should invalidate email', function(){
240240
var n1 = element('.doc-example-live :input');
241-
expect(n1.attr('className')).not().toMatch(/ng-validation-error/);
241+
expect(n1.prop('className')).not().toMatch(/ng-validation-error/);
242242
input('text').enter('a@b.c');
243-
expect(n1.attr('className')).toMatch(/ng-validation-error/);
243+
expect(n1.prop('className')).toMatch(/ng-validation-error/);
244244
});
245245
</doc:scenario>
246246
</doc:example>
@@ -272,9 +272,9 @@ extend(angularValidator, {
272272
<doc:scenario>
273273
it('should invalidate phone', function(){
274274
var n1 = element('.doc-example-live :input');
275-
expect(n1.attr('className')).not().toMatch(/ng-validation-error/);
275+
expect(n1.prop('className')).not().toMatch(/ng-validation-error/);
276276
input('text').enter('+12345678');
277-
expect(n1.attr('className')).toMatch(/ng-validation-error/);
277+
expect(n1.prop('className')).toMatch(/ng-validation-error/);
278278
});
279279
</doc:scenario>
280280
</doc:example>
@@ -310,9 +310,9 @@ extend(angularValidator, {
310310
<doc:scenario>
311311
it('should invalidate url', function(){
312312
var n1 = element('.doc-example-live :input');
313-
expect(n1.attr('className')).not().toMatch(/ng-validation-error/);
313+
expect(n1.prop('className')).not().toMatch(/ng-validation-error/);
314314
input('text').enter('abc://server/path');
315-
expect(n1.attr('className')).toMatch(/ng-validation-error/);
315+
expect(n1.prop('className')).toMatch(/ng-validation-error/);
316316
});
317317
</doc:scenario>
318318
</doc:example>
@@ -345,9 +345,9 @@ extend(angularValidator, {
345345
<doc:scenario>
346346
it('should invalidate json', function(){
347347
var n1 = element('.doc-example-live :input');
348-
expect(n1.attr('className')).not().toMatch(/ng-validation-error/);
348+
expect(n1.prop('className')).not().toMatch(/ng-validation-error/);
349349
input('json').enter('{name}');
350-
expect(n1.attr('className')).toMatch(/ng-validation-error/);
350+
expect(n1.prop('className')).toMatch(/ng-validation-error/);
351351
});
352352
</doc:scenario>
353353
</doc:example>
@@ -417,13 +417,13 @@ extend(angularValidator, {
417417
<doc:scenario>
418418
it('should change color in delayed way', function(){
419419
var textBox = element('.doc-example-live :input');
420-
expect(textBox.attr('className')).not().toMatch(/ng-input-indicator-wait/);
421-
expect(textBox.attr('className')).not().toMatch(/ng-validation-error/);
420+
expect(textBox.prop('className')).not().toMatch(/ng-input-indicator-wait/);
421+
expect(textBox.prop('className')).not().toMatch(/ng-validation-error/);
422422
input('text').enter('X');
423-
expect(textBox.attr('className')).toMatch(/ng-input-indicator-wait/);
423+
expect(textBox.prop('className')).toMatch(/ng-input-indicator-wait/);
424424
sleep(.6);
425-
expect(textBox.attr('className')).not().toMatch(/ng-input-indicator-wait/);
426-
expect(textBox.attr('className')).toMatch(/ng-validation-error/);
425+
expect(textBox.prop('className')).not().toMatch(/ng-input-indicator-wait/);
426+
expect(textBox.prop('className')).toMatch(/ng-validation-error/);
427427
});
428428
</doc:scenario>
429429
</doc:example>

src/widgets.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ function compileFormatter(expr) {
244244
</doc:source>
245245
<doc:scenario>
246246
it('should check ng:validate', function(){
247-
expect(element('.doc-example-live :input:last').attr('className')).
247+
expect(element('.doc-example-live :input:last').prop('className')).
248248
toMatch(/ng-validation-error/);
249249
250250
input('value').enter('123');
251-
expect(element('.doc-example-live :input:last').attr('className')).
251+
expect(element('.doc-example-live :input:last').prop('className')).
252252
not().toMatch(/ng-validation-error/);
253253
});
254254
</doc:scenario>
@@ -276,9 +276,11 @@ function compileFormatter(expr) {
276276
</doc:source>
277277
<doc:scenario>
278278
it('should check ng:required', function(){
279-
expect(element('.doc-example-live :input').attr('className')).toMatch(/ng-validation-error/);
279+
expect(element('.doc-example-live :input').prop('className')).
280+
toMatch(/ng-validation-error/);
280281
input('value').enter('123');
281-
expect(element('.doc-example-live :input').attr('className')).not().toMatch(/ng-validation-error/);
282+
expect(element('.doc-example-live :input').prop('className')).
283+
not().toMatch(/ng-validation-error/);
282284
});
283285
</doc:scenario>
284286
</doc:example>

0 commit comments

Comments
 (0)