@coorpacademy/app-review 0.1.16 → 0.1.18

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 (196) hide show
  1. package/es/actions/api/fetch-skills.d.ts +3 -3
  2. package/es/actions/api/fetch-skills.js +7 -2
  3. package/es/actions/api/fetch-slide.d.ts +1 -1
  4. package/es/actions/api/fetch-slide.js +3 -1
  5. package/es/actions/api/post-answer.d.ts +14 -0
  6. package/es/actions/api/post-answer.js +25 -0
  7. package/es/actions/api/post-progression.d.ts +3 -3
  8. package/es/actions/api/post-progression.js +5 -2
  9. package/es/actions/api/test/fetch-skills.test.js +7 -4
  10. package/es/actions/api/test/fetch-slide.test.js +7 -4
  11. package/es/actions/api/test/post-answer.test.d.ts +1 -0
  12. package/es/actions/api/test/post-answer.test.js +82 -0
  13. package/es/actions/api/test/post-progression.test.js +7 -4
  14. package/es/actions/data/test/token.test.d.ts +1 -0
  15. package/es/actions/data/test/token.test.js +25 -0
  16. package/es/actions/index.d.ts +1 -8
  17. package/es/actions/{api/test → test}/create-test-store.d.ts +2 -2
  18. package/es/actions/{api/test → test}/create-test-store.js +1 -1
  19. package/es/actions/ui/answers.d.ts +17 -3
  20. package/es/actions/ui/answers.js +41 -3
  21. package/es/actions/ui/slides.d.ts +0 -5
  22. package/es/actions/ui/slides.js +0 -4
  23. package/es/actions/ui/test/answers.test.d.ts +1 -0
  24. package/es/actions/ui/test/answers.test.js +100 -0
  25. package/es/actions/ui/test/slides.test.d.ts +1 -0
  26. package/es/actions/ui/test/slides.test.js +26 -0
  27. package/es/common/index.d.ts +0 -3
  28. package/es/common/index.js +0 -4
  29. package/es/index.js +1 -3
  30. package/es/reducers/data/index.d.ts +1 -1
  31. package/es/reducers/data/progression.d.ts +3 -3
  32. package/es/reducers/data/progression.js +2 -5
  33. package/es/reducers/data/slides.d.ts +2 -3
  34. package/es/reducers/data/test/progression.test.js +12 -27
  35. package/es/reducers/index.d.ts +2 -1
  36. package/es/reducers/ui/answers.d.ts +2 -2
  37. package/es/reducers/ui/answers.js +4 -8
  38. package/es/reducers/ui/index.d.ts +4 -1
  39. package/es/reducers/ui/index.js +3 -1
  40. package/es/reducers/ui/slide.d.ts +8 -0
  41. package/es/reducers/ui/slide.js +26 -0
  42. package/es/reducers/ui/test/answers.test.js +23 -3
  43. package/es/reducers/ui/test/current-slide-ref.test.js +1 -1
  44. package/es/reducers/ui/test/navigation.test.js +5 -5
  45. package/es/reducers/ui/test/slide.test.d.ts +1 -0
  46. package/es/reducers/ui/test/slide.test.js +12 -0
  47. package/es/test/util/services.mock.d.ts +3 -1
  48. package/es/test/util/services.mock.js +89 -72
  49. package/es/types/common.d.ts +0 -25
  50. package/es/views/skills/index.d.ts +1 -1
  51. package/es/views/skills/index.js +0 -3
  52. package/es/views/skills/test/skills.test.d.ts +1 -0
  53. package/es/views/skills/test/skills.test.js +94 -0
  54. package/es/views/slides/index.d.ts +13 -2
  55. package/es/views/slides/index.js +19 -15
  56. package/es/views/slides/map-api-slide-to-ui.js +65 -68
  57. package/es/views/slides/test/fixtures/free-text.d.ts +2 -1
  58. package/es/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
  59. package/es/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
  60. package/es/views/slides/test/fixtures/qcm.d.ts +2 -1
  61. package/es/views/slides/test/fixtures/slider.d.ts +2 -1
  62. package/es/views/slides/test/fixtures/template.d.ts +4 -0
  63. package/{lib/views/slides/test/fixtures/select-template.js → es/views/slides/test/fixtures/template.js} +82 -4
  64. package/es/views/slides/test/index.test.d.ts +1 -0
  65. package/es/views/slides/test/index.test.js +473 -0
  66. package/es/views/slides/test/map-api-slide-to-ui.test.js +4 -10
  67. package/es/views/slides/test/slide.template.on-change.test.d.ts +1 -0
  68. package/es/views/slides/test/slide.template.on-change.test.js +79 -0
  69. package/lib/actions/api/fetch-skills.d.ts +3 -3
  70. package/lib/actions/api/fetch-skills.js +22 -19
  71. package/lib/actions/api/fetch-slide.d.ts +1 -1
  72. package/lib/actions/api/fetch-slide.js +3 -1
  73. package/lib/actions/api/post-answer.d.ts +14 -0
  74. package/lib/actions/api/post-answer.js +75 -0
  75. package/lib/actions/api/post-progression.d.ts +3 -3
  76. package/lib/actions/api/post-progression.js +6 -3
  77. package/lib/actions/api/test/fetch-skills.test.js +7 -4
  78. package/lib/actions/api/test/fetch-slide.test.js +7 -4
  79. package/lib/actions/api/test/post-answer.test.d.ts +1 -0
  80. package/lib/actions/api/test/post-answer.test.js +145 -0
  81. package/lib/actions/api/test/post-progression.test.js +7 -4
  82. package/lib/actions/data/test/token.test.d.ts +1 -0
  83. package/lib/actions/data/test/token.test.js +70 -0
  84. package/lib/actions/index.d.ts +1 -8
  85. package/lib/actions/{api/test → test}/create-test-store.d.ts +2 -2
  86. package/lib/actions/{api/test → test}/create-test-store.js +1 -1
  87. package/lib/actions/ui/answers.d.ts +17 -3
  88. package/lib/actions/ui/answers.js +50 -3
  89. package/lib/actions/ui/slides.d.ts +0 -5
  90. package/lib/actions/ui/slides.js +0 -4
  91. package/lib/actions/ui/test/answers.test.d.ts +1 -0
  92. package/lib/actions/ui/test/answers.test.js +190 -0
  93. package/lib/actions/ui/test/slides.test.d.ts +1 -0
  94. package/lib/actions/ui/test/slides.test.js +71 -0
  95. package/lib/common/index.d.ts +0 -3
  96. package/lib/common/index.js +0 -4
  97. package/lib/index.js +1 -3
  98. package/lib/reducers/data/index.d.ts +1 -1
  99. package/lib/reducers/data/progression.d.ts +3 -3
  100. package/lib/reducers/data/progression.js +2 -5
  101. package/lib/reducers/data/slides.d.ts +2 -3
  102. package/lib/reducers/data/test/progression.test.js +12 -27
  103. package/lib/reducers/index.d.ts +2 -1
  104. package/lib/reducers/ui/answers.d.ts +2 -2
  105. package/lib/reducers/ui/answers.js +4 -8
  106. package/lib/reducers/ui/index.d.ts +4 -1
  107. package/lib/reducers/ui/index.js +3 -1
  108. package/lib/reducers/ui/slide.d.ts +8 -0
  109. package/lib/reducers/ui/slide.js +27 -0
  110. package/lib/reducers/ui/test/answers.test.js +23 -3
  111. package/lib/reducers/ui/test/current-slide-ref.test.js +1 -1
  112. package/lib/reducers/ui/test/navigation.test.js +5 -5
  113. package/lib/reducers/ui/test/slide.test.d.ts +1 -0
  114. package/lib/reducers/ui/test/slide.test.js +12 -0
  115. package/lib/test/util/services.mock.d.ts +3 -1
  116. package/lib/test/util/services.mock.js +89 -72
  117. package/lib/types/common.d.ts +0 -25
  118. package/lib/views/skills/index.d.ts +1 -1
  119. package/lib/views/skills/index.js +0 -3
  120. package/lib/views/skills/test/skills.test.d.ts +1 -0
  121. package/lib/views/skills/test/skills.test.js +94 -0
  122. package/lib/views/slides/index.d.ts +13 -2
  123. package/lib/views/slides/index.js +19 -15
  124. package/lib/views/slides/map-api-slide-to-ui.js +106 -99
  125. package/lib/views/slides/test/fixtures/free-text.d.ts +2 -1
  126. package/lib/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
  127. package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
  128. package/lib/views/slides/test/fixtures/qcm.d.ts +2 -1
  129. package/lib/views/slides/test/fixtures/slider.d.ts +2 -1
  130. package/lib/views/slides/test/fixtures/template.d.ts +4 -0
  131. package/{es/views/slides/test/fixtures/select-template.js → lib/views/slides/test/fixtures/template.js} +82 -4
  132. package/lib/views/slides/test/index.test.d.ts +1 -0
  133. package/lib/views/slides/test/index.test.js +473 -0
  134. package/lib/views/slides/test/map-api-slide-to-ui.test.js +4 -10
  135. package/lib/views/slides/test/slide.template.on-change.test.d.ts +1 -0
  136. package/lib/views/slides/test/slide.template.on-change.test.js +82 -0
  137. package/package.json +6 -5
  138. package/src/actions/api/fetch-skills.ts +18 -11
  139. package/src/actions/api/fetch-slide.ts +3 -1
  140. package/src/actions/api/post-answer.ts +44 -0
  141. package/src/actions/api/post-progression.ts +7 -4
  142. package/src/actions/api/test/fetch-skills.test.ts +9 -6
  143. package/src/actions/api/test/fetch-slide.test.ts +9 -6
  144. package/src/actions/api/test/post-answer.test.ts +101 -0
  145. package/src/actions/api/test/post-progression.test.ts +9 -6
  146. package/src/actions/data/test/token.test.ts +29 -0
  147. package/src/actions/index.ts +1 -17
  148. package/src/actions/{api/test → test}/create-test-store.ts +2 -2
  149. package/src/actions/ui/answers.ts +55 -6
  150. package/src/actions/ui/slides.ts +1 -8
  151. package/src/actions/ui/test/answers.test.ts +115 -0
  152. package/src/actions/ui/test/slides.test.ts +30 -0
  153. package/src/common/index.ts +0 -7
  154. package/src/index.tsx +1 -3
  155. package/src/reducers/data/progression.ts +4 -7
  156. package/src/reducers/data/slides.ts +2 -3
  157. package/src/reducers/data/test/progression.test.ts +15 -31
  158. package/src/reducers/ui/answers.ts +5 -9
  159. package/src/reducers/ui/index.ts +4 -1
  160. package/src/reducers/ui/slide.ts +43 -0
  161. package/src/reducers/ui/test/answers.test.ts +29 -4
  162. package/src/reducers/ui/test/current-slide-ref.test.ts +1 -1
  163. package/src/reducers/ui/test/navigation.test.ts +5 -5
  164. package/src/reducers/ui/test/slide.test.ts +15 -0
  165. package/src/test/util/services.mock.ts +94 -73
  166. package/src/types/common.ts +0 -30
  167. package/src/views/skills/index.ts +1 -5
  168. package/src/views/skills/test/skills.test.ts +101 -0
  169. package/src/views/slides/index.ts +38 -23
  170. package/src/views/slides/map-api-slide-to-ui.ts +146 -113
  171. package/src/views/slides/test/fixtures/free-text.ts +2 -1
  172. package/src/views/slides/test/fixtures/qcm-drag.ts +2 -1
  173. package/src/views/slides/test/fixtures/qcm-graphic.ts +2 -1
  174. package/src/views/slides/test/fixtures/qcm.ts +2 -1
  175. package/src/views/slides/test/fixtures/slider.ts +2 -1
  176. package/src/views/slides/test/fixtures/{select-template.ts → template.ts} +84 -5
  177. package/src/views/slides/test/index.test.ts +493 -0
  178. package/src/views/slides/test/map-api-slide-to-ui.test.ts +6 -11
  179. package/src/views/slides/test/slide.template.on-change.test.ts +92 -0
  180. package/es/fixtures/qcm-slide.d.ts +0 -2
  181. package/es/fixtures/qcm-slide.js +0 -33
  182. package/es/fixtures/temp-fixture.d.ts +0 -3
  183. package/es/fixtures/temp-fixture.js +0 -84
  184. package/es/views/slides/test/fixtures/select-template.d.ts +0 -3
  185. package/es/views/slides/test/fixtures/text-template.d.ts +0 -3
  186. package/es/views/slides/test/fixtures/text-template.js +0 -58
  187. package/lib/fixtures/qcm-slide.d.ts +0 -2
  188. package/lib/fixtures/qcm-slide.js +0 -33
  189. package/lib/fixtures/temp-fixture.d.ts +0 -3
  190. package/lib/fixtures/temp-fixture.js +0 -84
  191. package/lib/views/slides/test/fixtures/select-template.d.ts +0 -3
  192. package/lib/views/slides/test/fixtures/text-template.d.ts +0 -3
  193. package/lib/views/slides/test/fixtures/text-template.js +0 -58
  194. package/src/fixtures/qcm-slide.ts +0 -35
  195. package/src/fixtures/temp-fixture.ts +0 -94
  196. package/src/views/slides/test/fixtures/text-template.ts +0 -61
