@coorpacademy/app-review 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/es/actions/api/fetch-rank.js +5 -1
  2. package/es/actions/ui/quit-popin.d.ts +8 -0
  3. package/es/actions/ui/quit-popin.js +8 -0
  4. package/es/index.d.ts +0 -1
  5. package/es/reducers/data/rank.d.ts +4 -3
  6. package/es/reducers/data/rank.js +9 -18
  7. package/es/reducers/index.d.ts +7 -1
  8. package/es/reducers/ui/index.d.ts +11 -1
  9. package/es/reducers/ui/index.js +5 -1
  10. package/es/reducers/ui/navigation.js +0 -1
  11. package/es/reducers/ui/positions.js +3 -1
  12. package/es/reducers/ui/quit-popin.d.ts +4 -0
  13. package/es/reducers/ui/quit-popin.js +16 -0
  14. package/es/reducers/ui/show-congrats.d.ts +5 -0
  15. package/es/reducers/ui/show-congrats.js +20 -0
  16. package/es/reducers/ui/slide.js +4 -1
  17. package/es/types/common.d.ts +10 -8
  18. package/es/views/slides/index.d.ts +67 -19
  19. package/es/views/slides/index.js +122 -6
  20. package/lib/actions/api/fetch-rank.js +7 -1
  21. package/lib/actions/ui/quit-popin.d.ts +8 -0
  22. package/lib/actions/ui/quit-popin.js +8 -0
  23. package/lib/index.d.ts +0 -1
  24. package/lib/reducers/data/rank.d.ts +4 -3
  25. package/lib/reducers/data/rank.js +9 -18
  26. package/lib/reducers/index.d.ts +7 -1
  27. package/lib/reducers/ui/index.d.ts +11 -1
  28. package/lib/reducers/ui/index.js +5 -1
  29. package/lib/reducers/ui/navigation.js +0 -1
  30. package/lib/reducers/ui/positions.js +3 -1
  31. package/lib/reducers/ui/quit-popin.d.ts +4 -0
  32. package/lib/reducers/ui/quit-popin.js +17 -0
  33. package/lib/reducers/ui/show-congrats.d.ts +5 -0
  34. package/lib/reducers/ui/show-congrats.js +21 -0
  35. package/lib/reducers/ui/slide.js +4 -1
  36. package/lib/types/common.d.ts +10 -8
  37. package/lib/views/slides/index.d.ts +67 -19
  38. package/lib/views/slides/index.js +124 -6
  39. package/package.json +3 -3
  40. package/src/actions/api/fetch-rank.ts +8 -1
  41. package/src/actions/api/test/fetch-correction.test.ts +4 -2
  42. package/src/actions/api/test/fetch-rank.test.ts +17 -8
  43. package/src/actions/api/test/fetch-skills.test.ts +4 -2
  44. package/src/actions/api/test/fetch-slide.test.ts +4 -2
  45. package/src/actions/api/test/post-answer.test.ts +9 -10
  46. package/src/actions/api/test/post-progression.test.ts +4 -2
  47. package/src/actions/data/test/token.test.ts +4 -2
  48. package/src/actions/ui/quit-popin.ts +10 -0
  49. package/src/actions/ui/test/answers.test.ts +4 -2
  50. package/src/actions/ui/test/next-slide.test.ts +5 -2
  51. package/src/actions/ui/test/quit-popin.test.ts +39 -0
  52. package/src/actions/ui/test/slides.test.ts +4 -2
  53. package/src/reducers/data/rank.ts +15 -31
  54. package/src/reducers/data/test/rank.test.ts +33 -52
  55. package/src/reducers/ui/index.ts +7 -1
  56. package/src/reducers/ui/navigation.ts +0 -2
  57. package/src/reducers/ui/positions.ts +3 -1
  58. package/src/reducers/ui/quit-popin.ts +22 -0
  59. package/src/reducers/ui/show-congrats.ts +26 -0
  60. package/src/reducers/ui/slide.ts +4 -2
  61. package/src/reducers/ui/test/positions.test.ts +14 -0
  62. package/src/reducers/ui/test/quit-popin.test.ts +24 -0
  63. package/src/reducers/ui/test/show-congrats.test.ts +40 -0
  64. package/src/reducers/ui/test/slide.test.ts +21 -0
  65. package/src/types/common.ts +12 -8
  66. package/src/views/skills/test/skills.test.ts +8 -4
  67. package/src/views/slides/index.ts +207 -27
  68. package/src/views/slides/test/header.on-click.test.ts +46 -0
  69. package/src/views/slides/test/index.test.ts +335 -25
  70. package/src/views/slides/test/on-quit-popin.on-click.test.ts +65 -0
  71. package/src/views/slides/test/slide.free-text.on-change.test.ts +4 -2
  72. package/src/views/slides/test/slide.next-slide.on-click.test.ts +107 -2
  73. package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +4 -2
  74. package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +4 -2
  75. package/src/views/slides/test/slide.qcm.on-click.test.ts +4 -2
  76. package/src/views/slides/test/slide.slider.on-change.test.ts +4 -2
  77. package/src/views/slides/test/slide.slider.on-slider-change.test.ts +4 -2
  78. package/src/views/slides/test/slide.template.on-change.test.ts +4 -2
