Skip to content

Commit 1d5df94

Browse files
committed
Merge pull request #3789 from PaulL1/e2e_upgrade
Fix(e2e): upgrade 101 and 102 tutorial syntax, fix return value of te…
2 parents 00375b3 + 7f3cdbe commit 1d5df94

File tree

5 files changed

+90
-87
lines changed

5 files changed

+90
-87
lines changed

misc/site/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ <h4 class="feature-heading">Standard Features</h4>
102102
<li>Sorting</li>
103103
<li>Filtering</li>
104104
<li>User interaction</li>
105+
<li>e2e testing integration</li>
105106
</ul>
106107
<h4 class="feature-heading">Advanced Features</h4>
107108
<ul>

misc/tutorial/101_intro.ngdoc

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,34 +105,30 @@ Steps:
105105
</file>
106106

107107
<file name="scenario.js">
108-
var gridTestUtils = require('../../test/e2e/gridTestUtils.spec.js');
109-
it('grid should have three visible rows', function () {
110-
gridTestUtils.expectRowCount( 'grid1', 3 );
111-
});
108+
var GridObjectTest = require('../../test/e2e/gridObjectTestUtils.spec.js');
109+
var grid1 = new GridObjectTest('grid1');
110+
describe('101 tutorial', function() {
111+
it('grid should have three visible rows', function () {
112+
grid1.expectRowCount( 3 );
113+
});
112114

113-
it('grid should have four visible columns', function () {
114-
gridTestUtils.expectHeaderColumnCount( 'grid1', 4 );
115-
});
115+
it('header values should be as expected', function () {
116+
grid1.expectHeaderColumns( ['First Name', 'Last Name', 'Company', 'Employed'] );
117+
});
116118

117-
it('header values should be as expected', function () {
118-
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 0, 'First Name' );
119-
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 1, 'Last Name' );
120-
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 2, 'Company' );
121-
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 3, 'Employed' );
122-
});
123-
124-
it('first row cell values should be as expected', function () {
125-
// checking individual cells usually gives a better stack trace when there are errors
126-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Cox' );
127-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 1, 'Carney' );
128-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 2, 'Enormo' );
129-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 3, 'true' );
130-
});
119+
it('first row cell values should be as expected', function () {
120+
// checking individual cells usually gives a better stack trace when there are errors
121+
grid1.expectCellValueMatch( 0, 0, 'Cox' );
122+
grid1.expectCellValueMatch( 0, 1, 'Carney' );
123+
grid1.expectCellValueMatch( 0, 2, 'Enormo' );
124+
grid1.expectCellValueMatch( 0, 3, 'true' );
125+
});
131126

132-
it('next two row cell values should be as expected', function () {
133-
// checking in bulk is convenient to write, but can be less informative with errors
134-
gridTestUtils.expectRowValuesMatch( 'grid1', 1, [ 'Lorraine', 'Wise', 'Comveyer', 'false' ] );
135-
gridTestUtils.expectRowValuesMatch( 'grid1', 2, [ 'Nancy', 'Waters', 'Fuelton', 'false' ] );
127+
it('next two row cell values should be as expected', function () {
128+
// checking in bulk is convenient to write, but can be less informative with errors
129+
grid1.expectRowValuesMatch( 1, [ 'Lorraine', 'Wise', 'Comveyer', 'false' ] );
130+
grid1.expectRowValuesMatch( 2, [ 'Nancy', 'Waters', 'Fuelton', 'false' ] );
131+
});
136132
});
137133
</file>
138134
</example>

misc/tutorial/102_sorting.ngdoc

Lines changed: 51 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -141,168 +141,159 @@ include `string`, `number`, `numberStr` and `date`. If you use date be aware th
141141
</file>
142142
<file name="scenario.js">
143143
var gridTestUtils = require('../../test/e2e/gridTestUtils.spec.js');
144+
var GridObjectTest = require('../../test/e2e/gridObjectTestUtils.spec.js');
145+
var grid1 = new GridObjectTest('grid1');
146+
var grid2 = new GridObjectTest('grid2');
144147

