@@ -185,6 +185,86 @@ 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
+ var params2 = '?per_page=100' ;
239
+
240
+ return this . remote
241
+ . setFindTimeout ( intern . config . wc . pageLoadTimeout )
242
+ . get ( require . toUrl ( url + params ) )
243
+ . findByCssSelector ( '.js-dropdown-pagination .js-dropdown-toggle h1' ) . getVisibleText ( )
244
+ . then ( function ( text ) {
245
+ assert . equal ( text , 'Show 25' , 'Pagination dropdown label is updated from URL params' ) ;
246
+ } )
247
+ . end ( )
248
+ // Select "Show 100" from pagination dropdown
249
+ . findByCssSelector ( '.js-dropdown-pagination .js-dropdown-toggle' ) . click ( )
250
+ . end ( )
251
+ . findByCssSelector ( '.js-dropdown-pagination li.Dropdown-item:nth-child(3) > a:nth-child(1)' ) . click ( )
252
+ . end ( )
253
+ // find something so we know issues have been loaded
254
+ . findByCssSelector ( '.IssueItem:nth-of-type(1)' )
255
+ . goBack ( )
256
+ . getCurrentUrl ( )
257
+ . then ( function ( currUrl ) {
258
+ assert . include ( currUrl , 'per_page=25' , 'URL param is back to where we started' ) ;
259
+ } )
260
+ . end ( )
261
+ . findByCssSelector ( '.js-dropdown-pagination .js-dropdown-toggle h1' ) . getVisibleText ( )
262
+ . then ( function ( text ) {
263
+ assert . equal ( text , 'Show 25' , 'Pagination dropdown label is back to where we started' ) ;
264
+ } )
265
+ . end ( )
266
+ }
267
+
188
268
// 'clicking on a label performs a label search': function() {
189
269
// return this.remote
190
270
// .setFindTimeout(intern.config.wc.pageLoadTimeout)
0 commit comments