@@ -10,7 +10,7 @@ import {
10
10
  getChoicesCorrection,
11
11
  incorrectFreeTextPostAnswerResponse
12
12
  } from '../../../test/util/services.mock';
13
- import {mapStateToSlidesProps} from '..';
13
+ import {CongratsCardProps, CongratsProps, mapStateToSlidesProps} from '..';
14
14
  import type {StoreState} from '../../../reducers';
15
15
  import {freeTextSlide} from './fixtures/free-text';
16
16
  import {qcmGraphicSlide} from './fixtures/qcm-graphic';
@@ -29,9 +29,10 @@ test('should create initial props when fetched slide is not still received', t =
29
29
  },
30
30
  token: '1234',
31
31
  corrections: {},
32
- rank: {}
32
+ rank: {start: Number.NaN, end: Number.NaN}
33
33
  },
34
34
  ui: {
35
+ showCongrats: false,
35
36
  currentSlideRef: '',
36
37
  navigation: ['loader', 'slides'],
37
38
  answers: {},
@@ -42,7 +43,8 @@ test('should create initial props when fetched slide is not still received', t =
42
43
  animateCorrectionPopin: false,
43
44
  showCorrectionPopin: false
44
45
  }
45
- }
46
+ },
47
+ showQuitPopin: false
46
48
  }
47
49
  };
48
50
 
@@ -120,9 +122,10 @@ test('should create props when first slide is on the state', t => {
120
122
  },
121
123
  token: '1234',
122
124
  corrections: {},
123
- rank: {}
125
+ rank: {start: Number.NaN, end: Number.NaN}
124
126
  },
125
127
  ui: {
128
+ showCongrats: false,
126
129
  currentSlideRef: 'sli_VJYjJnJhg',
127
130
  navigation: ['loader', 'slides'],
128
131
  answers: {},
@@ -133,7 +136,8 @@ test('should create props when first slide is on the state', t => {
133
136
  animateCorrectionPopin: false,
134
137
  showCorrectionPopin: false
135
138
  }
136
- }
139
+ },
140
+ showQuitPopin: false
137
141
  }
138
142
  };
139
143
 
@@ -226,9 +230,10 @@ test('should create props when slide is on the state and user has selected answe
226
230
  },
227
231
  token: '1234',
228
232
  corrections: {},
229
- rank: {}
233
+ rank: {start: 10, end: Number.NaN}
230
234
  },
231
235
  ui: {
236
+ showCongrats: false,
232
237
  currentSlideRef: 'sli_VJYjJnJhg',
233
238
  navigation: ['loader', 'slides'],
234
239
  answers: {sli_VJYjJnJhg: ['My value']},
@@ -239,7 +244,8 @@ test('should create props when slide is on the state and user has selected answe
239
244
  animateCorrectionPopin: false,
240
245
  showCorrectionPopin: false
241
246
  }
242
- }
247
+ },
248
+ showQuitPopin: false
243
249
  }
244
250
  };
245
251
 
@@ -333,9 +339,10 @@ test('should verify props when first slide was answered correctly and next slide
333
339
  },
