@coorpacademy/app-review 0.4.4 → 0.5.0

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 (72) hide show
  1. package/es/actions/ui/next-slide.d.ts +4 -2
  2. package/es/actions/ui/next-slide.js +7 -4
  3. package/es/actions/ui/slides.d.ts +2 -3
  4. package/es/common/index.d.ts +2 -0
  5. package/es/common/index.js +9 -0
  6. package/es/reducers/index.d.ts +2 -1
  7. package/es/reducers/ui/answers.d.ts +2 -2
  8. package/es/reducers/ui/current-slide-ref.d.ts +3 -2
  9. package/es/reducers/ui/current-slide-ref.js +3 -0
  10. package/es/reducers/ui/index.d.ts +4 -1
  11. package/es/reducers/ui/index.js +3 -1
  12. package/es/reducers/ui/positions.d.ts +5 -0
  13. package/es/reducers/ui/positions.js +25 -0
  14. package/es/reducers/ui/slide.d.ts +2 -2
  15. package/es/views/slides/index.d.ts +2 -3
  16. package/es/views/slides/index.js +16 -24
  17. package/lib/actions/ui/next-slide.d.ts +4 -2
  18. package/lib/actions/ui/next-slide.js +7 -4
  19. package/lib/actions/ui/slides.d.ts +2 -3
  20. package/lib/common/index.d.ts +2 -0
  21. package/lib/common/index.js +9 -0
  22. package/lib/reducers/index.d.ts +2 -1
  23. package/lib/reducers/ui/answers.d.ts +2 -2
  24. package/lib/reducers/ui/current-slide-ref.d.ts +3 -2
  25. package/lib/reducers/ui/current-slide-ref.js +3 -0
  26. package/lib/reducers/ui/index.d.ts +4 -1
  27. package/lib/reducers/ui/index.js +3 -1
  28. package/lib/reducers/ui/positions.d.ts +5 -0
  29. package/lib/reducers/ui/positions.js +26 -0
  30. package/lib/reducers/ui/slide.d.ts +2 -2
  31. package/lib/views/slides/index.d.ts +2 -3
  32. package/lib/views/slides/index.js +16 -25
  33. package/package.json +7 -6
  34. package/src/actions/api/test/fetch-correction.test.ts +1 -0
  35. package/src/actions/api/test/fetch-rank.test.ts +1 -0
  36. package/src/actions/api/test/fetch-skills.test.ts +1 -0
  37. package/src/actions/api/test/fetch-slide.test.ts +1 -0
  38. package/src/actions/api/test/post-answer.test.ts +2 -0
  39. package/src/actions/api/test/post-progression.test.ts +1 -0
  40. package/src/actions/data/test/token.test.ts +1 -0
  41. package/src/actions/ui/next-slide.ts +15 -9
  42. package/src/actions/ui/slides.ts +2 -4
  43. package/src/actions/ui/test/answers.test.ts +1 -0
  44. package/src/actions/ui/test/next-slide.test.ts +7 -2
  45. package/src/actions/ui/test/slides.test.ts +1 -0
  46. package/src/common/index.ts +12 -0
  47. package/src/reducers/ui/answers.ts +2 -2
  48. package/src/reducers/ui/current-slide-ref.ts +5 -2
  49. package/src/reducers/ui/index.ts +4 -1
  50. package/src/reducers/ui/positions.ts +32 -0
  51. package/src/reducers/ui/slide.ts +7 -2
  52. package/src/reducers/ui/test/answers.test.ts +3 -1
  53. package/src/reducers/ui/test/current-slide-ref.test.ts +2 -2
  54. package/src/reducers/ui/test/positions.test.ts +68 -0
  55. package/src/reducers/ui/test/slide.test.ts +3 -1
  56. package/src/types/common.ts +0 -1
  57. package/src/views/skills/test/skills.test.ts +2 -0
  58. package/src/views/slides/index.ts +20 -31
  59. package/src/views/slides/test/index.test.ts +46 -40
  60. package/src/views/slides/test/slide.free-text.on-change.test.ts +1 -1
  61. package/src/views/slides/test/slide.next-slide.on-click.test.ts +8 -1
  62. package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +1 -1
  63. package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +1 -1
  64. package/src/views/slides/test/slide.qcm.on-click.test.ts +1 -1
  65. package/src/views/slides/test/slide.slider.on-change.test.ts +1 -1
  66. package/src/views/slides/test/slide.slider.on-slider-change.test.ts +15 -3
  67. package/src/views/slides/test/slide.template.on-change.test.ts +9 -10
  68. package/es/actions/ui/is-fetching.d.ts +0 -10
  69. package/es/actions/ui/is-fetching.js +0 -4
  70. package/lib/actions/ui/is-fetching.d.ts +0 -10
  71. package/lib/actions/ui/is-fetching.js +0 -4
  72. package/src/actions/ui/is-fetching.ts +0 -13