145148
describe('first grid on the page, no default sort', function() {
146149
// Reload the page before each test if on Firefox. Chrome does it automatically.
147150
gridTestUtils.firefoxReload();
148151

149-
it('grid should have three visible columns', function () {
150-
gridTestUtils.expectHeaderColumnCount( 'grid1', 3 );
151-
});
152-
153152
it('header values should be as expected', function () {
154-
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 0, 'Name' );
155-
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 1, 'Gender' );
156-
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 2, 'Company' );
153+
grid1.expectHeaderColumns( [ 'Name', 'Gender', 'Company' ] );
157154
});
158155

159156
it('grid should be unsorted by default', function () {
160-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Ethel Price' );
161-
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Claudine Neal' );
157+
grid1.expectCellValueMatch( 0, 0, 'Ethel Price' );
158+
grid1.expectCellValueMatch( 1, 0, 'Claudine Neal' );
162159
});
163160

164161
it('sort by name by clicking header', function () {
165-
gridTestUtils.clickHeaderCell( 'grid1', 0 )
162+
grid1.clickHeaderCell( 0 )
166163
.then(function () {
167-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alexander Foley' );
168-
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Alisha Myers' );
164+
grid1.expectCellValueMatch( 0, 0, 'Alexander Foley' );
165+
grid1.expectCellValueMatch( 1, 0, 'Alisha Myers' );
169166
});
170167
});
171168

172169
it('reverse sort by name by clicking header', function () {
173-
gridTestUtils.clickHeaderCell( 'grid1', 0 )
170+
grid1.clickHeaderCell( 0 )
174171
.then(function () {
175-
return gridTestUtils.clickHeaderCell( 'grid1', 0 );
172+
return grid1.clickHeaderCell( 0 );
176173
})
177174
.then(function () {
178-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Yvonne Parsons' );
179-
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Woods Key' );
175+
grid1.expectCellValueMatch( 0, 0, 'Yvonne Parsons' );
176+
grid1.expectCellValueMatch( 1, 0, 'Woods Key' );
180177
});
181178
});
182179

183180
it('return to original sort by name by clicking header', function () {
184-
gridTestUtils.clickHeaderCell( 'grid1', 0 )
181+
grid1.clickHeaderCell( 0 )
185182
.then(function () {
186-
return gridTestUtils.clickHeaderCell( 'grid1', 0 );
183+
return grid1.clickHeaderCell( 0 );
187184
})
188185
.then(function () {
189-
return gridTestUtils.clickHeaderCell( 'grid1', 0 );
186+
return grid1.clickHeaderCell( 0 );
190187
})
191188
.then(function () {
192-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Ethel Price' );
193-
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Claudine Neal' );
189+
grid1.expectCellValueMatch( 0, 0, 'Ethel Price' );
190+
grid1.expectCellValueMatch( 1, 0, 'Claudine Neal' );
194191
});
195192
});
196193

197194
it('sort asc by clicking menu', function() {
198-
gridTestUtils.clickColumnMenuSortAsc( 'grid1', 0 )
195+
grid1.clickColumnMenuSortAsc( 0 )
199196
.then(function () {
200-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alexander Foley' );
201-
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Alisha Myers' );
197+
grid1.expectCellValueMatch( 0, 0, 'Alexander Foley' );
198+
grid1.expectCellValueMatch( 1, 0, 'Alisha Myers' );
202199
});
203200
});
204201