@@ -0,0 +1,493 @@
1
+ import test from 'ava';
2
+ import identity from 'lodash/fp/identity';
3
+ import omit from 'lodash/fp/omit';
4
+ import {mapStateToSlidesProps} from '..';
5
+ import {StoreState} from '../../../reducers';
6
+ import {freeTextSlide} from './fixtures/free-text';
7
+
8
+ test('should create initial props when fetched slide is still not received', t => {
9
+ const state: StoreState = {
10
+ 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
+ },
35
+ skills: [],
36
+ slides: {
37
+ sli_N1XACJobn: null
38
+ },
39
+ token: '1234'
40
+ },
41
+ ui: {
42
+ currentSlideRef: '',
43
+ navigation: ['loader', 'slides'],
44
+ answers: [],
45
+ slide: {
46
+ validateButton: false
47
+ }
48
+ }
49
+ };
50
+
51
+ const props = mapStateToSlidesProps(state, identity);
52
+ t.is(props.congratsProps, undefined);
53
+ t.deepEqual(omit(['onQuitClick'], props.header), {
54
+ 'aria-label': 'aria-header-wrapper',
55
+ closeButtonAriaLabel: 'aria-close-button',
56
+ mode: '__revision_mode',
57
+ skillName: '__agility',
58
+ steps: [
59
+ {
60
+ current: true,
61
+ icon: 'no-answer',
62
+ value: '1'
63
+ },
64
+ {
65
+ current: false,
66
+ icon: 'no-answer',
67
+ value: '2'
68
+ },
69
+ {
70
+ current: false,
71
+ icon: 'no-answer',
72
+ value: '3'
73
+ },
74
+ {
75
+ current: false,
76
+ icon: 'no-answer',
77
+ value: '4'
78
+ },
79
+ {
80
+ current: false,
81
+ icon: 'no-answer',
82
+ value: '5'
83
+ }
84
+ ]
85
+ });
86
+ t.deepEqual(omit(['validateButton'], props.stack), {
87
+ correctionPopinProps: undefined,
88
+ endReview: false,
89
+ slides: {
90
+ '0': {
91
+ hidden: false,
92
+ position: 0,
93
+ loading: true
94
+ },
95
+ '1': {
96
+ hidden: false,
97
+ position: 1,
98
+ loading: true
99
+ },
100
+ '2': {
101
+ hidden: false,
102
+ position: 2,
103
+ loading: true
104
+ },
105
+ '3': {
106
+ hidden: false,
107
+ position: 3,
108
+ loading: true
109
+ },
110
+ '4': {
111
+ hidden: false,
112
+ position: 4,
113
+ loading: true
114
+ }
115
+ }
116
+ });
117
+ });
118
+
119
+ test('should create initial props when the slide is on the state', t => {
120
+ const state: StoreState = {
121
+ 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
+ }
145
+ },
146
+ skills: [],
147
+ slides: {
148
+ sli_N1XACJobn: freeTextSlide
149
+ },
150
+ token: '1234'
151
+ },
152
+ ui: {
153
+ currentSlideRef: 'sli_N1XACJobn',
154
+ navigation: ['loader', 'slides'],
155
+ answers: ['My value'],
156
+ slide: {
157
+ validateButton: true
158
+ }
159
+ }
160
+ };
161
+
162
+ const props = mapStateToSlidesProps(state, identity);
163
+ t.is(props.congratsProps, undefined);
164
+ t.deepEqual(omit(['onQuitClick'], props.header), {
165
+ 'aria-label': 'aria-header-wrapper',
166
+ closeButtonAriaLabel: 'aria-close-button',
167
+ mode: '__revision_mode',
168
+ skillName: '__agility',
169
+ steps: [
170
+ {
171
+ current: true,
172
+ icon: 'no-answer',
173
+ value: '1'
174
+ },
175
+ {
176
+ current: false,
177
+ icon: 'no-answer',
178
+ value: '2'
179
+ },
180
+ {
181
+ current: false,
182
+ icon: 'no-answer',
183
+ value: '3'
184
+ },
185
+ {
186
+ current: false,
187
+ icon: 'no-answer',
188
+ value: '4'
189
+ },
190
+ {
191
+ current: false,
192
+ icon: 'no-answer',
193
+ value: '5'
194
+ }
195
+ ]
196
+ });
197
+ t.deepEqual(omit(['validateButton', 'slides'], props.stack), {
198
+ correctionPopinProps: undefined,
199
+ endReview: false
200
+ });
201
+ t.false(props.stack.validateButton.disabled);
202
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
203
+ hidden: false,
204
+ position: 0,
205
+ loading: false,
206
+ parentContentTitle: 'From "Developing the review app" course',
207
+ questionText:
208
+ 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
209
+ });
210
+ t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
211
+ help: 'Type your answer.',
212
+ model: {
213
+ placeholder: 'Type here',
214
+ type: 'freeText',
215
+ value: 'My value'
216
+ }
217
+ });
218
+ t.deepEqual(omit(['0'], props.stack.slides), {
219
+ '1': {
220
+ hidden: false,
221
+ position: 1,
222
+ loading: true
223
+ },
224
+ '2': {
225
+ hidden: false,
226
+ position: 2,
227
+ loading: true
228
+ },
229
+ '3': {
230
+ hidden: false,
231
+ position: 3,
232
+ loading: true
233
+ },
234
+ '4': {
235
+ hidden: false,
236
+ position: 4,
237
+ loading: true
238
+ }
239
+ });
240
+ });
241
+
242
+ test('should create props when the next slide is on the state', t => {
243
+ const state: StoreState = {
244
+ 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
+ },
279
+ skills: [],
280
+ 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'
374
+ },
375
+ ui: {
376
+ currentSlideRef: 'sli_VJYjJnJhg',
377
+ navigation: ['loader', 'slides'],
378
+ answers: ['My value'],
379
+ slide: {
380
+ validateButton: false
381
+ }
382
+ }
383
+ };
384
+
385
+ const props = mapStateToSlidesProps(state, identity);
386
+ t.is(props.congratsProps, undefined);
387
+ t.deepEqual(omit(['onQuitClick'], props.header), {
388
+ 'aria-label': 'aria-header-wrapper',
389
+ closeButtonAriaLabel: 'aria-close-button',
390
+ mode: '__revision_mode',
391
+ skillName: '__agility',
392
+ steps: [
393
+ {
394
+ current: true,
395
+ icon: 'right',
396
+ value: '1'
397
+ },
398
+ {
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
400
+ current: true,
401
+ icon: 'no-answer',
402
+ value: '2'
403
+ },
404
+ {
405
+ current: false,
406
+ icon: 'no-answer',
407
+ value: '3'
408
+ },
409
+ {
410
+ current: false,
411
+ icon: 'no-answer',
412
+ value: '4'
413
+ },
414
+ {
415
+ current: false,
416
+ icon: 'no-answer',
417
+ value: '5'
418
+ }
419
+ ]
420
+ });
421
+ t.deepEqual(omit(['validateButton', 'slides'], props.stack), {
422
+ correctionPopinProps: undefined,
423
+ endReview: false
424
+ });
425
+ t.true(props.stack.validateButton.disabled);
426
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
427
+ hidden: false,
428
+ position: 0,
429
+ loading: false,
430
+ parentContentTitle: 'From "Developing the review app" course',
431
+ questionText:
432
+ 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
433
+ });
434
+ t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
435
+ help: 'Type your answer.',
436
+ model: {
437
+ placeholder: 'Type here',
438
+ type: 'freeText',
439
+ value: 'My value'
440
+ }
441
+ });
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 ?'
475
+ },
476
+ '2': {
477
+ hidden: false,
478
+ position: 2,
479
+ loading: true
480
+ },
481
+ '3': {
482
+ hidden: false,
483
+ position: 3,
484
+ loading: true
485
+ },
486
+ '4': {
487
+ hidden: false,
488
+ position: 4,
489
+ loading: true
490
+ }
491
+ }
492
+ );
493
+ });
@@ -1,13 +1,13 @@
1
1
  import test from 'ava';
