@coorpacademy/app-review 0.1.19 → 0.1.20

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 (34) hide show
  1. package/es/actions/api/post-answer.js +9 -8
  2. package/es/actions/api/test/post-answer.test.js +6 -6
  3. package/es/reducers/data/test/progression.test.js +4 -3
  4. package/es/services/post-answer.d.ts +1 -1
  5. package/es/services/post-answer.js +3 -1
  6. package/es/services/test/post-answer.test.js +27 -4
  7. package/es/test/util/services.mock.d.ts +2 -1
  8. package/es/test/util/services.mock.js +264 -23
  9. package/es/types/common.d.ts +11 -9
  10. package/es/views/slides/index.d.ts +1 -0
  11. package/es/views/slides/index.js +24 -8
  12. package/es/views/slides/test/index.test.js +518 -203
  13. package/lib/actions/api/post-answer.js +10 -9
  14. package/lib/actions/api/test/post-answer.test.js +6 -6
  15. package/lib/reducers/data/test/progression.test.js +4 -3
  16. package/lib/services/post-answer.d.ts +1 -1
  17. package/lib/services/post-answer.js +4 -2
  18. package/lib/services/test/post-answer.test.js +27 -4
  19. package/lib/test/util/services.mock.d.ts +2 -1
  20. package/lib/test/util/services.mock.js +265 -23
  21. package/lib/types/common.d.ts +11 -9
  22. package/lib/views/slides/index.d.ts +1 -0
  23. package/lib/views/slides/index.js +23 -7
  24. package/lib/views/slides/test/index.test.js +521 -203
  25. package/package.json +3 -4
  26. package/src/actions/api/post-answer.ts +9 -9
  27. package/src/actions/api/test/post-answer.test.ts +6 -6
  28. package/src/reducers/data/test/progression.test.ts +4 -3
  29. package/src/services/post-answer.ts +3 -2
  30. package/src/services/test/post-answer.test.ts +28 -4
  31. package/src/test/util/services.mock.ts +274 -24
  32. package/src/types/common.ts +13 -10
  33. package/src/views/slides/index.ts +35 -10
  34. package/src/views/slides/test/index.test.ts +559 -228
@@ -1,37 +1,25 @@
1
1
  import test from 'ava';
2
2
  import identity from 'lodash/fp/identity';
3
3
  import omit from 'lodash/fp/omit';
4
+ import set from 'lodash/fp/set';
5
+ import {
6
+ postProgressionResponse as createdProgression,
7
+ postAnswerResponses,
8
+ progressionSlideWithPendingSlide
9
+ } from '../../../test/util/services.mock';
4
10
  import {mapStateToSlidesProps} from '..';
5
11
  import {StoreState} from '../../../reducers';
6
12
  import {freeTextSlide} from './fixtures/free-text';
13
+ import {qcmGraphicSlide} from './fixtures/qcm-graphic';
14
+ import {templateSlide} from './fixtures/template';
15
+ import {qcmSlide} from './fixtures/qcm';
16
+ import {sliderSlide} from './fixtures/slider';
7
17
 
