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