2
2
  import identity from 'lodash/fp/identity';
3
- import {SlideFromAPI, UISlide} from '../../../types/common';
3
+ import {SlideFromAPI} from '../../../types/common';
4
4
  import {mapApiSlideToUi} from '../map-api-slide-to-ui';
5
+ import {UISlide} from '..';
5
6
  import {qcmUISlide, qcmSlide} from './fixtures/qcm';
6
7
  import {qcmDragUISlide, qcmDragSlide} from './fixtures/qcm-drag';
7
8
  import {freeTextSlide, freeTextUISlide} from './fixtures/free-text';
8
9
  import {qcmGraphicUISlide, qcmGraphicSlide} from './fixtures/qcm-graphic';
9
- import {textTemplateSlide, textTemplateUISlide} from './fixtures/text-template';
10
- import {selectTemplateSlide, selectTemplateUISlide} from './fixtures/select-template';
10
+ import {templateSlide, templateUISlide} from './fixtures/template';
11
11
  import {sliderSlide, sliderUISlide} from './fixtures/slider';
12
12
 
13
13
  const _mapApiSlideToUi = mapApiSlideToUi(identity);
@@ -38,15 +38,10 @@ test('qcm graphic', macro, {
38
38
  answers: [],
39
39
  expectedUiSlide: qcmGraphicUISlide
40
40
  });