334
340
  token: '1234',
335
341
  corrections: {},
336
- rank: {}
342
+ rank: {start: 10, end: Number.NaN}
337
343
  },
338
344
  ui: {
345
+ showCongrats: false,
339
346
  currentSlideRef: 'sli_VJYjJnJhg',
340
347
  navigation: ['loader', 'slides'],
341
348
  answers: {sli_VJYjJnJhg: ['My value']},
@@ -351,7 +358,8 @@ test('should verify props when first slide was answered correctly and next slide
351
358
  animateCorrectionPopin: false,
352
359
  showCorrectionPopin: false
353
360
  }
354
- }
361
+ },
362
+ showQuitPopin: false
355
363
  }
356
364
  };
357
365
 
@@ -449,9 +457,10 @@ test('should verify props when first slide was answered with error and next slid
449
457
  },
450
458
  token: '1234',
451
459
  corrections: {},
452
- rank: {}
460
+ rank: {start: 10, end: Number.NaN}
453
461
  },
454
462
  ui: {
463
+ showCongrats: false,
455
464
  currentSlideRef: 'sli_VJYjJnJhg',
456
465
  navigation: ['loader', 'slides'],
457
466
  answers: {sli_VJYjJnJhg: ['My value']},
@@ -467,7 +476,8 @@ test('should verify props when first slide was answered with error and next slid
467
476
  animateCorrectionPopin: false,
468
477
  showCorrectionPopin: false
469
478
  }
470
- }
479
+ },
480
+ showQuitPopin: false
471
481
  }
472
482
  };
473
483
 
@@ -522,9 +532,10 @@ test('should verify props when first slide was answered, next slide is fetched &
522
532
  corrections: {
523
533
  [freeTextSlide._id]: getChoicesCorrection(freeTextSlide._id)
524
534
  },
525
- rank: {}
535
+ rank: {start: 10, end: Number.NaN}
526
536
  },
527
537
  ui: {
538
+ showCongrats: false,
528
539
  currentSlideRef: 'sli_VJYjJnJhg',
529
540
  navigation: ['loader', 'slides'],
530
541
  answers: {sli_VJYjJnJhg: ['My value']},
@@ -540,7 +551,8 @@ test('should verify props when first slide was answered, next slide is fetched &
540
551
  animateCorrectionPopin: false,
541
552
  showCorrectionPopin: false
542
553
  }
543
- }
554
+ },
555
+ showQuitPopin: false
544
556
  }
545
557
  };
546
558
 
@@ -652,9 +664,10 @@ test('should verify props when first slide was answered incorrectly, next slide
652
664
  corrections: {
653
665
  [freeTextSlide._id]: getChoicesCorrection(freeTextSlide._id, true)
654
666
  },
655
- rank: {}
667
+ rank: {start: 10, end: Number.NaN}
656
668
  },
657
669
  ui: {
670
+ showCongrats: false,
658
671
  currentSlideRef: 'sli_VJYjJnJhg',
659
672
  navigation: ['loader', 'slides'],
660
673
  answers: {sli_VJYjJnJhg: ['My value']},
@@ -670,7 +683,8 @@ test('should verify props when first slide was answered incorrectly, next slide
670
683
  animateCorrectionPopin: false,
671
684
  showCorrectionPopin: false
672
685
  }
673
- }
686
+ },
687
+ showQuitPopin: false
674
688
  }
675
689
  };
676
690
 
@@ -785,9 +799,10 @@ test('should verify props when currentSlideRef has changed to nextContent of pro
785
799
  corrections: {
786
800
  [freeTextSlide._id]: getChoicesCorrection(freeTextSlide._id)
787
801
  },
788
- rank: {}
802
+ rank: {start: 10, end: Number.NaN}
789
803
  },
790
804
  ui: {
805
+ showCongrats: false,
791
806
  currentSlideRef: 'sli_VkSQroQnx',
792
807
  navigation: ['loader', 'slides'],
793
808
  answers: {
@@ -807,7 +822,8 @@ test('should verify props when currentSlideRef has changed to nextContent of pro
807
822
  animateCorrectionPopin: false,
808
823
  showCorrectionPopin: false
809
824
  }
810
- }
825
+ },
826
+ showQuitPopin: false
811
827
  }