205202
it('sort desc by clicking menu, then remove sort', function() {
206-
gridTestUtils.clickColumnMenuSortDesc( 'grid1', 0 )
203+
grid1.clickColumnMenuSortDesc( 0 )
207204
.then(function () {
208-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Yvonne Parsons' );
209-
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Woods Key' );
205+
grid1.expectCellValueMatch( 0, 0, 'Yvonne Parsons' );
206+
grid1.expectCellValueMatch( 1, 0, 'Woods Key' );
210207
return true;
211208
})
212209
.then(function () {
213-
return gridTestUtils.clickColumnMenuRemoveSort( 'grid1', 0 );
210+
return grid1.clickColumnMenuRemoveSort( 0 );
214211
})
215212
.then(function () {
216-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Ethel Price' );
217-
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Claudine Neal' );
213+
grid1.expectCellValueMatch( 0, 0, 'Ethel Price' );
214+
grid1.expectCellValueMatch( 1, 0, 'Claudine Neal' );
218215
});
219216
});
220217

221218
it('sort two columns, gender then name, by shift clicking', function() {
222-
gridTestUtils.clickHeaderCell( 'grid1', 1 )
219+
grid1.clickHeaderCell( 1 )
223220
.then(function () {
224-
return gridTestUtils.shiftClickHeaderCell( 'grid1', 0 );
221+
return grid1.shiftClickHeaderCell( 0 );
225222
})
226223
.then(function () {
227-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alisha Myers' );
228-
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Beryl Rice' );
224+
grid1.expectCellValueMatch( 0, 0, 'Alisha Myers' );
225+
grid1.expectCellValueMatch( 1, 0, 'Beryl Rice' );
229226
});
230227
});
231228

232229
it('sort disabled on last column', function() {
233-
gridTestUtils.clickHeaderCell( 'grid1', 2 )
230+
grid1.clickHeaderCell( 2 )
234231
.then(function () {
235-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Ethel Price' );
236-
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'Claudine Neal' );
232+
grid1.expectCellValueMatch( 0, 0, 'Ethel Price' );
233+
grid1.expectCellValueMatch( 1, 0, 'Claudine Neal' );
237234
});
238235
});
239236

240237
it('click one menu, then click another menu, expect undisplay and redisplay on second click', function() {
241-
gridTestUtils.expectVisibleColumnMenuItems( 'grid1', 0, 3 );
242-
gridTestUtils.expectVisibleColumnMenuItems( 'grid1', 1, 3 );
238+
grid1.expectVisibleColumnMenuItems( 0, 3 );
239+
grid1.expectVisibleColumnMenuItems( 1, 3 );
243240
});
244241

245242
it('toggle gender, expect Alexander Foley to move around', function() {
246243
// sort gender asc, then name
247-
gridTestUtils.clickHeaderCell( 'grid1', 1 )
244+
grid1.clickHeaderCell( 1 )
248245
.then(function () {
249-
return gridTestUtils.clickHeaderCell( 'grid1', 1 );
246+
return grid1.clickHeaderCell( 1 );
250247
})
251248
.then(function () {
252-
return gridTestUtils.shiftClickHeaderCell( 'grid1', 0 );
249+
return grid1.shiftClickHeaderCell( 0 );
253250
})
254251
.then(function () {
255-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alexander Foley' );
252+
grid1.expectCellValueMatch( 0, 0, 'Alexander Foley' );
256253
})
257254
.then(function () {
258255
return gridTestUtils.click(element(by.id('toggleGender')));
259256
})
260257
.then(function () {
261-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Anthony Joyner' );
258+
grid1.expectCellValueMatch( 0, 0, 'Anthony Joyner' );
262259
})
263260
.then(function () {
264261
return gridTestUtils.click(element(by.id('toggleGender')));
265262
})
266263
.then(function () {
267-
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'Alexander Foley' );
264+
grid1.expectCellValueMatch( 0, 0, 'Alexander Foley' );
268265
});
269266
});
270267

271268
});
272269

273270