@@ -1,16 +1,14 @@
1
- import concat from 'lodash/fp/concat';
2
1
  import findLast from 'lodash/fp/findLast';
3
2
  import get from 'lodash/fp/get';
4
3
  import getOr from 'lodash/fp/getOr';
5
4
  import last from 'lodash/fp/last';
6
5
  import reduce from 'lodash/fp/reduce';
7
6
  import set from 'lodash/fp/set';
8
- import slice from 'lodash/fp/slice';
9
7
  import toInteger from 'lodash/fp/toInteger';
10
8
  import type {Dispatch} from 'redux';
11
9
  import join from 'lodash/fp/join';
12
- import type {ProgressionAnswerItem, ProgressionFromAPI} from '../../types/common';
13
- import type {SlideIndexes} from '../../common';
10
+ import type {ProgressionAnswerItem} from '../../types/common';
11
+ import {getProgressionSlidesRefs, type SlideIndexes} from '../../common';
14
12
  import type {StoreState} from '../../reducers';
15
13
  import type {AnswerUI} from '../../types/slides';
16
14
  import {postAnswer} from '../../actions/api/post-answer';
@@ -34,7 +32,6 @@ type StepItem = {
34
32
  type SlideUIAnimations = 'unstack' | 'restack';
35
33
 
36
34
  export type ReviewSlide = {
37
- hidden: boolean;
38
35
  position: number;
39
36
  loading: boolean;
40
37
  showCorrectionPopin?: boolean;
@@ -93,7 +90,7 @@ export type SlidesViewProps = {
93
90
  endReview: boolean;
94
91
  };
95
92
  reviewBackgroundAriaLabel?: string;
96
- congratsProps?: {
93
+ congrats?: {
97
94
  'aria-label'?: string;
98
95
  'data-name'?: string;
99
96
  animationLottie: unknown;
@@ -115,42 +112,30 @@ export type SlidesViewProps = {
115
112
  };
116
113
  };
117
114
 
115
+ // TODO replace this, position no more needed
118
116
  export const initialState: SlidesStack = {
119
117
  '0': {
120
- hidden: false,
121
118
  position: 0,
122
119
  loading: true
123
120
  },
124
121
  '1': {
125
- hidden: false,
126
122
  position: 1,
127
123
  loading: true
128
124
  },
129
125
  '2': {
130
- hidden: false,
131
126
  position: 2,
132
127
  loading: true
133
128
  },
134
129
  '3': {
135
- hidden: false,
136
130
  position: 3,
137
131
  loading: true
138
132
  },
139
133
  '4': {
140
- hidden: false,
141
134
  position: 4,
142
135
  loading: true
143
136
  }
144
137
  };
145
138
 
146
- const getProgressionSlidesRefs = (progression: ProgressionFromAPI): string[] => {
147
- if (progression.state.step.current < 5) {
148
- const slideRef = progression.state.nextContent.ref;
149
- return concat(progression.state.slides, [slideRef]);
150
- }
151
- return slice(0, 5, progression.state.slides);
152
- };
153
-
154
139
  const buildStackSlides = (state: StoreState, dispatch: Dispatch): SlidesStack => {
155
140
  const currentSlideRef = state.ui.currentSlideRef;
156
141
  const progression = state.data.progression;
@@ -160,26 +145,30 @@ const buildStackSlides = (state: StoreState, dispatch: Dispatch): SlidesStack =>
160
145
 
161
146
  // @ts-expect-error typescript does not support capped versions of lodash functions
162
147
  const stack = reduce.convert({cap: false})(
163
- (acc: SlidesStack, uiSlide: ReviewSlide, index: string): SlidesStack => {
164
- const slideRef = slideRefs[toInteger(index)];
165
- if (!slideRef) return set(index, uiSlide, acc);
148
+ (acc: SlidesStack, uiSlide: ReviewSlide, _index: string): SlidesStack => {
149
+ const index = toInteger(_index);
150
+
151
+ const positions = state.ui.positions;
152
+ const position = positions[index];
153
+
154
+ const slideRef = slideRefs[index];
155
+ if (!slideRef) return set(index, {...uiSlide, position}, acc);
166
156
  const slideFromAPI = get(slideRef, state.data.slides);
167
- if (!slideFromAPI) return set(index, uiSlide, acc);
157
+ if (!slideFromAPI) return set(index, {...uiSlide, position}, acc);
168
158
 
169
159
  const answers = getOr([], ['ui', 'answers', slideRef], state);
170
160
  const {questionText, answerUI} = mapApiSlideToUi(dispatch)(slideFromAPI, answers);
171
- const parentContentTitle = getOr('', 'parentContentTitle.title', slideFromAPI);
172
- const parentContentType = getOr('', 'parentContentTitle.type', slideFromAPI);
161
+ const {title: parentContentTitle, type: parentContentType} = slideFromAPI.parentContentTitle;
173
162
 
174
163
  const isCurrentSlideRef = currentSlideRef === slideRef;
175
- const animateCorrectionPopin =
176
- isCurrentSlideRef && get(['ui', 'slide', slideRef, 'animateCorrectionPopin'], state);
177
- const showCorrectionPopin =
178
- isCurrentSlideRef && get(['ui', 'slide', slideRef, 'showCorrectionPopin'], state);
179
- const animationType = get(['ui', 'slide', slideRef, 'animationType'], state);
164
+ const slideUI = get(['ui', 'slide', slideRef], state);
165
+ const animateCorrectionPopin = isCurrentSlideRef && slideUI.animateCorrectionPopin;
166
+ const showCorrectionPopin = isCurrentSlideRef && slideUI.showCorrectionPopin;
167
+ const animationType = slideUI.animationType;
180
168
 
181
169
  const updatedUiSlide = {
182
170
  ...uiSlide,
171
+ position,
183
172
  showCorrectionPopin,
184
173
  animateCorrectionPopin,
185
174
  loading: false,
@@ -336,6 +325,6 @@ export const mapStateToSlidesProps = (
336
325
  correction && getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf),
337
326
  endReview: false
338
327
  },
339
- congratsProps: undefined
328
+ congrats: undefined
340
329
  };
341
330
  };
@@ -1,6 +1,7 @@
1
1
  import test from 'ava';
2
2
  import identity from 'lodash/fp/identity';
3
3
  import omit from 'lodash/fp/omit';
4
+ import pick from 'lodash/fp/pick';
4
5
  import set from 'lodash/fp/set';
5
6
  import {
6
7
  postProgressionResponse as createdProgression,
@@ -34,6 +35,7 @@ test('should create initial props when fetched slide is not still received', t =
34
35
  currentSlideRef: '',
35
36
  navigation: ['loader', 'slides'],
36
37
  answers: {},
38
+ positions: [0, 1, 2, 3, 4],
37
39
  slide: {
38
40
  sli_N1XACJobn: {
39
41
  validateButton: false,
@@ -45,7 +47,7 @@ test('should create initial props when fetched slide is not still received', t =
45
47
  };
46
48
 
47
49
  const props = mapStateToSlidesProps(state, identity, identity);
48
- t.is(props.congratsProps, undefined);
50
+ t.is(props.congrats, undefined);
49
51
  t.deepEqual(omit(['onQuitClick'], props.header), {
50
52
  'aria-label': 'aria-header-wrapper',
51
53
  closeButtonAriaLabel: 'aria-close-button',
@@ -84,27 +86,22 @@ test('should create initial props when fetched slide is not still received', t =
84
86
  endReview: false,
85
87
  slides: {
86
88
  '0': {
87
- hidden: false,
88
89
  position: 0,
89
90
  loading: true
90
91
  },
91
92
  '1': {
92
- hidden: false,
93
93
  position: 1,
94
94
  loading: true
95
95
  },
96
96
  '2': {
97
- hidden: false,
98
97
  position: 2,
99
98
  loading: true
100
99
  },
101
100
  '3': {
102
- hidden: false,
103
101
  position: 3,
104
102
  loading: true
105
103
  },
106
104
  '4': {
107
- hidden: false,
108
105
  position: 4,
109
106
  loading: true
110
107
  }
@@ -129,6 +126,7 @@ test('should create props when first slide is on the state', t => {
129
126
  currentSlideRef: 'sli_VJYjJnJhg',
130
127
  navigation: ['loader', 'slides'],
131
128
  answers: {},
129
+ positions: [0, 1, 2, 3, 4],
132
130
  slide: {
133
131
  sli_VJYjJnJhg: {
134
132
  validateButton: false,
@@ -140,7 +138,7 @@ test('should create props when first slide is on the state', t => {
140
138
  };
141
139
 
142
140
  const props = mapStateToSlidesProps(state, identity, identity);
143
- t.is(props.congratsProps, undefined);
141
+ t.is(props.congrats, undefined);
144
142
  t.deepEqual(omit(['onQuitClick'], props.header), {
145
143
  'aria-label': 'aria-header-wrapper',
146
144
  closeButtonAriaLabel: 'aria-close-button',
@@ -182,7 +180,6 @@ test('should create props when first slide is on the state', t => {
182
180
  animationType: undefined,
183
181
  animateCorrectionPopin: false,
184
182
  showCorrectionPopin: false,
185
- hidden: false,
186
183
  position: 0,
187
184
  loading: false,
188
185
  parentContentTitle: 'From "Developing the review app" course',
@@ -200,22 +197,18 @@ test('should create props when first slide is on the state', t => {
200
197
  });
201
198
  t.deepEqual(omit(['0'], props.stack.slides), {
202
199
  '1': {
203
- hidden: false,
204
200
  position: 1,
205
201
  loading: true
206
202
  },
207
203
  '2': {
208
- hidden: false,
209
204
  position: 2,
210
205
  loading: true
211
206
  },
212
207
  '3': {
213
- hidden: false,
214
208
  position: 3,
215
209
  loading: true
216
210
  },
217
211
  '4': {
218
- hidden: false,
219
212
  position: 4,
220
213
  loading: true
221
214
  }
@@ -239,6 +232,7 @@ test('should create props when slide is on the state and user has selected answe
239
232
  currentSlideRef: 'sli_VJYjJnJhg',
240
233
  navigation: ['loader', 'slides'],
241
234
  answers: {sli_VJYjJnJhg: ['My value']},
235
+ positions: [0, 1, 2, 3, 4],
242
236
  slide: {
243
237
  sli_VJYjJnJhg: {
244
238
  validateButton: true,
@@ -250,7 +244,7 @@ test('should create props when slide is on the state and user has selected answe
250
244
  };
251
245
 
252
246
  const props = mapStateToSlidesProps(state, identity, identity);
253
- t.is(props.congratsProps, undefined);
247
+ t.is(props.congrats, undefined);
254
248
  t.deepEqual(omit(['onQuitClick'], props.header), {
255
249
  'aria-label': 'aria-header-wrapper',
256
250
  closeButtonAriaLabel: 'aria-close-button',
@@ -292,7 +286,6 @@ test('should create props when slide is on the state and user has selected answe
292
286
  animationType: undefined,
293
287
  animateCorrectionPopin: false,
294
288
  showCorrectionPopin: false,
295
- hidden: false,
296
289
  position: 0,
297
290
  loading: false,
298
291
  parentContentTitle: 'From "Developing the review app" course',
@@ -310,22 +303,18 @@ test('should create props when slide is on the state and user has selected answe
310
303
  });
311
304
  t.deepEqual(omit(['0'], props.stack.slides), {
312
305
  '1': {
313
- hidden: false,
314
306
  position: 1,
315
307
  loading: true
316
308
  },
317
309
  '2': {
318
- hidden: false,
319
310
  position: 2,
320
311
  loading: true
321
312
  },
322
313
  '3': {
323
- hidden: false,
324
314
  position: 3,
325
315
  loading: true
326
316
  },
327
317
  '4': {
328
- hidden: false,
329
318
  position: 4,
330
319
  loading: true
331
320
  }
@@ -350,6 +339,7 @@ test('should verify props when first slide was answered correctly and next slide
350
339
  currentSlideRef: 'sli_VJYjJnJhg',
351
340
  navigation: ['loader', 'slides'],
352
341
  answers: {sli_VJYjJnJhg: ['My value']},
342
+ positions: [0, 1, 2, 3, 4],
353
343
  slide: {
354
344
  sli_VJYjJnJhg: {
355
345
  validateButton: false,
@@ -366,7 +356,7 @@ test('should verify props when first slide was answered correctly and next slide
366
356
  };
367
357
 
368
358
  const props = mapStateToSlidesProps(state, identity, identity);
369
- t.is(props.congratsProps, undefined);
359
+ t.is(props.congrats, undefined);
370
360
  t.deepEqual(omit(['onQuitClick'], props.header), {
371
361
  'aria-label': 'aria-header-wrapper',
372
362
  closeButtonAriaLabel: 'aria-close-button',
@@ -408,7 +398,6 @@ test('should verify props when first slide was answered correctly and next slide
408
398
  animationType: undefined,
409
399
  animateCorrectionPopin: false,
410
400
  showCorrectionPopin: false,
411
- hidden: false,
412
401
  position: 0,
413
402
  loading: false,
414
403
  parentContentTitle: 'From "Developing the review app" course',
@@ -426,22 +415,18 @@ test('should verify props when first slide was answered correctly and next slide
426
415
  t.is(props.stack.validateButton.disabled, true);
427
416
  t.deepEqual(omit(['0'], props.stack.slides), {
428
417
  '1': {
429
- hidden: false,
430
418
  position: 1,
431
419
  loading: true
432
420
  },
433
421
  '2': {
434
- hidden: false,
435
422
  position: 2,
436
423
  loading: true
437
424
  },
438
425
  '3': {
439
- hidden: false,
440
426
  position: 3,
441
427
  loading: true
442
428
  },
443
429
  '4': {
444
- hidden: false,
445
430
  position: 4,
446
431
  loading: true
447
432
  }
@@ -470,6 +455,7 @@ test('should verify props when first slide was answered with error and next slid
470
455
  currentSlideRef: 'sli_VJYjJnJhg',
471
456
  navigation: ['loader', 'slides'],
472
457
  answers: {sli_VJYjJnJhg: ['My value']},
458
+ positions: [0, 1, 2, 3, 4],
473
459
  slide: {
474
460
  sli_VJYjJnJhg: {
475
461
  validateButton: false,
@@ -486,7 +472,7 @@ test('should verify props when first slide was answered with error and next slid
486
472
  };
487
473
 
488
474
  const props = mapStateToSlidesProps(state, identity, identity);
489
- t.is(props.congratsProps, undefined);
475
+ t.is(props.congrats, undefined);
490
476
  t.deepEqual(omit(['onQuitClick'], props.header), {
491
477
  'aria-label': 'aria-header-wrapper',
492
478
  closeButtonAriaLabel: 'aria-close-button',
@@ -542,6 +528,7 @@ test('should verify props when first slide was answered, next slide is fetched &
542
528
  currentSlideRef: 'sli_VJYjJnJhg',
543
529
  navigation: ['loader', 'slides'],
544
530
  answers: {sli_VJYjJnJhg: ['My value']},
531
+ positions: [0, 1, 2, 3, 4],
545
532
  slide: {
546
533
  sli_VJYjJnJhg: {
547
534
  validateButton: false,
@@ -558,7 +545,7 @@ test('should verify props when first slide was answered, next slide is fetched &
558
545
  };
559
546
 
560
547
  const props = mapStateToSlidesProps(state, identity, identity);
561
- t.is(props.congratsProps, undefined);
548
+ t.is(props.congrats, undefined);
562
549
  t.deepEqual(omit(['onQuitClick'], props.header), {
563
550
  'aria-label': 'aria-header-wrapper',
564
551
  closeButtonAriaLabel: 'aria-close-button',
@@ -611,7 +598,6 @@ test('should verify props when first slide was answered, next slide is fetched &
611
598
  animationType: undefined,
612
599
  animateCorrectionPopin: true,
613
600
  showCorrectionPopin: true,
614
- hidden: false,
615
601
  position: 0,
616
602
  loading: false,
617
603
  parentContentTitle: 'From "Developing the review app" course',
@@ -630,7 +616,6 @@ test('should verify props when first slide was answered, next slide is fetched &
630
616
  animationType: undefined,
631
617
  animateCorrectionPopin: false,
632
618
  showCorrectionPopin: false,
633
- hidden: false,
634
619
  position: 1,
635
620
  loading: false,
636
621
  parentContentTitle: 'From "Developing the review app" course',
@@ -639,17 +624,14 @@ test('should verify props when first slide was answered, next slide is fetched &
639
624
  t.is(props.stack.validateButton.disabled, true);
640
625
  t.deepEqual(omit(['0', '1'], props.stack.slides), {
641
626
  '2': {
642
- hidden: false,
643
627
  position: 2,
644
628
  loading: true
645
629
  },
646
630
  '3': {
647
- hidden: false,
648
631
  position: 3,
649
632
  loading: true
650
633
  },
651
634
  '4': {
652
- hidden: false,
653
635
  position: 4,
654
636
  loading: true
655
637
  }
@@ -676,6 +658,7 @@ test('should verify props when first slide was answered incorrectly, next slide
676
658
  currentSlideRef: 'sli_VJYjJnJhg',
677
659
  navigation: ['loader', 'slides'],
678
660
  answers: {sli_VJYjJnJhg: ['My value']},
661
+ positions: [0, 1, 2, 3, 4],
679
662
  slide: {
680
663
  sli_VJYjJnJhg: {
681
664
  validateButton: false,
@@ -692,7 +675,7 @@ test('should verify props when first slide was answered incorrectly, next slide
692
675
  };
693
676
 
694
677
  const props = mapStateToSlidesProps(state, identity, identity);
695
- t.is(props.congratsProps, undefined);
678
+ t.is(props.congrats, undefined);
696
679
  t.deepEqual(omit(['onQuitClick'], props.header), {
697
680
  'aria-label': 'aria-header-wrapper',
698
681
  closeButtonAriaLabel: 'aria-close-button',
@@ -748,7 +731,6 @@ test('should verify props when first slide was answered incorrectly, next slide
748
731
  animationType: undefined,
749
732
  animateCorrectionPopin: true,
750
733
  showCorrectionPopin: true,
751
- hidden: false,
752
734
  position: 0,
753
735
  loading: false,
754
736
  parentContentTitle: 'From "Developing the review app" course',
@@ -767,7 +749,6 @@ test('should verify props when first slide was answered incorrectly, next slide
767
749
  animationType: undefined,
768
750
  animateCorrectionPopin: false,
769
751
  showCorrectionPopin: false,
770
- hidden: false,
771
752
  position: 1,
772
753
  loading: false,
773
754
  parentContentTitle: 'From "Developing the review app" course',
@@ -776,17 +757,14 @@ test('should verify props when first slide was answered incorrectly, next slide
776
757
  t.is(props.stack.validateButton.disabled, true);
777
758
  t.deepEqual(omit(['0', '1'], props.stack.slides), {
778
759
  '2': {
779
- hidden: false,
780
760
  position: 2,
781
761
  loading: true
782
762
  },
783
763
  '3': {
784
- hidden: false,
785
764
  position: 3,
786
765
  loading: true
787
766
  },
788
767
  '4': {
789
- hidden: false,
790
768
  position: 4,
791
769
  loading: true
792
770
  }
@@ -816,6 +794,7 @@ test('should verify props when currentSlideRef has changed to nextContent of pro
816
794
  sli_VJYjJnJhg: ['Benchmark'],
817
795
  sli_VkSQroQnx: []
818
796
  },
797
+ positions: [-1, 0, 1, 2, 3],
819
798
  slide: {
820
799
  sli_VJYjJnJhg: {
821
800
  validateButton: false,
@@ -833,7 +812,7 @@ test('should verify props when currentSlideRef has changed to nextContent of pro
833
812
  };
834
813
 
835
814
  const props = mapStateToSlidesProps(state, identity, identity);
836
- t.is(props.congratsProps, undefined);
815
+ t.is(props.congrats, undefined);
837
816
  t.deepEqual(omit(['onQuitClick'], props.header), {
838
817
  'aria-label': 'aria-header-wrapper',
839
818
  closeButtonAriaLabel: 'aria-close-button',
@@ -868,7 +847,31 @@ test('should verify props when currentSlideRef has changed to nextContent of pro
868
847
  ]
869
848
  });
870
849
 
871
- // TODO update test with props.stack validations when NEXT_SLIDE implemented
850
+ const propsToCheck = ['loading', 'animateCorrectionPopin', 'animationType', 'position'];
851
+ t.deepEqual(pick(propsToCheck, props.stack.slides[0]), {
852
+ loading: false,
853
+ animateCorrectionPopin: false,
854
+ animationType: 'unstack',
855
+ position: -1
856
+ });
857
+ t.deepEqual(pick(propsToCheck, props.stack.slides[1]), {
858
+ loading: false,
859
+ animateCorrectionPopin: false,
860
+ animationType: undefined,
861
+ position: 0
862
+ });
863
+ t.deepEqual(pick(propsToCheck, props.stack.slides[2]), {
864
+ loading: true,
865
+ position: 1
866
+ });
867
+ t.deepEqual(pick(propsToCheck, props.stack.slides[3]), {
868
+ loading: true,
869
+ position: 2
870
+ });
871
+ t.deepEqual(pick(propsToCheck, props.stack.slides[4]), {
872
+ loading: true,
873
+ position: 3
874
+ });
872
875
  });
873
876
 
874
877
  test('should verify props when progression is in success', t => {
@@ -904,6 +907,7 @@ test('should verify props when progression is in success', t => {
904
907
  sli_VkAzsCLKb: ['7'],
905
908
  'sli_N13-hG3kX': ['Leaderboard', 'utilisateurs', 'étoiles']
906
909
  },
910
+ positions: [-1, -1, -1, -1, 0],
907
911
  slide: {
908
912
  sli_VJYjJnJhg: {
909
913
  validateButton: false,
@@ -939,7 +943,7 @@ test('should verify props when progression is in success', t => {
939
943
  };
940
944
 
941
945
  const props = mapStateToSlidesProps(state, identity, identity);
942
- t.is(props.congratsProps, undefined);
946
+ t.is(props.congrats, undefined);
943
947
  t.deepEqual(omit(['onQuitClick'], props.header), {
944
948
  'aria-label': 'aria-header-wrapper',
945
949
  closeButtonAriaLabel: 'aria-close-button',
@@ -1010,6 +1014,7 @@ test('should verify props when progression has answered a current pendingSlide',
1010
1014
  sli_VkAzsCLKb: ['7'],
1011
1015
  'sli_N13-hG3kX': ['Leaderboard', 'utilisateurs', 'étoiles']
1012
1016
  },
1017
+ positions: [0, -1, 1, -1, -1],
1013
1018
  slide: {
1014
1019
  sli_VJYjJnJhg: {
1015
1020
  validateButton: false,
@@ -1113,6 +1118,7 @@ test('should verify props when progression still has a pendingSlide', t => {
1113
1118
  sli_VkAzsCLKb: ['7'],
1114
1119
  'sli_N13-hG3kX': ['Leaderboard', 'utilisateurs', 'étoiles']
1115
1120
  },
1121
+ positions: [-1, -1, 0, -1, -1],
1116
1122
  slide: {
1117
1123
  sli_VJYjJnJhg: {
1118
1124
  validateButton: false,
@@ -59,6 +59,7 @@ const initialState: StoreState = {
59
59
  currentSlideRef: freeTextSlide._id,
60
60
  navigation: ['skills', 'slides'],
61
61
  answers: {},
62
+ positions: [0, 1, 2, 3, 4],
62
63
  slide: {
63
64
  [freeTextSlide._id]: {
64
65
  validateButton: false,
@@ -101,7 +102,6 @@ test('should dispatch EDIT_BASIC action via the property onChange of a Free Text
101
102
  animationType: undefined,
102
103
  animateCorrectionPopin: false,
103
104
  showCorrectionPopin: false,
104
- hidden: false,
105
105
  position: 0,
106
106
  loading: false,
107
107
  parentContentTitle: 'From "Developing the review app" course',
@@ -31,6 +31,7 @@ test('correction popin actions after click', async t => {
31
31
  currentSlideRef: 'sli_VJYjJnJhg',
32
32
  navigation: ['loader', 'slides'],
33
33
  answers: {sli_VJYjJnJhg: ['My value']},
34
+ positions: [0, 1, 2, 3, 4],
34
35
  slide: {
35
36
  sli_VJYjJnJhg: {
36
37
  validateButton: false,
@@ -52,7 +53,9 @@ test('correction popin actions after click', async t => {
52
53
  payload: {
53
54
  animationType: 'restack',
54
55
  currentSlideRef: freeTextSlide._id,
55
- nextSlideRef: qcmGraphicSlide._id
56
+ nextSlideRef: qcmGraphicSlide._id,
57
+ totalCorrectAnswers: 0,
58
+ answeredSlides: ['sli_VJYjJnJhg']
56
59
  }
57
60
  }
58
61
  ];
@@ -60,5 +63,9 @@ test('correction popin actions after click', async t => {
60
63
  const props = mapStateToSlidesProps(getState(), dispatch, identity);
61
64
  const correctionPopin = props.stack.correctionPopinProps as CorrectionPopinProps;
62
65
  await correctionPopin.next.onClick();
66
+
67
+ const updatedState = getState();
68
+ t.deepEqual(updatedState.ui.positions, [4, 0, 1, 2, 3]);
69
+ t.deepEqual(updatedState.ui.currentSlideRef, qcmGraphicSlide._id);
63
70
  t.pass();
64
71
  });
@@ -47,6 +47,7 @@ const initialState: StoreState = {
47
47
  ui: {
48
48
  currentSlideRef: qcmDragSlide._id,
49
49
  navigation: ['skills', 'slides'],
50
+ positions: [0, 1, 2, 3, 4],
50
51
  answers: {},
51
52
  slide: {
52
53
  [qcmDragSlide._id]: {
@@ -75,7 +76,6 @@ test('should dispatch EDIT_QCM_DRAG action via the property onClick of a QCM Dra
75
76
  animationType: undefined,
76
77
  animateCorrectionPopin: false,
77
78
  showCorrectionPopin: false,
78
- hidden: false,
79
79
  position: 0,
80
80
  loading: false,
81
81
  parentContentTitle: 'From "Using redux" chapter',
@@ -47,6 +47,7 @@ const initialState: StoreState = {
47
47
  ui: {
48
48
  currentSlideRef: qcmGraphicSlide._id,
49
49
  navigation: ['skills', 'slides'],
50
+ positions: [0, 1, 2, 3, 4],
50
51
  answers: {},
51
52
  slide: {
52
53
  [qcmGraphicSlide._id]: {
@@ -75,7 +76,6 @@ test('should dispatch EDIT_QCM_GRAPHIC action via the property onClick of a QCM
75
76
  animationType: undefined,
76
77
  animateCorrectionPopin: false,
77
78
  showCorrectionPopin: false,
78
- hidden: false,
79
79
  position: 0,
80
80
  loading: false,
81
81
  parentContentTitle: 'From "Developing the review app" course',
@@ -47,6 +47,7 @@ const initialState: StoreState = {
47
47
  ui: {
48
48
  currentSlideRef: qcmSlide._id,
49
49
  navigation: ['skills', 'slides'],
50
+ positions: [0, 1, 2, 3, 4],
50
51
  answers: {},
51
52
  slide: {
52
53
  [qcmSlide._id]: {
@@ -77,7 +78,6 @@ test('should dispatch EDIT_QCM action via the property onClick of a QCM slide',
77
78
  animationType: undefined,
78
79
  animateCorrectionPopin: false,
79
80
  showCorrectionPopin: false,
80
- hidden: false,
81
81
  position: 0,
82
82
  loading: false,
83
83
  parentContentTitle: 'From "Developing the review app" course',
@@ -47,6 +47,7 @@ const initialState: StoreState = {
47
47
  ui: {
48
48
  currentSlideRef: sliderSlide._id,
49
49
  navigation: ['skills', 'slides'],
50
+ positions: [0, 1, 2, 3, 4],
50
51
  answers: {},
51
52
  slide: {
52
53
  [sliderSlide._id]: {
@@ -75,7 +76,6 @@ test('should dispatch EDIT_SLIDER action via the property onChange of a Slider s
75
76
  animationType: undefined,
76
77
  animateCorrectionPopin: false,
77
78
  showCorrectionPopin: false,
78
- hidden: false,
79
79
  position: 0,
80
80
  loading: false,
81
81
  parentContentTitle: 'From "Developing the review app" course',
@@ -1,5 +1,6 @@
1
1
  import test from 'ava';
2
2
  import get from 'lodash/fp/get';
3
+ import omit from 'lodash/fp/omit';
3
4
  import identity from 'lodash/fp/identity';
4
5
  import {ProgressionFromAPI} from '../../../types/common';
5
6
  import {StoreState} from '../../../reducers';
@@ -47,6 +48,7 @@ const initialState: StoreState = {
47
48
  currentSlideRef: sliderSlide._id,
48
49
  navigation: ['skills', 'slides'],
49
50
  answers: {},
51
+ positions: [0, 1, 2, 3, 4],
50
52
  slide: {
51
53
  [sliderSlide._id]: {
52
54
  validateButton: false,
@@ -58,7 +60,7 @@ const initialState: StoreState = {
58
60
  };
59
61
 
60
62
  test('should dispatch EDIT_SLIDER action via the property onSliderChange of a Slider slide', t => {
61
- t.plan(1);
63
+ t.plan(2);
62
64
 
63
65
  const expectedActions = [
64
66
  {
@@ -70,8 +72,18 @@ test('should dispatch EDIT_SLIDER action via the property onSliderChange of a Sl
70
72
  const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
71
73
  const props = mapStateToSlidesProps(getState(), dispatch, identity);
72
74
 
73
- const SlideProps = props.stack.slides['0'].answerUI?.model as QuestionRange;
75
+ const slideProps = props.stack.slides['0'].answerUI?.model as QuestionRange;
76
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
77
+ animationType: undefined,
78
+ animateCorrectionPopin: false,
79
+ showCorrectionPopin: false,
80
+ position: 0,
81
+ loading: false,
82
+ parentContentTitle: 'From "Developing the review app" course',
83
+ questionText:
84
+ 'En combien d’années la communauté de communes du Thouarsais est-elle passée de zéro à un tiers d’énergies renouvelables ?'
85
+ });
74
86
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
75
- const onSliderChange = get('onSliderChange', SlideProps)!;
87
+ const onSliderChange = get('onSliderChange', slideProps)!;
76
88
  onSliderChange(111);
77
89
  });