@@ -426,6 +426,241 @@ test('create a poll with only one day and multiple times', function(assert) {
426
426
} ) ;
427
427
} ) ;
428
428
429
+ test ( 'create a poll with only one day (without time)' , function ( assert ) {
430
+ let day = moment ( ) . add ( 1 , 'day' ) ;
431
+ const dayFormat = moment . localeData ( ) . longDateFormat ( 'LLLL' )
432
+ . replace (
433
+ moment . localeData ( ) . longDateFormat ( 'LT' ) , '' )
434
+ . trim ( ) ;
435
+
436
+ pageCreateIndex
437
+ . visit ( ) ;
438
+
439
+ andThen ( function ( ) {
440
+ pageCreateIndex
441
+ . next ( ) ;
442
+
443
+ andThen ( function ( ) {
444
+ assert . equal ( currentPath ( ) , 'create.meta' ) ;
445
+
446
+ pageCreateMeta
447
+ . title ( 'default poll' )
448
+ . description ( 'a sample description' )
449
+ . next ( ) ;
450
+
451
+ andThen ( function ( ) {
452
+ assert . equal ( currentPath ( ) , 'create.options' ) ;
453
+
454
+ pageCreateOptions
455
+ . dateOptions ( [ day ] ) ;
456
+ pageCreateOptions
457
+ . next ( ) ;
458
+
459
+ andThen ( function ( ) {
460
+ assert . equal ( currentPath ( ) , 'create.options-datetime' ) ;
461
+
462
+ assert . deepEqual (
463
+ pageCreateOptionsDatetime . days ( ) . labels ,
464
+ [ day . format ( dayFormat ) ] ,
465
+ 'time inputs having days as label'
466
+ ) ;
467
+
468
+ pageCreateOptionsDatetime
469
+ . next ( ) ;
470
+ andThen ( function ( ) {
471
+ assert . equal ( currentPath ( ) , 'create.settings' ) ;
472
+
473
+ pageCreateSettings
474
+ . next ( ) ;
475
+
476
+ andThen ( function ( ) {
477
+ assert . equal ( currentPath ( ) , 'poll.participation' ) ;
478
+ assert . ok (
479
+ pagePollParticipation . urlIsValid ( ) === true ,
480
+ 'poll url is valid'
481
+ ) ;
482
+ assert . equal (
483
+ pagePollParticipation . title ,
484
+ 'default poll' ,
485
+ 'poll title is correct'
486
+ ) ;
487
+ assert . equal (
488
+ pagePollParticipation . description ,
489
+ 'a sample description' ,
490
+ 'poll description is correct'
491
+ ) ;
492
+ assert . deepEqual (
493
+ pagePollParticipation . options ( ) . labels ,
494
+ [
495
+ day . format ( dayFormat )
496
+ ] ,
497
+ 'options are correctly labeled'
498
+ ) ;
499
+ } ) ;
500
+ } ) ;
501
+ } ) ;
502
+ } ) ;
503
+ } ) ;
504
+ } ) ;
505
+ } ) ;
506
+
507
+ test ( 'create a poll with only one day (with time)' , function ( assert ) {
508
+ let day = moment ( ) . add ( 1 , 'day' ) ;
509
+ const dayFormat = moment . localeData ( ) . longDateFormat ( 'LLLL' )
510
+ . replace (
511
+ moment . localeData ( ) . longDateFormat ( 'LT' ) , '' )
512
+ . trim ( ) ;
513
+
514
+ pageCreateIndex
515
+ . visit ( ) ;
516
+
517
+ andThen ( function ( ) {
518
+ pageCreateIndex
519
+ . next ( ) ;
520
+
521
+ andThen ( function ( ) {
522
+ assert . equal ( currentPath ( ) , 'create.meta' ) ;
523
+
524
+ pageCreateMeta
525
+ . title ( 'default poll' )
526
+ . description ( 'a sample description' )
527
+ . next ( ) ;
528
+
529
+ andThen ( function ( ) {
530
+ assert . equal ( currentPath ( ) , 'create.options' ) ;
531
+
532
+ pageCreateOptions
533
+ . dateOptions ( [ day ] ) ;
534
+ pageCreateOptions
535
+ . next ( ) ;
536
+
537
+ andThen ( function ( ) {
538
+ assert . equal ( currentPath ( ) , 'create.options-datetime' ) ;
539
+
540
+ assert . deepEqual (
541
+ pageCreateOptionsDatetime . days ( ) . labels ,
542
+ [ day . format ( dayFormat ) ] ,
543
+ 'time inputs having days as label'
544
+ ) ;
545
+
546
+ pageCreateOptionsDatetime
547
+ . days ( 0 ) . times ( 0 ) . time ( '22:30' ) ;
548
+ pageCreateOptionsDatetime
549
+ . next ( ) ;
550
+
551
+ andThen ( function ( ) {
552
+ assert . equal ( currentPath ( ) , 'create.settings' ) ;
553
+
554
+ pageCreateSettings
555
+ . next ( ) ;
556
+
557
+ andThen ( function ( ) {
558
+ assert . equal ( currentPath ( ) , 'poll.participation' ) ;
559
+ assert . ok (
560
+ pagePollParticipation . urlIsValid ( ) === true ,
561
+ 'poll url is valid'
562
+ ) ;
563
+ assert . equal (
564
+ pagePollParticipation . title ,
565
+ 'default poll' ,
566
+ 'poll title is correct'
567
+ ) ;
568
+ assert . equal (
569
+ pagePollParticipation . description ,
570
+ 'a sample description' ,
571
+ 'poll description is correct'
572
+ ) ;
573
+ assert . deepEqual (
574
+ pagePollParticipation . options ( ) . labels ,
575
+ [
576
+ day . hour ( 22 ) . minute ( 30 ) . format ( 'LLLL' )
577
+ ] ,
578
+ 'options are correctly labeled'
579
+ ) ;
580
+ } ) ;
581
+ } ) ;
582
+ } ) ;
583
+ } ) ;
584
+ } ) ;
585
+ } ) ;
586
+ } ) ;
587
+
588
+ test ( 'create a poll for answering a question with only one option' , function ( assert ) {
589
+ pageCreateIndex
590
+ . visit ( ) ;
591
+
592
+ andThen ( function ( ) {
593
+ pageCreateIndex
594
+ . pollType ( 'MakeAPoll' )
595
+ . next ( ) ;
596
+
597
+ andThen ( function ( ) {
598
+ assert . equal ( currentPath ( ) , 'create.meta' ) ;
599
+
600
+ pageCreateMeta
601
+ . title ( 'default poll' )
602
+ . next ( ) ;
603
+
604
+ andThen ( function ( ) {
605
+ assert . equal ( currentPath ( ) , 'create.options' ) ;
606
+ expectComponent ( 'create-options-text' ) ;
607
+
608
+ assert . equal (
609
+ pageCreateOptions . textOptions ( ) . count ,
610
+ 2 ,
611
+ 'there are two input fields as default'
612
+ ) ;
613
+
614
+ pageCreateOptions
615
+ . textOptions ( 0 ) . title ( 'option a' ) ;
616
+ pageCreateOptions
617
+ . textOptions ( 1 ) . delete ( ) ;
618
+
619
+ andThen ( function ( ) {
620
+ assert . equal (
621
+ pageCreateOptions . textOptions ( ) . count ,
622
+ 1 ,
623
+ 'option was deleted'
624
+ ) ;
625
+
626
+ pageCreateOptions
627
+ . next ( ) ;
628
+
629
+ andThen ( function ( ) {
630
+ assert . equal ( currentPath ( ) , 'create.settings' ) ;
631
+
632
+ pageCreateSettings
633
+ . next ( ) ;
634
+
635
+ andThen ( function ( ) {
636
+ assert . equal ( currentPath ( ) , 'poll.participation' ) ;
637
+ assert . ok (
638
+ pagePollParticipation . urlIsValid ( ) === true ,
639
+ 'poll url is valid'
640
+ ) ;
641
+ assert . equal (
642
+ pagePollParticipation . title ,
643
+ 'default poll' ,
644
+ 'poll title is correct'
645
+ ) ;
646
+ assert . equal (
647
+ pagePollParticipation . description ,
648
+ '' ,
649
+ 'poll description is correct'
650
+ ) ;
651
+ assert . deepEqual (
652
+ pagePollParticipation . options ( ) . labels ,
653
+ [ 'option a' ] ,
654
+ 'options are labeled correctly'
655
+ ) ;
656
+ } ) ;
657
+ } ) ;
658
+ } ) ;
659
+ } ) ;
660
+ } ) ;
661
+ } ) ;
662
+ } ) ;
663
+
429
664
test ( 'create a poll and using back button (find a date)' , function ( assert ) {
430
665
let days = [
431
666
moment ( ) . add ( 1 , 'day' ) ,
0 commit comments