274271
describe('second grid on the page, has default sort', function() {
275-
it('grid should have three visible columns', function () {
276-
gridTestUtils.expectHeaderColumnCount( 'grid2', 3 );
277-
});
278-
279272
it('header values should be as expected', function () {
280-
gridTestUtils.expectHeaderCellValueMatch( 'grid2', 0, 'Name' );
281-
gridTestUtils.expectHeaderCellValueMatch( 'grid2', 1, 'Gender' );
282-
gridTestUtils.expectHeaderCellValueMatch( 'grid2', 2, 'Company' );
273+
grid2.expectHeaderColumns( [ 'Name', 'Gender', 'Company' ] );
283274
});
284275

285276
it('grid should be sorted by default', function () {
286-
gridTestUtils.expectCellValueMatch( 'grid2', 0, 0, 'Yvonne Parsons' );
287-
gridTestUtils.expectCellValueMatch( 'grid2', 1, 0, 'Velma Fry' );
277+
grid2.expectCellValueMatch( 0, 0, 'Yvonne Parsons' );
278+
grid2.expectCellValueMatch( 1, 0, 'Velma Fry' );
288279
});
289280

290281
it('sort on second column can\'t be removed when cycle through header clicks', function () {
291-
gridTestUtils.clickHeaderCell( 'grid2', 0 )
282+
grid2.clickHeaderCell( 0 )
292283
.then(function () {
293-
gridTestUtils.expectCellValueMatch( 'grid2', 0, 0, 'Ethel Price' );
284+
grid2.expectCellValueMatch( 0, 0, 'Ethel Price' );
294285
})
295286
.then(function () {
296-
return gridTestUtils.clickHeaderCell( 'grid2', 1 );
287+
return grid2.clickHeaderCell( 1 );
297288
})
298289
.then(function () {
299-
gridTestUtils.expectCellValueMatch( 'grid2', 0, 0, 'Wilder Gonzales' );
290+
grid2.expectCellValueMatch( 0, 0, 'Wilder Gonzales' );
300291
})
301292
.then(function () {
302-
return gridTestUtils.clickHeaderCell( 'grid2', 1 );
293+
return grid2.clickHeaderCell( 1 );
303294
})
304295
.then(function () {
305-
gridTestUtils.expectCellValueMatch( 'grid2', 0, 0, 'Ethel Price' );
296+
grid2.expectCellValueMatch( 0, 0, 'Ethel Price' );
306297
});
307298
});
308299
});

misc/tutorial/403_end_to_end_testing.ngdoc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,19 @@ Within your tests you can then use the helper methods that are provided:
2222
gridTestUtils.expectRowCount( 'myGrid', 3 );
2323
</pre>
2424

25-
For documentation of the available methods, refer to {@link api/ui.grid.e2eTestLibrary.api:gridTest gridTest}
25+
For documentation of the available methods, refer to {@link api/ui.grid.e2eTestLibrary.api:gridTest gridTest}
26+
27+
Note that many of the tutorials (particularly those in the 100 series) have e2e tests on them,
28+
these can be found by looking at end to end test tab in the example on each of those tutorials.
29+
30+
Note also there is a newer syntax for providing the gridId, which is shown in the first few
31+
of those tutorials:
32+
33+
<pre>
34+
var GridObjectTest = require('../../test/e2e/gridObjectTestUtils.spec.js');
35+
var grid1 = new GridObjectTest('grid1');
36+
describe('101 tutorial', function() {
37+
it('grid should have three visible rows', function () {
38+
grid1.expectRowCount( 3 );
39+
});
40+
</pre>

test/e2e/gridObjectTestUtils.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var gridTestUtils = require('./gridTestUtils.spec.js');
55
function getProxyToRealMethod(gridId, method) {
66
return function() {
77
var callArgs = [gridId].concat(Array.prototype.slice.call(arguments));
8-
gridTestUtils[method].apply(gridTestUtils, callArgs);
8+
return gridTestUtils[method].apply(gridTestUtils, callArgs);
99
};
1010
}
1111

0 commit comments

Comments
 (0)