812
828
  };
813
829
 
@@ -874,7 +890,7 @@ test('should verify props when currentSlideRef has changed to nextContent of pro
874
890
  });
875
891
  });
876
892
 
877
- test('should verify props when progression is in success', t => {
893
+ test('should verify props when progression is in success, showing last correction popin', t => {
878
894
  // state after receive last POST_ANSWER_SUCCESS and before last NEXT_SLIDE
879
895
  const state: StoreState = {
880
896
  data: {
@@ -895,9 +911,10 @@ test('should verify props when progression is in success', t => {
895
911
  [sliderSlide.universalRef]: getChoicesCorrection(sliderSlide._id),
896
912
  [templateSlide.universalRef]: getChoicesCorrection(templateSlide._id)
897
913
  },
898
- rank: {}
914
+ rank: {start: 10, end: Number.NaN}
899
915
  },
900
916
  ui: {
917
+ showCongrats: false,
901
918
  currentSlideRef: templateSlide.universalRef,
902
919
  navigation: ['loader', 'slides'],
903
920
  answers: {
@@ -938,7 +955,8 @@ test('should verify props when progression is in success', t => {
938
955
  animateCorrectionPopin: true,
939
956
  showCorrectionPopin: true
940
957
  }
941
- }
958
+ },
959
+ showQuitPopin: false
942
960
  }
943
961
  };
944
962
 
@@ -978,7 +996,263 @@ test('should verify props when progression is in success', t => {
978
996
  ]
979
997
  });
980
998
 
981
- // TODO update test with props.stack validations when NEXT_SLIDE implemented
999
+ t.deepEqual(omit(['next.onClick'], props.stack.correctionPopinProps), {
1000
+ information: {
1001
+ label: '_klf',
1002
+ message:
1003
+ 'L’apprenant peut aussi évaluer sa performance grâce à un classement disponible sur la vue leaderboard. Elle compare sa position par rapport à celle des autres apprenants de la plateforme.'
1004
+ },
1005
+ klf: undefined,
1006
+ next: {
1007
+ ariaLabel: '_correctionNextAriaLabel',
1008
+ label: '_correctionNextLabel'
1009
+ },
1010
+ resultLabel: '_right',
1011
+ type: 'right'
1012
+ });
1013
+ });
1014
+
1015
+ test('should verify props showing congrats', t => {
1016
+ const state: StoreState = {
1017
+ data: {
1018
+ progression: postAnswerResponses[templateSlide.universalRef],
1019
+ skills: [],
1020
+ slides: {
1021
+ [freeTextSlide.universalRef]: freeTextSlide,
1022
+ [qcmGraphicSlide.universalRef]: qcmGraphicSlide,
1023
+ [qcmSlide.universalRef]: qcmSlide,
1024
+ [sliderSlide.universalRef]: sliderSlide,
1025
+ [templateSlide.universalRef]: templateSlide
1026
+ },
1027
+ token: '1234',
1028
+ corrections: {
1029
+ [freeTextSlide._id]: getChoicesCorrection(freeTextSlide._id),
1030
+ [qcmGraphicSlide.universalRef]: getChoicesCorrection(qcmGraphicSlide._id),
1031
+ [qcmSlide.universalRef]: getChoicesCorrection(qcmSlide._id),
1032
+ [sliderSlide.universalRef]: getChoicesCorrection(sliderSlide._id),
1033
+ [templateSlide.universalRef]: getChoicesCorrection(templateSlide._id)
1034
+ },
1035
+ rank: {start: 10, end: 9}
1036
+ },
1037
+ ui: {
1038
+ showCongrats: true,
1039
+ showQuitPopin: false,
1040
+ currentSlideRef: 'successExitNode',
1041
+ navigation: ['loader', 'slides'],
1042
+ answers: {
1043
+ sli_VJYjJnJhg: ['Benchmark'],
1044
+ sli_VkSQroQnx: ['Faux'],
1045
+ sli_N1XACJobn: ['Le créateur peut fixer un pourcentage pour chaque transaction future'],
1046
+ sli_VkAzsCLKb: ['7'],
1047
+ 'sli_N13-hG3kX': ['Leaderboard', 'utilisateurs', 'étoiles']
1048
+ },
1049
+ positions: [-1, -1, -1, -1, 0],
1050
+ slide: {
1051
+ sli_VJYjJnJhg: {
1052
+ validateButton: false,
1053
+ animateCorrectionPopin: false,
1054
+ showCorrectionPopin: false,
1055
+ animationType: 'unstack'
1056
+ },
1057
+ sli_VkSQroQnx: {
1058
+ validateButton: false,
1059
+ animateCorrectionPopin: false,
1060
+ showCorrectionPopin: false,
1061
+ animationType: 'unstack'
1062
+ },
1063
+ sli_N1XACJobn: {
1064
+ validateButton: false,
1065
+ animateCorrectionPopin: false,
1066
+ showCorrectionPopin: false,
1067
+ animationType: 'unstack'
1068
+ },
1069
+ sli_VkAzsCLKb: {
1070
+ validateButton: false,
1071
+ animateCorrectionPopin: false,
1072
+ showCorrectionPopin: false,
1073
+ animationType: 'unstack'
1074
+ },
1075
+ 'sli_N13-hG3kX': {
1076
+ validateButton: false,
1077
+ animateCorrectionPopin: true,
1078
+ showCorrectionPopin: false,
1079
+ animationType: 'unstack'
1080
+ }
1081
+ }
1082
+ }
1083
+ };
1084
+
1085
+ const props = mapStateToSlidesProps(state, identity, identity);
1086
+ const congrats = props.congrats as CongratsProps;
1087
+ t.is(congrats.title, 'Congratulations!');
1088
+ t.is(
1089
+ congrats.animationLottie.animationSrc,
1090
+ 'https://static-staging.coorpacademy.com/animations/review/confetti.json'
1091
+ );
1092
+ const {cardCongratsStar, buttonRevising, buttonRevisingSkill} = congrats;
1093
+ const cardCongratsRank = congrats.cardCongratsRank as CongratsCardProps;
1094
+ t.deepEqual(
1095
+ {
1096
+ animationLottie: cardCongratsRank.animationLottie,
1097
+ rankSuffix: cardCongratsRank.rankSuffix,
1098
+ reviewCardTitle: cardCongratsRank.reviewCardTitle,
1099
+ reviewCardValue: cardCongratsRank.reviewCardValue
1100
+ },
1101
+ {
1102
+ animationLottie: {
1103
+ animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',
1104
+ 'aria-label': 'aria lottie',
1105
+ autoplay: true,
1106
+ 'data-name': 'default-lottie',
1107
+ ie11ImageBackup:
1108
+ 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg',
1109
+ loop: true
1110
+ },
1111
+ rankSuffix: 'th',
1112
+ reviewCardTitle: 'You are now',
1113
+ reviewCardValue: '9'
1114
+ }
1115
+ );
1116
+ t.deepEqual(
1117
+ {
1118
+ animationLottie: cardCongratsStar.animationLottie,
1119
+ rankSuffix: cardCongratsStar.rankSuffix,
1120
+ reviewCardTitle: cardCongratsStar.reviewCardTitle,
1121
+ reviewCardValue: cardCongratsStar.reviewCardValue
1122
+ },
1123
+ {
1124
+ animationLottie: {
1125
+ animationSrc: 'https://static-staging.coorpacademy.com/animations/review/star.json',
1126
+ 'aria-label': 'aria lottie',
1127
+ autoplay: undefined,
1128
+ className: undefined,
1129
+ 'data-name': 'default-lottie',
1130
+ ie11ImageBackup:
1131
+ 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg',
1132
+ loop: false,
1133
+ rendererSettings: {
1134
+ hideOnTransparent: false
1135
+ }
1136
+ },
1137
+ rankSuffix: undefined,
1138
+ reviewCardTitle: 'You have won',
1139
+ reviewCardValue: '40'
1140
+ }
1141
+ );
1142
+
1143
+ t.is(buttonRevising, undefined);
1144
+ t.is(buttonRevisingSkill, undefined);
1145
+ });
1146
+
1147
+ test('should verify props showing congrats, with only stars card, if user has no earn positions on raking', t => {
1148
+ const state: StoreState = {
1149
+ data: {
1150
+ progression: postAnswerResponses[templateSlide.universalRef],
1151
+ skills: [],
1152
+ slides: {
1153
+ [freeTextSlide.universalRef]: freeTextSlide,
1154
+ [qcmGraphicSlide.universalRef]: qcmGraphicSlide,
1155
+ [qcmSlide.universalRef]: qcmSlide,
1156
+ [sliderSlide.universalRef]: sliderSlide,
1157
+ [templateSlide.universalRef]: templateSlide
1158
+ },
1159
+ token: '1234',
1160
+ corrections: {
1161
+ [freeTextSlide._id]: getChoicesCorrection(freeTextSlide._id),
1162
+ [qcmGraphicSlide.universalRef]: getChoicesCorrection(qcmGraphicSlide._id),
1163
+ [qcmSlide.universalRef]: getChoicesCorrection(qcmSlide._id),
1164
+ [sliderSlide.universalRef]: getChoicesCorrection(sliderSlide._id),
1165
+ [templateSlide.universalRef]: getChoicesCorrection(templateSlide._id)
1166
+ },
1167
+ rank: {start: 10, end: 10}
1168
+ },
1169
+ ui: {
1170
+ showCongrats: true,
1171
+ showQuitPopin: false,
1172
+ currentSlideRef: 'successExitNode',
1173
+ navigation: ['loader', 'slides'],
1174
+ answers: {
1175
+ sli_VJYjJnJhg: ['Benchmark'],
1176
+ sli_VkSQroQnx: ['Faux'],
1177
+ sli_N1XACJobn: ['Le créateur peut fixer un pourcentage pour chaque transaction future'],
1178
+ sli_VkAzsCLKb: ['7'],
1179
+ 'sli_N13-hG3kX': ['Leaderboard', 'utilisateurs', 'étoiles']
1180
+ },
1181
+ positions: [-1, -1, -1, -1, 0],
1182
+ slide: {
1183
+ sli_VJYjJnJhg: {
1184
+ validateButton: false,
1185
+ animateCorrectionPopin: false,
1186
+ showCorrectionPopin: false,
1187
+ animationType: 'unstack'
1188
+ },
1189
+ sli_VkSQroQnx: {
1190
+ validateButton: false,
1191
+ animateCorrectionPopin: false,
1192
+ showCorrectionPopin: false,
1193
+ animationType: 'unstack'
1194
+ },
1195
+ sli_N1XACJobn: {
1196
+ validateButton: false,
1197
+ animateCorrectionPopin: false,
1198
+ showCorrectionPopin: false,
1199
+ animationType: 'unstack'
1200
+ },
1201
+ sli_VkAzsCLKb: {
1202
+ validateButton: false,
1203
+ animateCorrectionPopin: false,
1204
+ showCorrectionPopin: false,
1205
+ animationType: 'unstack'
1206
+ },
1207
+ 'sli_N13-hG3kX': {
1208
+ validateButton: false,
1209
+ animateCorrectionPopin: true,
1210
+ showCorrectionPopin: false,
1211
+ animationType: 'unstack'
1212
+ }
1213
+ }
1214
+ }
1215
+ };
1216
+
1217
+ const props = mapStateToSlidesProps(state, identity, identity);
1218
+ const congrats = props.congrats as CongratsProps;
1219
+ t.is(congrats.title, 'Congratulations!');
1220
+ t.is(
1221
+ congrats.animationLottie.animationSrc,
1222
+ 'https://static-staging.coorpacademy.com/animations/review/confetti.json'
1223
+ );
1224
+ const {cardCongratsStar, buttonRevising, buttonRevisingSkill} = congrats;
1225
+ t.deepEqual(
1226
+ {
1227
+ animationLottie: cardCongratsStar.animationLottie,
1228
+ rankSuffix: cardCongratsStar.rankSuffix,
1229
+ reviewCardTitle: cardCongratsStar.reviewCardTitle,
1230
+ reviewCardValue: cardCongratsStar.reviewCardValue
1231
+ },
1232
+ {
1233
+ animationLottie: {
1234
+ animationSrc: 'https://static-staging.coorpacademy.com/animations/review/star.json',
1235
+ 'aria-label': 'aria lottie',
1236
+ autoplay: undefined,
1237
+ className: undefined,
1238
+ 'data-name': 'default-lottie',
1239
+ ie11ImageBackup:
1240
+ 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg',
1241
+ loop: false,
1242
+ rendererSettings: {
1243
+ hideOnTransparent: false
1244
+ }
1245
+ },
1246
+ rankSuffix: undefined,
1247
+ reviewCardTitle: 'You have won',
1248
+ reviewCardValue: '40'
1249
+ }
1250
+ );
1251
+ const cardCongratsRank = congrats.cardCongratsRank;
1252
+ t.is(cardCongratsRank, undefined);
1253
+
1254
+ t.is(buttonRevising, undefined);
1255
+ t.is(buttonRevisingSkill, undefined);
982
1256
  });
983
1257
 
984
1258
  test('should verify props when progression has answered a current pendingSlide', t => {
@@ -1002,9 +1276,10 @@ test('should verify props when progression has answered a current pendingSlide',
1002
1276
  [sliderSlide.universalRef]: getChoicesCorrection(sliderSlide._id),
1003
1277
  [templateSlide.universalRef]: getChoicesCorrection(templateSlide._id)
1004
1278
  },
1005
- rank: {}
1279
+ rank: {start: 10, end: Number.NaN}
1006
1280
  },
1007
1281
  ui: {
1282
+ showCongrats: false,
1008
1283
  currentSlideRef: freeTextSlide.universalRef,
1009
1284
  navigation: ['loader', 'slides'],
1010
1285
  answers: {
@@ -1045,7 +1320,8 @@ test('should verify props when progression has answered a current pendingSlide',
1045
1320
  showCorrectionPopin: false,
1046
1321
  animationType: 'unstack'
1047
1322
  }
1048
- }
1323
+ },
1324
+ showQuitPopin: false
1049
1325
  }
1050
1326
  };
1051
1327
 
@@ -1106,9 +1382,10 @@ test('should verify props when progression still has a pendingSlide', t => {
1106
1382
  [sliderSlide.universalRef]: getChoicesCorrection(sliderSlide._id),
1107
1383
  [templateSlide.universalRef]: getChoicesCorrection(templateSlide._id)
1108
1384
  },
1109
- rank: {}
1385
+ rank: {start: 10, end: Number.NaN}
1110
1386
  },
1111
1387
  ui: {
1388
+ showCongrats: false,
1112
1389
  currentSlideRef: qcmSlide.universalRef,
1113
1390
  navigation: ['loader', 'slides'],
1114
1391
  answers: {
@@ -1149,7 +1426,8 @@ test('should verify props when progression still has a pendingSlide', t => {
1149
1426
  showCorrectionPopin: false,
1150
1427
  animationType: 'unstack'
1151
1428
  }
1152
- }
1429
+ },
1430
+ showQuitPopin: false
1153
1431
  }
1154
1432
  };
