@@ -425,3 +425,107 @@ test('create a poll with only one day and multiple times', function(assert) {
425
425
} ) ;
426
426
} ) ;
427
427
} ) ;
428
+
429
+ test ( 'create a poll and using back button (find a date)' , function ( assert ) {
430
+ let days = [
431
+ moment ( ) . add ( 1 , 'day' ) ,
432
+ moment ( ) . add ( 1 , 'week' )
433
+ ] ;
434
+ const dayFormat = moment . localeData ( ) . longDateFormat ( 'LLLL' )
435
+ . replace (
436
+ moment . localeData ( ) . longDateFormat ( 'LT' ) , '' )
437
+ . trim ( ) ;
438
+
439
+ setupBrowserNavigationButtons ( ) ;
440
+
441
+ pageCreateIndex
442
+ . visit ( ) ;
443
+
444
+ andThen ( function ( ) {
445
+ pageCreateIndex
446
+ . next ( ) ;
447
+
448
+ andThen ( function ( ) {
449
+ assert . equal ( currentPath ( ) , 'create.meta' ) ;
450
+
451
+ pageCreateMeta
452
+ . title ( 'default poll' )
453
+ . description ( 'a sample description' )
454
+ . next ( ) ;
455
+
456
+ andThen ( function ( ) {
457
+ assert . equal ( currentPath ( ) , 'create.options' ) ;
458
+
459
+ pageCreateOptions
460
+ . dateOptions ( days ) ;
461
+ pageCreateOptions
462
+ . next ( ) ;
463
+
464
+ andThen ( function ( ) {
465
+ assert . equal ( currentPath ( ) , 'create.options-datetime' ) ;
466
+
467
+ assert . deepEqual (
468
+ pageCreateOptionsDatetime . days ( ) . labels ,
469
+ days . map ( ( day ) => day . format ( dayFormat ) ) ,
470
+ 'time inputs having days as label'
471
+ ) ;
472
+ pageCreateOptionsDatetime . days ( 1 ) . times ( 0 ) . time ( '10:00' ) ;
473
+
474
+ backButton ( ) ;
475
+
476
+ andThen ( ( ) => {
477
+ assert . equal ( currentPath ( ) , 'create.options' ) ;
478
+ assert . deepEqual (
479
+ pageCreateOptions . dateOptions ( ) . map ( ( date ) => date . toISOString ( ) ) ,
480
+ days . map ( ( day ) => day . toISOString ( ) ) ,
481
+ 'days are still present after back button is used'
482
+ ) ;
483
+
484
+ pageCreateOptions
485
+ . next ( ) ;
486
+
487
+ andThen ( ( ) => {
488
+ assert . equal ( currentPath ( ) , 'create.options-datetime' ) ;
489
+
490
+ pageCreateOptionsDatetime
491
+ . next ( ) ;
492
+
493
+ andThen ( function ( ) {
494
+ assert . equal ( currentPath ( ) , 'create.settings' ) ;
495
+
496
+ pageCreateSettings
497
+ . next ( ) ;
498
+
499
+ andThen ( function ( ) {
500
+ assert . equal ( currentPath ( ) , 'poll.participation' ) ;
501
+ assert . ok (
502
+ pagePollParticipation . urlIsValid ( ) === true ,
503
+ 'poll url is valid'
504
+ ) ;
505
+ assert . equal (
506
+ pagePollParticipation . title ,
507
+ 'default poll' ,
508
+ 'poll title is correct'
509
+ ) ;
510
+ assert . equal (
511
+ pagePollParticipation . description ,
512
+ 'a sample description' ,
513
+ 'poll description is correct'
514
+ ) ;
515
+ assert . deepEqual (
516
+ pagePollParticipation . options ( ) . labels ,
517
+ [
518
+ days [ 0 ] . format ( dayFormat ) ,
519
+ days [ 1 ] . hour ( 10 ) . minute ( 0 ) . format ( 'LLLL' )
520
+ ] ,
521
+ 'options are correctly labeled'
522
+ ) ;
523
+ } ) ;
524
+ } ) ;
525
+ } ) ;
526
+ } ) ;
527
+ } ) ;
528
+ } ) ;
529
+ } ) ;
530
+ } ) ;
531
+ } ) ;
0 commit comments