41
- test('text template', macro, {
42
- slide: textTemplateSlide,
41
+ test('template', macro, {
42
+ slide: templateSlide,
43
43
  answers: [],
44
- expectedUiSlide: textTemplateUISlide
45
- });
46
- test('select template', macro, {
47
- slide: selectTemplateSlide,
48
- answers: [],
49
- expectedUiSlide: selectTemplateUISlide
44
+ expectedUiSlide: templateUISlide
50
45
  });
51
46
  test('free text', macro, {slide: freeTextSlide, answers: [], expectedUiSlide: freeTextUISlide});
52
47
  test('slider', macro, {slide: sliderSlide, answers: [], expectedUiSlide: sliderUISlide});
@@ -0,0 +1,92 @@
1
+ import test from 'ava';
2
+ import omit from 'lodash/fp/omit';
3
+ import get from 'lodash/fp/get';
4
+ import {mapStateToSlidesProps} from '..';
5
+ import {ProgressionFromAPI} from '../../../types/common';
6
+ import {services} from '../../../test/util/services.mock';
7
+ import {createTestStore} from '../../../actions/test/create-test-store';
8
+ import {StoreState} from '../../../reducers';
9
+ import {EDIT_TEMPLATE} from '../../../actions/ui/answers';
10
+ import {Template} from '../../../types/slides';
11
+ import {templateSlide} from './fixtures/template';
12
+
13
+ const progression: ProgressionFromAPI = {
14
+ _id: '123456789123',
15
+ content: {type: 'skill', ref: '_skill-ref'},
16
+ engine: {
17
+ ref: 'review'
18
+ },
19
+ state: {
20
+ allAnswers: [],
21
+ isCorrect: true,
22
+ nextContent: {
23
+ ref: templateSlide.id,
24
+ type: 'slide'
25
+ },
26
+ pendingSlides: [],
27
+ slides: [],
28
+ step: {
29
+ current: 1
30
+ },
31
+ stars: 0
32
+ }
33
+ };
34
+
35
+ const initialState: StoreState = {
36
+ data: {
37
+ progression,
38
+ slides: {
39
+ [templateSlide.id]: templateSlide
40
+ },
41
+ skills: [],
42
+ token: '1234'
43
+ },
44
+ ui: {
45
+ currentSlideRef: templateSlide.id,
46
+ navigation: ['skills', 'slides'],
47
+ answers: [],
48
+ slide: {
49
+ validateButton: false
50
+ }
51
+ }
52
+ };
53
+
54
+ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Template Text slide', t => {
55
+ t.plan(2);
56
+
57
+ const expectedActions = [{type: EDIT_TEMPLATE, payload: ['', 'test', '']}];
58
+ const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
59
+
60
+ const props = mapStateToSlidesProps(getState(), dispatch);
61
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
62
+ hidden: false,
63
+ position: 0,
64
+ loading: false,
65
+ parentContentTitle: 'From "Developing the review app" course',
66
+ questionText: 'Complétez la phrase ci-dessous.'
67
+ });
68
+
69
+ const SlideProps = props.stack.slides['0'].answerUI?.model as Template;
70
+ const onChange = get(['1', 'onChange'], SlideProps.answers);
71
+ onChange('test');
72
+ });
73
+
74
+ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Template Select slide', t => {
75
+ t.plan(2);
76
+
77
+ const expectedActions = [{type: EDIT_TEMPLATE, payload: ['Catalogue', '', '']}];
78
+ const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
79
+
80
+ const props = mapStateToSlidesProps(getState(), dispatch);
81
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
82
+ hidden: false,
83
+ position: 0,
84
+ loading: false,
85
+ parentContentTitle: 'From "Developing the review app" course',
86
+ questionText: 'Complétez la phrase ci-dessous.'
87
+ });
88
+
89
+ const SlideProps = props.stack.slides['0'].answerUI?.model as Template;
90
+ const onChange = get(['0', 'onChange'], SlideProps.answers);
91
+ onChange('Catalogue');
92
+ });
@@ -1,2 +0,0 @@
1
- import { UISlide } from '../types/common';
2
- export declare const slide: Pick<UISlide, 'questionText' | 'answerUI'>;
@@ -1,33 +0,0 @@
1
- import noop from 'lodash/fp/noop';
2
- export const slide = {
3
- questionText: 'QCM',
4
- answerUI: {
5
- help: '__help',
6
- model: {
7
- type: 'qcm',
8
- answers: [
9
- {
10
- selected: false,
11
- title: 'choix1',
12
- help: '(help choix1)',
13
- ariaLabel: '__ariaLabel1',
14
- onClick: noop
15
- },
16
- {
17
- selected: false,
18
- title: 'choix2',
19
- help: '(help choix2)',
20
- ariaLabel: '__ariaLabel2',
21
- onClick: noop
22
- },
23
- {
24
- selected: false,
25
- title: 'choix3',
26
- help: '(help choix3)',
27
- ariaLabel: '__ariaLabel3',
28
- onClick: noop
29
- }
30
- ]
31
- }
32
- }
33
- };
@@ -1,3 +0,0 @@
1
- import { SlidesViewProps, CorrectionPopinProps } from '../views/slides';
2
- export declare const correctionPopinProps: CorrectionPopinProps;
3
- export declare const congratsProps: SlidesViewProps['congratsProps'];