1155
1433
 
@@ -1188,3 +1466,35 @@ test('should verify props when progression still has a pendingSlide', t => {
1188
1466
  ]
1189
1467
  });
1190
1468
  });
1469
+
1470
+ test('should verify that props quitPopin is not undefined when popin is displayed', t => {
1471
+ const state: StoreState = {
1472
+ data: {
1473
+ progression: createdProgression,
1474
+ skills: [],
1475
+ slides: {
1476
+ sli_N1XACJobn: null
1477
+ },
1478
+ token: '1234',
1479
+ corrections: {},
1480
+ rank: {start: Number.NaN, end: Number.NaN}
1481
+ },
1482
+ ui: {
1483
+ showCongrats: false,
1484
+ currentSlideRef: '',
1485
+ navigation: ['loader', 'slides'],
1486
+ answers: {},
1487
+ positions: [0, 1, 2, 3, 4],
1488
+ slide: {
1489
+ sli_N1XACJobn: {
1490
+ validateButton: false,
1491
+ animateCorrectionPopin: false,
1492
+ showCorrectionPopin: false
1493
+ }
1494
+ },
1495
+ showQuitPopin: true
1496
+ }
1497
+ };
1498
+ const props = mapStateToSlidesProps(state, identity, identity);
1499
+ t.not(props.quitPopin, undefined);
1500
+ });
@@ -0,0 +1,65 @@
1
+ import test from 'ava';
2
+ import identity from 'lodash/fp/identity';
3
+ import {createTestStore} from '../../../actions/test/create-test-store';
4
+ import {CLOSE_POPIN} from '../../../actions/ui/quit-popin';
5
+ import {incorrectFreeTextPostAnswerResponse, services} from '../../../test/util/services.mock';
6
+ import {StoreState} from '../../../reducers';
7
+ import {mapStateToSlidesProps, QuitPopinProps} from '..';
8
+ import {freeTextSlide} from './fixtures/free-text';
9
+ import {qcmGraphicSlide} from './fixtures/qcm-graphic';
10
+
11
+ const state: StoreState = {
12
+ data: {
13
+ progression: incorrectFreeTextPostAnswerResponse,
14
+ skills: [],
15
+ slides: {
16
+ sli_VJYjJnJhg: freeTextSlide,
17
+ sli_VkSQroQnx: qcmGraphicSlide
18
+ },
19
+ token: '1234',
20
+ corrections: {},
21
+ rank: {start: 10, end: Number.NaN}
22
+ },
23
+ ui: {
24
+ showCongrats: false,
25
+ currentSlideRef: 'sli_VJYjJnJhg',
26
+ navigation: ['loader', 'slides'],
27
+ answers: {sli_VJYjJnJhg: ['My value']},
28
+ positions: [0, 1, 2, 3, 4],
29
+ slide: {
30
+ sli_VJYjJnJhg: {
31
+ validateButton: false,
32
+ animateCorrectionPopin: true,
33
+ showCorrectionPopin: true
34
+ },
35
+ sli_VkSQroQnx: {
36
+ validateButton: false,
37
+ animateCorrectionPopin: false,
38
+ showCorrectionPopin: false
39
+ }
40
+ },
41
+ showQuitPopin: true
42
+ }
43
+ };
44
+
45
+ test('should dispatch CLOSE_POPIN action via the property handleOnclick of secondButton when popin is open', async t => {
46
+ const expectedAction = [{type: CLOSE_POPIN}];
47
+ const {dispatch, getState} = createTestStore(t, state, services, expectedAction);
48
+ const props = mapStateToSlidesProps(getState(), dispatch, identity);
49
+ const quitPopin = props.quitPopin as QuitPopinProps;
50
+ await quitPopin.secondButton.handleOnclick();
51
+ const updatedState = getState();
52
+ t.is(updatedState.ui.showQuitPopin, false);
53
+ t.pass();
54
+ });
55
+
56
+ test('should dispatch onQuitClick function via the property handleOnclick of firstButton when popin is open', async t => {
57
+ t.plan(2);
58
+
59
+ const expectedAction = [{type: CLOSE_POPIN}];
60
+ const {dispatch, getState} = createTestStore(t, state, services, expectedAction);
61
+ const props = mapStateToSlidesProps(getState(), dispatch, () => t.pass());
62
+ const quitPopin = props.quitPopin as QuitPopinProps;
63
+ await quitPopin.firstButton.handleOnclick();
64
+ t.pass();
65
+ });
@@ -53,9 +53,10 @@ const initialState: StoreState = {
53
53
  skills: [],
54
54
  token: '1234',
55
55
  corrections: {},
56
- rank: {}
56
+ rank: {start: 10, end: Number.NaN}
57
57
  },
58
58
  ui: {
59
+ showCongrats: false,
59
60
  currentSlideRef: freeTextSlide._id,
60
61
  navigation: ['skills', 'slides'],
61
62
  answers: {},
@@ -66,7 +67,8 @@ const initialState: StoreState = {
66
67
  animateCorrectionPopin: false,
67
68
  showCorrectionPopin: false
68
69
  }
69
- }
70
+ },
71
+ showQuitPopin: false
70
72
  }
71
73
  };
72
74