8
- test('should create initial props when fetched slide is still not received', t => {
18
+ test('should create initial props when fetched slide is not still received', t => {
19
+ // SCENARIO : @@progression/POST_SUCCESS ok and @@slides/FETCH_REQUEST, (the slide is being fetched)
9
20
  const state: StoreState = {
10
21
  data: {
11
- progression: {
12
- _id: '62b1d1087aa12f00253f40ee',
13
- content: {
14
- ref: '_skillref',
15
- type: 'skill'
16
- },
17
- engine: {
18
- ref: 'review'
19
- },
20
- state: {
21
- allAnswers: [],
22
- isCorrect: true,
23
- nextContent: {
24
- ref: 'sli_N1XACJobn',
25
- type: 'slide'
26
- },
27
- pendingSlides: [],
28
- slides: [],
29
- step: {
30
- current: 1
31
- },
32
- stars: 0
33
- }
34
- },
22
+ progression: createdProgression,
35
23
  skills: [],
36
24
  slides: {
37
25
  sli_N1XACJobn: null
@@ -116,41 +104,120 @@ test('should create initial props when fetched slide is still not received', t =
116
104
  });
117
105
  });
118
106
 
119
- test('should create initial props when the slide is on the state', t => {
107
+ test('should create props when first slide is on the state', t => {
108
+ // SCENARIO : after @@slides/FETCH_SUCCESS
120
109
  const state: StoreState = {
121
110
  data: {
122
- progression: {
123
- _id: '62b1d1087aa12f00253f40ee',
124
- content: {
125
- ref: '_skillref',
126
- type: 'skill'
127
- },
128
- engine: {
129
- ref: 'review'
130
- },
131
- state: {
132
- allAnswers: [],
133
- isCorrect: true,
134
- nextContent: {
135
- ref: 'sli_N1XACJobn',
136
- type: 'slide'
137
- },
138
- pendingSlides: [],
139
- slides: [],
140
- step: {
141
- current: 1
142
- },
143
- stars: 0
144
- }
111
+ progression: createdProgression,
112
+ skills: [],
113
+ slides: {
114
+ sli_VJYjJnJhg: freeTextSlide
115
+ },
116
+ token: '1234'
117
+ },
118
+ ui: {
119
+ currentSlideRef: 'sli_VJYjJnJhg',
120
+ navigation: ['loader', 'slides'],
121
+ answers: [],
122
+ slide: {
123
+ validateButton: false
124
+ }
125
+ }
126
+ };
127
+
128
+ const props = mapStateToSlidesProps(state, identity);
129
+ t.is(props.congratsProps, undefined);
130
+ t.deepEqual(omit(['onQuitClick'], props.header), {
131
+ 'aria-label': 'aria-header-wrapper',
132
+ closeButtonAriaLabel: 'aria-close-button',
133
+ mode: '__revision_mode',
134
+ skillName: '__agility',
135
+ steps: [
136
+ {
137
+ current: true,
138
+ icon: 'no-answer',
139
+ value: '1'
140
+ },
141
+ {
142
+ current: false,
143
+ icon: 'no-answer',
144
+ value: '2'
145
+ },
146
+ {
147
+ current: false,
148
+ icon: 'no-answer',
149
+ value: '3'
150
+ },
151
+ {
152
+ current: false,
153
+ icon: 'no-answer',
154
+ value: '4'
145
155
  },
156
+ {
157
+ current: false,
158
+ icon: 'no-answer',
159
+ value: '5'
160
+ }
161
+ ]
162
+ });
163
+ t.deepEqual(omit(['validateButton', 'slides'], props.stack), {
164
+ correctionPopinProps: undefined,
165
+ endReview: false
166
+ });
167
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
168
+ hidden: false,
169
+ position: 0,
170
+ loading: false,
171
+ parentContentTitle: 'From "Developing the review app" course',
172
+ questionText:
173
+ 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
174
+ });
175
+ t.is(props.stack.validateButton.disabled, true);
176
+ t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
177
+ help: 'Type your answer.',
178
+ model: {
179
+ placeholder: 'Type here',
180
+ type: 'freeText',
181
+ value: ''
182
+ }
183
+ });
184
+ t.deepEqual(omit(['0'], props.stack.slides), {
185
+ '1': {
186
+ hidden: false,
187
+ position: 1,
188
+ loading: true
189
+ },
190
+ '2': {
191
+ hidden: false,
192
+ position: 2,
193
+ loading: true
194
+ },
195
+ '3': {
196
+ hidden: false,
197
+ position: 3,
198
+ loading: true
199
+ },
200
+ '4': {
201
+ hidden: false,
202
+ position: 4,
203
+ loading: true
204
+ }
205
+ });
206
+ });
207
+
208
+ test('should create props when slide is on the state and user has selected answers', t => {
209
+ // This is the case after EDIT_ANSWER and before POST_ANSWER_REQUEST
210
+ const state: StoreState = {
211
+ data: {
212
+ progression: createdProgression,
146
213
  skills: [],
147
214
  slides: {
148
- sli_N1XACJobn: freeTextSlide
215
+ sli_VJYjJnJhg: freeTextSlide
149
216
  },
150
217
  token: '1234'
151
218
  },
152
219
  ui: {
153
- currentSlideRef: 'sli_N1XACJobn',
220
+ currentSlideRef: 'sli_VJYjJnJhg',
154
221
  navigation: ['loader', 'slides'],
155
222
  answers: ['My value'],
156
223
  slide: {
@@ -198,7 +265,6 @@ test('should create initial props when the slide is on the state', t => {
198
265
  correctionPopinProps: undefined,
199
266
  endReview: false
200
267
  });
201
- t.false(props.stack.validateButton.disabled);
202
268
  t.deepEqual(omit('answerUI', props.stack.slides['0']), {
203
269
  hidden: false,
204
270
  position: 0,
@@ -207,6 +273,7 @@ test('should create initial props when the slide is on the state', t => {
207
273
  questionText:
208
274
  'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
209
275
  });
276
+ t.is(props.stack.validateButton.disabled, false);
210
277
  t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
211
278
  help: 'Type your answer.',
212
279
  model: {
@@ -239,138 +306,17 @@ test('should create initial props when the slide is on the state', t => {
239
306
  });
240
307
  });
241
308
 
242
- test('should create props when the next slide is on the state', t => {
309
+ test('should verify props when first slide was answered correctly and next slide is not fetched yet', t => {
310
+ // Scenario: after POST_ANSWER_SUCCESS and during SLIDE_FETCH_REQUEST for the nextContent.ref slide
243
311
  const state: StoreState = {
244
312
  data: {
245
- progression: {
246
- _id: '62b1d1087aa12f00253f40ee',
247
- content: {
248
- ref: '_skill-ref',
249
- type: 'skill'
250
- },
251
- engine: {
252
- ref: 'review'
253
- },
254
- state: {
255
- allAnswers: [
256
- {
257
- slideRef: 'sli_VJYjJnJhg',
258
- isCorrect: true,
259
- answer: ['Benchmark']
260
- }
261
- ],
262
- isCorrect: true,
263
- nextContent: {
264
- ref: 'sli_VkSQroQnx',
265
- type: 'slide'
266
- },
267
- content: {
268
- ref: 'sli_VJYjJnJhg',
269
- type: 'slide'
270
- },
271
- pendingSlides: [],
272
- slides: ['sli_VJYjJnJhg'],
273
- step: {
274
- current: 2
275
- },
276
- stars: 4
277
- }
278
- },
313
+ progression: postAnswerResponses.sli_VJYjJnJhg,
279
314
  skills: [],
280
315
  slides: {
281
- sli_VJYjJnJhg: {
282
- question: {
283
- content: {
284
- media: {
285
- src: [],
286
- posters: [],
287
- subtitles: []
288
- },
289
- label: '',
290
- placeholder: 'Type here',
291
- id: 'sli_VJYjJnJhg.choice_1'
292
- },
293
- type: 'basic',
294
- header:
295
- 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?',
296
- explanation: 'Type your answer.'
297
- },
298
- klf: 'To negotiate your salary when being hired, you have to establish a benchmark beforehand. In other words, you should assess the salary to which you aspire by enquiring about the remuneration paid in the same industry, the same region and the same position.',
299
- tips: 'According to Insee, Paris salaries are 20-25% higher compared with those of the provinces in 2015.',
300
- universalRef: 'sli_VJYjJnJhg',
301
- id: 'sli_VJYjJnJhg',
302
- parentContentTitle: {
303
- title: 'Developing the review app',
304
- type: 'course'
305
- }
306
- },
307
- sli_VkSQroQnx: {
308
- question: {
309
- content: {
310
- media: {
311
- src: [],
312
- posters: [],
313
- subtitles: []
314
- },
315
- choices: [
316
- {
317
- media: {
318
- src: [
319
- {
320
- _id: '624efd915948a7013083e986',
321
- mimeType: 'image/jpeg',
322
- url: '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/true-1512554153232.jpg',
323
- id: '624efd915948a7013083e986'
324
- }
325
- ],
326
- posters: [],
327
- subtitles: [],
328
- type: 'img'
329
- },
330
- items: [],
331
- _id: '624efd915948a7013083e985',
332
- label: 'Vrai',
333
- value: 'sli_VkSQroQnx.choice_NJesyUo7nx',
334
- id: '624efd915948a7013083e985'
335
- },
336
- {
337
- media: {
338
- src: [
339
- {
340
- _id: '624efd915948a7013083e988',
341
- mimeType: 'image/jpeg',
342
- url: '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/false-1512554160848.jpg',
343
- id: '624efd915948a7013083e988'
344
- }
345
- ],
346
- posters: [],
347
- subtitles: [],
348
- type: 'img'
349
- },
350
- items: [],
351
- _id: '624efd915948a7013083e987',
352
- label: 'Faux',
353
- value: 'sli_VkSQroQnx.choice_VkgayLjX3e',
354
- id: '624efd915948a7013083e987'
355
- }
356
- ]
357
- },
358
- type: 'qcmGraphic',
359
- header:
360
- 'Pour mener une bonne négociation, il ne faut ressentir aucune émotion. Vrai ou faux ?',
361
- explanation: 'Sélectionnez la bonne réponse.'
362
- },
363
- klf: "Il ne faut pas prendre la négociation comme une affaire personnelle, afin de rester centré sur son sujet. Mais cela ne signifie pas être dépourvu de toute émotion, car celles-ci peuvent être de vrais atouts. À condition de réussir à les exprimer sans accuser l'autre d'en être à l'origine.",
364
- tips: "Pour gérer ses émotions, il faut d'abord les identifier, notamment en analysant ses ressentis physiques et en trouvant l'élément déclencheur.",
365
- universalRef: 'sli_VkSQroQnx',
366
- id: 'sli_VkSQroQnx',
367
- parentContentTitle: {
368
- title: 'Developing the review app',
369
- type: 'course'
370
- }
371
- }
372
- },
373
- token: 'undefined'
316
+ sli_VJYjJnJhg: freeTextSlide,
317
+ sli_VkSQroQnx: null
318
+ },
319
+ token: '1234'
374
320
  },
375
321
  ui: {
376
322
  currentSlideRef: 'sli_VJYjJnJhg',
@@ -396,8 +342,172 @@ test('should create props when the next slide is on the state', t => {
396
342
  value: '1'
397
343
  },
398
344
  {
399
- // FIX ME: update on PR -> https://trello.com/c/qOSDa8Fm/2715-app-review-props-dynamiques-pour-les-step-items-du-header-bas%C3%A9-sur-le-state
345
+ current: false,
346
+ icon: 'no-answer',
347
+ value: '2'
348
+ },
349
+ {
350
+ current: false,
351
+ icon: 'no-answer',
352
+ value: '3'
353
+ },
354
+ {
355
+ current: false,
356
+ icon: 'no-answer',
357
+ value: '4'
358
+ },
359
+ {
360
+ current: false,
361
+ icon: 'no-answer',
362
+ value: '5'
363
+ }
364
+ ]
365
+ });
366
+ t.deepEqual(omit(['validateButton', 'slides'], props.stack), {
367
+ correctionPopinProps: undefined,
368
+ endReview: false
369
+ });
370
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
371
+ hidden: false,
372
+ position: 0,
373
+ loading: false,
374
+ parentContentTitle: 'From "Developing the review app" course',
375
+ questionText:
376
+ 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
377
+ });
378
+ t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
379
+ help: 'Type your answer.',
380
+ model: {
381
+ placeholder: 'Type here',
382
+ type: 'freeText',
383
+ value: 'My value'
384
+ }
385
+ });
386
+ t.is(props.stack.validateButton.disabled, true);
387
+ t.deepEqual(omit(['0'], props.stack.slides), {
388
+ '1': {
389
+ hidden: false,
390
+ position: 1,
391
+ loading: true
392
+ },
393
+ '2': {
394
+ hidden: false,
395
+ position: 2,
396
+ loading: true
397
+ },
398
+ '3': {
399
+ hidden: false,
400
+ position: 3,
401
+ loading: true
402
+ },
403
+ '4': {
404
+ hidden: false,
405
+ position: 4,
406
+ loading: true
407
+ }
408
+ });
409
+ });
410
+
411
+ test('should verify props when first slide was answered with error and next slide is not fetched yet', t => {
412
+ // Scenario: after POST_ANSWER_SUCCESS and during SLIDE_FETCH_REQUEST for the nextContent.ref slide
413
+ const state: StoreState = {
414
+ data: {
415
+ progression: set(
416
+ ['state', 'allAnswers', 0, 'isCorrect'],
417
+ false,
418
+ postAnswerResponses.sli_VJYjJnJhg
419
+ ),
420
+ skills: [],
421
+ slides: {
422
+ sli_VJYjJnJhg: freeTextSlide,
423
+ sli_VkSQroQnx: null
424
+ },
425
+ token: '1234'
426
+ },
427
+ ui: {
428
+ currentSlideRef: 'sli_VJYjJnJhg',
429
+ navigation: ['loader', 'slides'],
430
+ answers: ['My value'],
431
+ slide: {
432
+ validateButton: false
433
+ }
434
+ }
435
+ };
436
+
437
+ const props = mapStateToSlidesProps(state, identity);
438
+ t.is(props.congratsProps, undefined);
439
+ t.deepEqual(omit(['onQuitClick'], props.header), {
440
+ 'aria-label': 'aria-header-wrapper',
441
+ closeButtonAriaLabel: 'aria-close-button',
442
+ mode: '__revision_mode',
443
+ skillName: '__agility',
444
+ steps: [
445
+ {
400
446
  current: true,
447
+ icon: 'wrong',
448
+ value: '1'
449
+ },
450
+ {
451
+ current: false,
452
+ icon: 'no-answer',
453
+ value: '2'
454
+ },
455
+ {
456
+ current: false,
457
+ icon: 'no-answer',
458
+ value: '3'
459
+ },
460
+ {
461
+ current: false,
462
+ icon: 'no-answer',
463
+ value: '4'
464
+ },
465
+ {
466
+ current: false,
467
+ icon: 'no-answer',
468
+ value: '5'
469
+ }
470
+ ]
471
+ });
472
+ });
473
+
474
+ test('should verify props when first slide was answered and next slide is fecthed', t => {
475
+ // Scenario: after POST_ANSWER_SUCCESS and SLIDE_FETCH_SUCCESS for the nextContent.ref slide
476
+ const state: StoreState = {
477
+ data: {
478
+ progression: postAnswerResponses.sli_VJYjJnJhg,
479
+ skills: [],
480
+ slides: {
481
+ sli_VJYjJnJhg: freeTextSlide,
482
+ sli_VkSQroQnx: qcmGraphicSlide
483
+ },
484
+ token: '1234'
485
+ },
486
+ ui: {
487
+ currentSlideRef: 'sli_VJYjJnJhg',
488
+ navigation: ['loader', 'slides'],
489
+ answers: ['My value'],
490
+ slide: {
491
+ validateButton: false
492
+ }
493
+ }
494
+ };
495
+
496
+ const props = mapStateToSlidesProps(state, identity);
497
+ t.is(props.congratsProps, undefined);
498
+ t.deepEqual(omit(['onQuitClick'], props.header), {
499
+ 'aria-label': 'aria-header-wrapper',
500
+ closeButtonAriaLabel: 'aria-close-button',
501
+ mode: '__revision_mode',
502
+ skillName: '__agility',
503
+ steps: [
504
+ {
505
+ current: true,
506
+ icon: 'right',
507
+ value: '1'
508
+ },
509
+ {
510
+ current: false,
401
511
  icon: 'no-answer',
402
512
  value: '2'
403
513
  },
@@ -422,7 +532,6 @@ test('should create props when the next slide is on the state', t => {
422
532
  correctionPopinProps: undefined,
423
533
  endReview: false
424
534
  });
425
- t.true(props.stack.validateButton.disabled);
426
535
  t.deepEqual(omit('answerUI', props.stack.slides['0']), {
427
536
  hidden: false,
428
537
  position: 0,
@@ -439,55 +548,277 @@ test('should create props when the next slide is on the state', t => {
439
548
  value: 'My value'
440
549
  }
441
550
  });
442
- t.deepEqual(
443
- omit(
444
- ['0', '1.answerUI.model.answers.0.onClick', '1.answerUI.model.answers.1.onClick'],
445
- props.stack.slides
446
- ),
447
- {
448
- '1': {
449
- answerUI: {
450
- help: 'Sélectionnez la bonne réponse.',
451
- model: {
452
- answers: [
453
- {
454
- image:
455
- '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/true-1512554153232.jpg',
456
- selected: false,
457
- title: 'Vrai'
458
- },
459
- {
460
- image:
461
- '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/false-1512554160848.jpg',
462
- selected: false,
463
- title: 'Faux'
464
- }
465
- ],
466
- type: 'qcmGraphic'
467
- }
468
- },
469
- hidden: false,
470
- loading: false,
471
- position: 1,
472
- parentContentTitle: 'From "Developing the review app" course',
473
- questionText:
474
- 'Pour mener une bonne négociation, il ne faut ressentir aucune émotion. Vrai ou faux ?'
551
+ t.deepEqual(omit('answerUI', props.stack.slides['1']), {
552
+ hidden: false,
553
+ position: 1,
554
+ loading: false,
555
+ parentContentTitle: 'From "Developing the review app" course',
556
+ questionText:
557
+ 'Pour mener une bonne négociation, il ne faut ressentir aucune émotion. Vrai ou faux ?'
558
+ });
559
+ t.is(props.stack.validateButton.disabled, true);
560
+ t.deepEqual(omit(['0', '1'], props.stack.slides), {
561
+ '2': {
562
+ hidden: false,
563
+ position: 2,
564
+ loading: true
565
+ },
566
+ '3': {
567
+ hidden: false,
568
+ position: 3,
569
+ loading: true
570
+ },
571
+ '4': {
572
+ hidden: false,
573
+ position: 4,
574
+ loading: true
575
+ }
576
+ });
577
+ });
578
+
579
+ test('should verify props when currentSlideRef has changed to nextContent of progression after first asnwered question', t => {
580
+ // state after click on NEXT_SLIDE
581
+ const state: StoreState = {
582
+ data: {
583
+ progression: postAnswerResponses.sli_VJYjJnJhg,
584
+ skills: [],
585
+ slides: {
586
+ sli_VJYjJnJhg: freeTextSlide,
587
+ sli_VkSQroQnx: qcmGraphicSlide
475
588
  },
476
- '2': {
477
- hidden: false,
478
- position: 2,
479
- loading: true
589
+ token: '1234'
590
+ },
591
+ ui: {
592
+ currentSlideRef: 'sli_VkSQroQnx',
593
+ navigation: ['loader', 'slides'],
594
+ answers: [],
595
+ slide: {
596
+ validateButton: false
597
+ }
598
+ }
599
+ };
600
+
601
+ const props = mapStateToSlidesProps(state, identity);
602
+ t.is(props.congratsProps, undefined);
603
+ t.deepEqual(omit(['onQuitClick'], props.header), {
604
+ 'aria-label': 'aria-header-wrapper',
605
+ closeButtonAriaLabel: 'aria-close-button',
606
+ mode: '__revision_mode',
607
+ skillName: '__agility',
608
+ steps: [
609
+ {
610
+ current: false,
611
+ icon: 'right',
612
+ value: '1'
480
613
  },
481
- '3': {
482
- hidden: false,
483
- position: 3,
484
- loading: true
614
+ {
615
+ current: true,
616
+ icon: 'no-answer',
617
+ value: '2'
485
618
  },
486
- '4': {
487
- hidden: false,
488
- position: 4,
489
- loading: true
619
+ {
620
+ current: false,
621
+ icon: 'no-answer',
622
+ value: '3'
623
+ },
624
+ {
625
+ current: false,
626
+ icon: 'no-answer',
627
+ value: '4'
628
+ },
629
+ {
630
+ current: false,
631
+ icon: 'no-answer',
632
+ value: '5'
633
+ }
634
+ ]
635
+ });
636
+
637
+ // TODO update test with props.stack validations when NEXT_SLIDE implemented
638
+ });
639
+
640
+ test('should verify props when progression is in success', t => {
641
+ // state after receive last POST_ANSWER_SUCCESS and before last NEXT_SLIDE
642
+ const state: StoreState = {
643
+ data: {
644
+ progression: postAnswerResponses[templateSlide.universalRef],
645
+ skills: [],
646
+ slides: {
647
+ [freeTextSlide.universalRef]: freeTextSlide,
648
+ [qcmGraphicSlide.universalRef]: qcmGraphicSlide,
649
+ [qcmSlide.universalRef]: qcmSlide,
650
+ [sliderSlide.universalRef]: sliderSlide,
651
+ [templateSlide.universalRef]: templateSlide
652
+ },
653
+ token: '1234'
654
+ },
655
+ ui: {
656
+ currentSlideRef: templateSlide.universalRef,
657
+ navigation: ['loader', 'slides'],
658
+ answers: [],
659
+ slide: {
660
+ validateButton: false
490
661
  }
491
662
  }
492
- );
663
+ };
664
+
665
+ const props = mapStateToSlidesProps(state, identity);
666
+ t.is(props.congratsProps, undefined);
667
+ t.deepEqual(omit(['onQuitClick'], props.header), {
668
+ 'aria-label': 'aria-header-wrapper',
669
+ closeButtonAriaLabel: 'aria-close-button',
670
+ mode: '__revision_mode',
671
+ skillName: '__agility',
672
+ steps: [
673
+ {
674
+ current: false,
675
+ icon: 'right',
676
+ value: '1'
677
+ },
678
+ {
679
+ current: false,
680
+ icon: 'right',
681
+ value: '2'
682
+ },
683
+ {
684
+ current: false,
685
+ icon: 'right',
686
+ value: '3'
687
+ },
688
+ {
689
+ current: false,
690
+ icon: 'right',
691
+ value: '4'
692
+ },
693
+ {
694
+ current: true,
695
+ icon: 'right',
696
+ value: '5'
697
+ }
698
+ ]
699
+ });
700
+
701
+ // TODO update test with props.stack validations when NEXT_SLIDE implemented
702
+ });
703
+
704
+ test('should verify props when progression has answered a current pendingslide', t => {
705
+ // Scenario, freeTextSlide and qcmSlide are pending slides, freeTextSlide was answered correctly, qcmSlide remains but not yet the currentSlideRef
706
+ const state: StoreState = {
707
+ data: {
708
+ progression: progressionSlideWithPendingSlide,
709
+ skills: [],
710
+ slides: {
711
+ [freeTextSlide.universalRef]: freeTextSlide,
712
+ [qcmGraphicSlide.universalRef]: qcmGraphicSlide,
713
+ [qcmSlide.universalRef]: qcmSlide,
714
+ [sliderSlide.universalRef]: sliderSlide,
715
+ [templateSlide.universalRef]: templateSlide
716
+ },
717
+ token: '1234'
718
+ },
719
+ ui: {
720
+ currentSlideRef: freeTextSlide.universalRef,
721
+ navigation: ['loader', 'slides'],
722
+ answers: [],
723
+ slide: {
724
+ validateButton: false
725
+ }
726
+ }
727
+ };
728
+
729
+ const props = mapStateToSlidesProps(state, identity);
730
+ t.deepEqual(omit(['onQuitClick'], props.header), {
731
+ 'aria-label': 'aria-header-wrapper',
732
+ closeButtonAriaLabel: 'aria-close-button',
733
+ mode: '__revision_mode',
734
+ skillName: '__agility',
735
+ steps: [
736
+ {
737
+ current: true,
738
+ icon: 'right',
739
+ value: '1'
740
+ },
741
+ {
742
+ current: false,
743
+ icon: 'right',
744
+ value: '2'
745
+ },
746
+ {
747
+ current: false,
748
+ icon: 'wrong',
749
+ value: '3'
750
+ },
751
+ {
752
+ current: false,
753
+ icon: 'right',
754
+ value: '4'
755
+ },
756
+ {
757
+ current: false,
758
+ icon: 'right',
759
+ value: '5'
760
+ }
761
+ ]
762
+ });
763
+ });
764
+
765
+ test('should verify props when progression has still pendingslide', t => {
766
+ // Scenario, freeTextSlide and qcmSlide are pending slides, freeTextSlide was answered correctly, qcmSlide remains and it is the currentSlideRef
767
+ const state: StoreState = {
768
+ data: {
769
+ progression: progressionSlideWithPendingSlide,
770
+ skills: [],
771
+ slides: {
772
+ [freeTextSlide.universalRef]: freeTextSlide,
773
+ [qcmGraphicSlide.universalRef]: qcmGraphicSlide,
774
+ [qcmSlide.universalRef]: qcmSlide,
775
+ [sliderSlide.universalRef]: sliderSlide,
776
+ [templateSlide.universalRef]: templateSlide
777
+ },
778
+ token: '1234'
779
+ },
780
+ ui: {
781
+ currentSlideRef: qcmSlide.universalRef,
782
+ navigation: ['loader', 'slides'],
783
+ answers: [],
784
+ slide: {
785
+ validateButton: false
786
+ }
787
+ }
788
+ };
789
+
790
+ const props = mapStateToSlidesProps(state, identity);
791
+ t.deepEqual(omit(['onQuitClick'], props.header), {
792
+ 'aria-label': 'aria-header-wrapper',
793
+ closeButtonAriaLabel: 'aria-close-button',
794
+ mode: '__revision_mode',
795
+ skillName: '__agility',
796
+ steps: [
797
+ {
798
+ current: false,
799
+ icon: 'right',
800
+ value: '1'
801
+ },
802
+ {
803
+ current: false,
804
+ icon: 'right',
805
+ value: '2'
806
+ },
807
+ {
808
+ current: true,
809
+ icon: 'no-answer',
810
+ value: '3'
811
+ },
812
+ {
813
+ current: false,
814
+ icon: 'right',
815
+ value: '4'
816
+ },
817
+ {
818
+ current: false,
819
+ icon: 'right',
820
+ value: '5'
821
+ }
822
+ ]
823
+ });
493
824
  });