@@ -185,6 +185,137 @@ define([
185
185
. end ( ) ;
186
186
} ,
187
187
188
+ 'loading issues page has default params in URL' : function ( ) {
189
+ return this . remote
190
+ . setFindTimeout ( intern . config . wc . pageLoadTimeout )
191
+ . get ( require . toUrl ( url ) )
192
+ // find something so we know the page has loaded
193
+ . findByCssSelector ( '.IssueItem:nth-of-type(1)' )
194
+ . getCurrentUrl ( )
195
+ . then ( function ( currUrl ) {
196
+ assert . include ( currUrl , 'page=1&per_page=50&state=open' , 'Default model params are added to the URL' ) ;
197
+ } ) ;
198
+ } ,
199
+
200
+ 'loading partial params results in merge with defaults' : function ( ) {
201
+ var params = '?page=2' ;
202
+ return this . remote
203
+ . setFindTimeout ( intern . config . wc . pageLoadTimeout )
204
+ . get ( require . toUrl ( url + params ) )
205
+ // find something so we know the page has loaded
206
+ . findByCssSelector ( '.IssueItem:nth-of-type(1)' )
207
+ . getCurrentUrl ( )
208
+ . then ( function ( currUrl ) {
209
+ assert . include ( currUrl , 'page=2&per_page=50&state=open' , 'Default model params are merged with partial URL params' ) ;
210
+ } ) ;
211
+ } ,
212
+
213
+ 'dropdowns reflect state from URL' : function ( ) {
214
+ var params = '?per_page=25&sort=updated&direction=desc&state=all' ;
215
+
216
+ return this . remote
217
+ . setFindTimeout ( intern . config . wc . pageLoadTimeout )
218
+ . get ( require . toUrl ( url + params ) )
219
+ . findByCssSelector ( '.js-dropdown-pagination .js-dropdown-toggle h1' ) . getVisibleText ( )
220
+ . then ( function ( text ) {
221
+ assert . equal ( text , 'Show 25' , 'Pagination dropdown label is updated from URL params' ) ;
222
+ } )
223
+ . end ( )
224
+ . findAllByCssSelector ( '.js-issuelist-filter .js-dropdown-toggle h1' ) . getVisibleText ( )
225
+ . then ( function ( text ) {
226
+ assert . equal ( text , 'View all Issues' , 'Filter dropdown label is updated from URL params' ) ;
227
+ } )
228
+ . end ( )
229
+ . findAllByCssSelector ( '.js-dropdown-sort .js-dropdown-toggle h1' ) . getVisibleText ( )
230
+ . then ( function ( text ) {
231
+ assert . equal ( text , 'Recently Updated' , 'Sort dropdown label is updated from URL params' ) ;
232
+ } )
233
+ . end ( ) ;
234
+ } ,
235
+
236
+ 'going back in history updates issue list and URL state' : function ( ) {
237
+ var params = '?per_page=25' ;
238
+
239
+ return this . remote
240
+ . setFindTimeout ( intern . config . wc . pageLoadTimeout )
241
+ . get ( require . toUrl ( url + params ) )
242
+ . findByCssSelector ( '.js-dropdown-pagination .js-dropdown-toggle h1' ) . getVisibleText ( )
243
+ . then ( function ( text ) {
244
+ assert . equal ( text , 'Show 25' , 'Pagination dropdown label is updated from URL params' ) ;
245
+ } )
246
+ . end ( )
247
+ // Select "Show 100" from pagination dropdown
248
+ . findByCssSelector ( '.js-dropdown-pagination .js-dropdown-toggle' ) . click ( )
249
+ . end ( )
250
+ . findByCssSelector ( '.js-dropdown-pagination li.Dropdown-item:nth-child(3) > a:nth-child(1)' ) . click ( )
251
+ . end ( )
252
+ // find something so we know issues have been loaded
253
+ . findByCssSelector ( '.IssueItem:nth-of-type(1)' )
254
+ . goBack ( )
255
+ . getCurrentUrl ( )
256
+ . then ( function ( currUrl ) {
257
+ assert . include ( currUrl , 'per_page=25' , 'URL param is back to where we started' ) ;
258
+ } )
259
+ . end ( )
260
+ . findByCssSelector ( '.js-dropdown-pagination .js-dropdown-toggle h1' ) . getVisibleText ( )
261
+ . then ( function ( text ) {
262
+ assert . equal ( text , 'Show 25' , 'Pagination dropdown label is back to where we started' ) ;
263
+ } )
264
+ . end ( ) ;
265
+ } ,
266
+
267
+ 'clicking on a stage filter adds the correct param to the URL' : function ( ) {
268
+ return this . remote
269
+ . setFindTimeout ( intern . config . wc . pageLoadTimeout )
270
+ . get ( require . toUrl ( url ) )
271
+ . findByCssSelector ( '[data-filter="contactready"]' ) . click ( )
272
+ . end ( )
273
+ // find something so we know the page has loaded
274
+ . findByCssSelector ( '.IssueItem:nth-of-type(1)' )
275
+ . getCurrentUrl ( )
276
+ . then ( function ( currUrl ) {
277
+ assert . include ( currUrl , 'stage=contactready' , 'Stage filter added to URL correctly.' ) ;
278
+ } )
279
+ . end ( ) ;
280
+ } ,
281
+
282
+ 'toggling a stage filter doesn\'t leave the param in the URL' : function ( ) {
283
+ return this . remote
284
+ . setFindTimeout ( intern . config . wc . pageLoadTimeout )
285
+ . get ( require . toUrl ( url ) )
286
+ . findByCssSelector ( '[data-filter="closed"]' ) . click ( )
287
+ . end ( )
288
+ // find something so we know the page has loaded
289
+ . findByCssSelector ( '.IssueItem:nth-of-type(1)' )
290
+ . end ( )
291
+ . findByCssSelector ( '[data-filter="closed"]' ) . click ( )
292
+ . end ( )
293
+ . getCurrentUrl ( )
294
+ . then ( function ( currUrl ) {
295
+ assert . notInclude ( currUrl , 'stage=closed' , 'Stage filter added then removed from URL.' ) ;
296
+ } )
297
+ . end ( ) ;
298
+ } ,
299
+
300
+ 'toggling between stage filters results in last param in URL' : function ( ) {
301
+ return this . remote
302
+ . setFindTimeout ( intern . config . wc . pageLoadTimeout )
303
+ . get ( require . toUrl ( url ) )
304
+ . findByCssSelector ( '[data-filter="closed"]' ) . click ( )
305
+ . end ( )
306
+ // find something so we know the page has loaded
307
+ . findByCssSelector ( '.IssueItem:nth-of-type(1)' )
308
+ . end ( )
309
+ . findByCssSelector ( '[data-filter="sitewait"]' ) . click ( )
310
+ . end ( )
311
+ . getCurrentUrl ( )
312
+ . then ( function ( currUrl ) {
313
+ assert . include ( currUrl , 'stage=sitewait' , 'Stage filter added to URL correctly.' ) ;
314
+ assert . notInclude ( currUrl , 'stage=closed' , 'Stage removed from URL correctly.' ) ;
315
+ } )
316
+ . end ( ) ;
317
+ }
318
+
188
319
// 'clicking on a label performs a label search': function() {
189
320
// return this.remote
190
321
// .setFindTimeout(intern.config.wc.pageLoadTimeout)
0 commit comments