@coorpacademy/app-review 0.2.12 → 0.3.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 (198) hide show
  1. package/es/actions/api/fetch-correction.js +1 -1
  2. package/es/actions/api/post-answer.d.ts +6 -0
  3. package/es/actions/api/post-answer.js +3 -1
  4. package/es/actions/ui/answers.d.ts +3 -0
  5. package/es/actions/ui/answers.js +3 -1
  6. package/es/reducers/index.d.ts +1 -1
  7. package/es/reducers/ui/answers.d.ts +4 -2
  8. package/es/reducers/ui/answers.js +6 -3
  9. package/es/reducers/ui/index.d.ts +4 -4
  10. package/es/reducers/ui/slide.d.ts +6 -4
  11. package/es/reducers/ui/slide.js +12 -4
  12. package/es/views/slides/index.js +4 -4
  13. package/lib/actions/api/fetch-correction.js +1 -1
  14. package/lib/actions/api/post-answer.d.ts +6 -0
  15. package/lib/actions/api/post-answer.js +4 -2
  16. package/lib/actions/ui/answers.d.ts +3 -0
  17. package/lib/actions/ui/answers.js +3 -1
  18. package/lib/reducers/index.d.ts +1 -1
  19. package/lib/reducers/ui/answers.d.ts +4 -2
  20. package/lib/reducers/ui/answers.js +6 -3
  21. package/lib/reducers/ui/index.d.ts +4 -4
  22. package/lib/reducers/ui/slide.d.ts +6 -4
  23. package/lib/reducers/ui/slide.js +12 -4
  24. package/lib/views/slides/index.js +4 -4
  25. package/package.json +2 -2
  26. package/src/actions/api/fetch-correction.ts +1 -1
  27. package/src/actions/api/post-answer.ts +5 -1
  28. package/src/actions/api/test/fetch-correction.test.ts +6 -2
  29. package/src/actions/api/test/fetch-rank.test.ts +2 -4
  30. package/src/actions/api/test/fetch-skills.test.ts +2 -4
  31. package/src/actions/api/test/fetch-slide.test.ts +2 -4
  32. package/src/actions/api/test/post-answer.test.ts +52 -13
  33. package/src/actions/api/test/post-progression.test.ts +2 -4
  34. package/src/actions/data/test/token.test.ts +2 -4
  35. package/src/actions/ui/answers.ts +4 -1
  36. package/src/actions/ui/test/answers.test.ts +38 -14
  37. package/src/actions/ui/test/next-slide.test.ts +8 -4
  38. package/src/actions/ui/test/slides.test.ts +2 -4
  39. package/src/reducers/data/test/progression.test.ts +1 -0
  40. package/src/reducers/ui/answers.ts +11 -5
  41. package/src/reducers/ui/index.ts +2 -2
  42. package/src/reducers/ui/slide.ts +30 -9
  43. package/src/reducers/ui/test/answers.test.ts +61 -13
  44. package/src/reducers/ui/test/slide.test.ts +36 -7
  45. package/src/views/skills/test/skills.test.ts +4 -8
  46. package/src/views/slides/index.ts +4 -4
  47. package/src/views/slides/test/index.test.ts +173 -28
  48. package/src/views/slides/test/slide.free-text.on-change.test.ts +7 -2
  49. package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +7 -2
  50. package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +7 -2
  51. package/src/views/slides/test/slide.qcm.on-click.test.ts +7 -2
  52. package/src/views/slides/test/slide.slider.on-change.test.ts +7 -2
  53. package/src/views/slides/test/slide.slider.on-slider-change.test.ts +7 -2
  54. package/src/views/slides/test/slide.template.on-change.test.ts +12 -4
  55. package/es/actions/api/test/fetch-correction.test.d.ts +0 -1
  56. package/es/actions/api/test/fetch-correction.test.js +0 -91
  57. package/es/actions/api/test/fetch-rank.test.d.ts +0 -1
  58. package/es/actions/api/test/fetch-rank.test.js +0 -100
  59. package/es/actions/api/test/fetch-skills.test.d.ts +0 -1
  60. package/es/actions/api/test/fetch-skills.test.js +0 -61
  61. package/es/actions/api/test/fetch-slide.test.d.ts +0 -1
  62. package/es/actions/api/test/fetch-slide.test.js +0 -68
  63. package/es/actions/api/test/post-answer.test.d.ts +0 -1
  64. package/es/actions/api/test/post-answer.test.js +0 -172
  65. package/es/actions/api/test/post-progression.test.d.ts +0 -1
  66. package/es/actions/api/test/post-progression.test.js +0 -109
  67. package/es/actions/data/test/token.test.d.ts +0 -1
  68. package/es/actions/data/test/token.test.js +0 -27
  69. package/es/actions/ui/test/answers.test.d.ts +0 -1
  70. package/es/actions/ui/test/answers.test.js +0 -117
  71. package/es/actions/ui/test/next-slide.test.d.ts +0 -1
  72. package/es/actions/ui/test/next-slide.test.js +0 -63
  73. package/es/actions/ui/test/slides.test.d.ts +0 -1
  74. package/es/actions/ui/test/slides.test.js +0 -28
  75. package/es/reducers/data/test/corrections.test.d.ts +0 -1
  76. package/es/reducers/data/test/corrections.test.js +0 -27
  77. package/es/reducers/data/test/progression.test.d.ts +0 -1
  78. package/es/reducers/data/test/progression.test.js +0 -24
  79. package/es/reducers/data/test/rank.test.d.ts +0 -1
  80. package/es/reducers/data/test/rank.test.js +0 -59
  81. package/es/reducers/data/test/skills.test.d.ts +0 -1
  82. package/es/reducers/data/test/skills.test.js +0 -12
  83. package/es/reducers/data/test/slides.test.d.ts +0 -1
  84. package/es/reducers/data/test/slides.test.js +0 -21
  85. package/es/reducers/data/test/token.test.d.ts +0 -1
  86. package/es/reducers/data/test/token.test.js +0 -11
  87. package/es/reducers/ui/test/answers.test.d.ts +0 -1
  88. package/es/reducers/ui/test/answers.test.js +0 -31
  89. package/es/reducers/ui/test/current-slide-ref.test.d.ts +0 -1
  90. package/es/reducers/ui/test/current-slide-ref.test.js +0 -12
  91. package/es/reducers/ui/test/navigation.test.d.ts +0 -1
  92. package/es/reducers/ui/test/navigation.test.js +0 -15
  93. package/es/reducers/ui/test/slide.test.d.ts +0 -1
  94. package/es/reducers/ui/test/slide.test.js +0 -24
  95. package/es/services/test/fetch-correction.test.d.ts +0 -1
  96. package/es/services/test/fetch-correction.test.js +0 -39
  97. package/es/services/test/fetch-rank.test.d.ts +0 -1
  98. package/es/services/test/fetch-rank.test.js +0 -24
  99. package/es/services/test/fetch-skills.test.d.ts +0 -1
  100. package/es/services/test/fetch-skills.test.js +0 -29
  101. package/es/services/test/fetch-slide.test.d.ts +0 -1
  102. package/es/services/test/fetch-slide.test.js +0 -22
  103. package/es/services/test/post-answer.test.d.ts +0 -1
  104. package/es/services/test/post-answer.test.js +0 -88
  105. package/es/services/test/post-progression.test.d.ts +0 -1
  106. package/es/services/test/post-progression.test.js +0 -56
  107. package/es/views/skills/test/skills.test.d.ts +0 -1
  108. package/es/views/skills/test/skills.test.js +0 -98
  109. package/es/views/slides/test/index.test.d.ts +0 -1
  110. package/es/views/slides/test/index.test.js +0 -979
  111. package/es/views/slides/test/map-api-slide-to-ui.test.d.ts +0 -1
  112. package/es/views/slides/test/map-api-slide-to-ui.test.js +0 -36
  113. package/es/views/slides/test/slide.free-text.on-change.test.d.ts +0 -1
  114. package/es/views/slides/test/slide.free-text.on-change.test.js +0 -72
  115. package/es/views/slides/test/slide.qcm-drag.on-click.test.d.ts +0 -1
  116. package/es/views/slides/test/slide.qcm-drag.on-click.test.js +0 -72
  117. package/es/views/slides/test/slide.qcm-graphic.on-click.test.d.ts +0 -1
  118. package/es/views/slides/test/slide.qcm-graphic.on-click.test.js +0 -72
  119. package/es/views/slides/test/slide.qcm.on-click.test.d.ts +0 -1
  120. package/es/views/slides/test/slide.qcm.on-click.test.js +0 -74
  121. package/es/views/slides/test/slide.slider.on-change.test.d.ts +0 -1
  122. package/es/views/slides/test/slide.slider.on-change.test.js +0 -73
  123. package/es/views/slides/test/slide.slider.on-slider-change.test.d.ts +0 -1
  124. package/es/views/slides/test/slide.slider.on-slider-change.test.js +0 -63
  125. package/es/views/slides/test/slide.template.on-change.test.d.ts +0 -1
  126. package/es/views/slides/test/slide.template.on-change.test.js +0 -85
  127. package/lib/actions/api/test/fetch-correction.test.d.ts +0 -1
  128. package/lib/actions/api/test/fetch-correction.test.js +0 -151
  129. package/lib/actions/api/test/fetch-rank.test.d.ts +0 -1
  130. package/lib/actions/api/test/fetch-rank.test.js +0 -171
  131. package/lib/actions/api/test/fetch-skills.test.d.ts +0 -1
  132. package/lib/actions/api/test/fetch-skills.test.js +0 -120
  133. package/lib/actions/api/test/fetch-slide.test.d.ts +0 -1
  134. package/lib/actions/api/test/fetch-slide.test.js +0 -127
  135. package/lib/actions/api/test/post-answer.test.d.ts +0 -1
  136. package/lib/actions/api/test/post-answer.test.js +0 -254
  137. package/lib/actions/api/test/post-progression.test.d.ts +0 -1
  138. package/lib/actions/api/test/post-progression.test.js +0 -167
  139. package/lib/actions/data/test/token.test.d.ts +0 -1
  140. package/lib/actions/data/test/token.test.js +0 -72
  141. package/lib/actions/ui/test/answers.test.d.ts +0 -1
  142. package/lib/actions/ui/test/answers.test.js +0 -233
  143. package/lib/actions/ui/test/next-slide.test.d.ts +0 -1
  144. package/lib/actions/ui/test/next-slide.test.js +0 -64
  145. package/lib/actions/ui/test/slides.test.d.ts +0 -1
  146. package/lib/actions/ui/test/slides.test.js +0 -73
  147. package/lib/reducers/data/test/corrections.test.d.ts +0 -1
  148. package/lib/reducers/data/test/corrections.test.js +0 -28
  149. package/lib/reducers/data/test/progression.test.d.ts +0 -1
  150. package/lib/reducers/data/test/progression.test.js +0 -24
  151. package/lib/reducers/data/test/rank.test.d.ts +0 -1
  152. package/lib/reducers/data/test/rank.test.js +0 -59
  153. package/lib/reducers/data/test/skills.test.d.ts +0 -1
  154. package/lib/reducers/data/test/skills.test.js +0 -12
  155. package/lib/reducers/data/test/slides.test.d.ts +0 -1
  156. package/lib/reducers/data/test/slides.test.js +0 -22
  157. package/lib/reducers/data/test/token.test.d.ts +0 -1
  158. package/lib/reducers/data/test/token.test.js +0 -11
  159. package/lib/reducers/ui/test/answers.test.d.ts +0 -1
  160. package/lib/reducers/ui/test/answers.test.js +0 -31
  161. package/lib/reducers/ui/test/current-slide-ref.test.d.ts +0 -1
  162. package/lib/reducers/ui/test/current-slide-ref.test.js +0 -12
  163. package/lib/reducers/ui/test/navigation.test.d.ts +0 -1
  164. package/lib/reducers/ui/test/navigation.test.js +0 -15
  165. package/lib/reducers/ui/test/slide.test.d.ts +0 -1
  166. package/lib/reducers/ui/test/slide.test.js +0 -24
  167. package/lib/services/test/fetch-correction.test.d.ts +0 -1
  168. package/lib/services/test/fetch-correction.test.js +0 -95
  169. package/lib/services/test/fetch-rank.test.d.ts +0 -1
  170. package/lib/services/test/fetch-rank.test.js +0 -78
  171. package/lib/services/test/fetch-skills.test.d.ts +0 -1
  172. package/lib/services/test/fetch-skills.test.js +0 -83
  173. package/lib/services/test/fetch-slide.test.d.ts +0 -1
  174. package/lib/services/test/fetch-slide.test.js +0 -76
  175. package/lib/services/test/post-answer.test.d.ts +0 -1
  176. package/lib/services/test/post-answer.test.js +0 -142
  177. package/lib/services/test/post-progression.test.d.ts +0 -1
  178. package/lib/services/test/post-progression.test.js +0 -110
  179. package/lib/views/skills/test/skills.test.d.ts +0 -1
  180. package/lib/views/skills/test/skills.test.js +0 -98
  181. package/lib/views/slides/test/index.test.d.ts +0 -1
  182. package/lib/views/slides/test/index.test.js +0 -990
  183. package/lib/views/slides/test/map-api-slide-to-ui.test.d.ts +0 -1
  184. package/lib/views/slides/test/map-api-slide-to-ui.test.js +0 -47
  185. package/lib/views/slides/test/slide.free-text.on-change.test.d.ts +0 -1
  186. package/lib/views/slides/test/slide.free-text.on-change.test.js +0 -74
  187. package/lib/views/slides/test/slide.qcm-drag.on-click.test.d.ts +0 -1
  188. package/lib/views/slides/test/slide.qcm-drag.on-click.test.js +0 -74
  189. package/lib/views/slides/test/slide.qcm-graphic.on-click.test.d.ts +0 -1
  190. package/lib/views/slides/test/slide.qcm-graphic.on-click.test.js +0 -74
  191. package/lib/views/slides/test/slide.qcm.on-click.test.d.ts +0 -1
  192. package/lib/views/slides/test/slide.qcm.on-click.test.js +0 -76
  193. package/lib/views/slides/test/slide.slider.on-change.test.d.ts +0 -1
  194. package/lib/views/slides/test/slide.slider.on-change.test.js +0 -75
  195. package/lib/views/slides/test/slide.slider.on-slider-change.test.d.ts +0 -1
  196. package/lib/views/slides/test/slide.slider.on-slider-change.test.js +0 -65
  197. package/lib/views/slides/test/slide.template.on-change.test.d.ts +0 -1
  198. package/lib/views/slides/test/slide.template.on-change.test.js +0 -88
@@ -1,979 +0,0 @@
1
- import test from 'ava';
2
- import identity from 'lodash/fp/identity';
3
- import omit from 'lodash/fp/omit';
4
- import set from 'lodash/fp/set';
5
- import { postProgressionResponse as createdProgression, postAnswerResponses, progressionSlideWithPendingSlide, getChoicesCorrection, incorrectFreeTextPostAnswerResponse } from '../../../test/util/services.mock';
6
- import { mapStateToSlidesProps } from '..';
7
- import { freeTextSlide } from './fixtures/free-text';
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
- const popinPropsRightAnswer = {
13
- resultLabel: '_right',
14
- information: {
15
- label: '_klf',
16
- message: '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.'
17
- },
18
- klf: undefined,
19
- next: {
20
- ariaLabel: '_correctionNextAriaLabel',
21
- label: '_correctionNextLabel'
22
- },
23
- type: 'right'
24
- };
25
- const popinPropsWrongAnswer = {
26
- ...popinPropsRightAnswer,
27
- klf: {
28
- label: '_klf',
29
- tooltip: '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.'
30
- },
31
- type: 'wrong',
32
- resultLabel: '_wrong',
33
- information: {
34
- label: '_correctAnswer',
35
- message: 'Benchmark'
36
- }
37
- };
38
- test('should create initial props when fetched slide is not still received', t => {
39
- // SCENARIO : @@progression/POST_SUCCESS ok and @@slides/FETCH_REQUEST, (the slide is being fetched)
40
- const state = {
41
- data: {
42
- progression: createdProgression,
43
- skills: [],
44
- slides: {
45
- sli_N1XACJobn: null
46
- },
47
- token: '1234',
48
- corrections: {},
49
- rank: {}
50
- },
51
- ui: {
52
- currentSlideRef: '',
53
- navigation: ['loader', 'slides'],
54
- answers: [],
55
- slide: {
56
- validateButton: false
57
- }
58
- }
59
- };
60
- const props = mapStateToSlidesProps(state, identity);
61
- t.is(props.congratsProps, undefined);
62
- t.deepEqual(omit(['onQuitClick'], props.header), {
63
- 'aria-label': 'aria-header-wrapper',
64
- closeButtonAriaLabel: 'aria-close-button',
65
- mode: '__revision_mode',
66
- skillName: '__agility',
67
- steps: [
68
- {
69
- current: true,
70
- icon: 'no-answer',
71
- value: '1'
72
- },
73
- {
74
- current: false,
75
- icon: 'no-answer',
76
- value: '2'
77
- },
78
- {
79
- current: false,
80
- icon: 'no-answer',
81
- value: '3'
82
- },
83
- {
84
- current: false,
85
- icon: 'no-answer',
86
- value: '4'
87
- },
88
- {
89
- current: false,
90
- icon: 'no-answer',
91
- value: '5'
92
- }
93
- ]
94
- });
95
- t.deepEqual(omit(['validateButton'], props.stack), {
96
- correctionPopinProps: undefined,
97
- endReview: false,
98
- slides: {
99
- '0': {
100
- hidden: false,
101
- position: 0,
102
- loading: true
103
- },
104
- '1': {
105
- hidden: false,
106
- position: 1,
107
- loading: true
108
- },
109
- '2': {
110
- hidden: false,
111
- position: 2,
112
- loading: true
113
- },
114
- '3': {
115
- hidden: false,
116
- position: 3,
117
- loading: true
118
- },
119
- '4': {
120
- hidden: false,
121
- position: 4,
122
- loading: true
123
- }
124
- }
125
- });
126
- });
127
- test('should create props when first slide is on the state', t => {
128
- // SCENARIO : after @@slides/FETCH_SUCCESS
129
- const state = {
130
- data: {
131
- progression: createdProgression,
132
- skills: [],
133
- slides: {
134
- sli_VJYjJnJhg: freeTextSlide
135
- },
136
- token: '1234',
137
- corrections: {},
138
- rank: {}
139
- },
140
- ui: {
141
- currentSlideRef: 'sli_VJYjJnJhg',
142
- navigation: ['loader', 'slides'],
143
- answers: [],
144
- slide: {
145
- validateButton: false
146
- }
147
- }
148
- };
149
- const props = mapStateToSlidesProps(state, identity);
150
- t.is(props.congratsProps, undefined);
151
- t.deepEqual(omit(['onQuitClick'], props.header), {
152
- 'aria-label': 'aria-header-wrapper',
153
- closeButtonAriaLabel: 'aria-close-button',
154
- mode: '__revision_mode',
155
- skillName: '__agility',
156
- steps: [
157
- {
158
- current: true,
159
- icon: 'no-answer',
160
- value: '1'
161
- },
162
- {
163
- current: false,
164
- icon: 'no-answer',
165
- value: '2'
166
- },
167
- {
168
- current: false,
169
- icon: 'no-answer',
170
- value: '3'
171
- },
172
- {
173
- current: false,
174
- icon: 'no-answer',
175
- value: '4'
176
- },
177
- {
178
- current: false,
179
- icon: 'no-answer',
180
- value: '5'
181
- }
182
- ]
183
- });
184
- t.deepEqual(omit(['validateButton', 'slides'], props.stack), {
185
- correctionPopinProps: undefined,
186
- endReview: false
187
- });
188
- t.deepEqual(omit('answerUI', props.stack.slides['0']), {
189
- animateCorrectionPopin: false,
190
- showCorrectionPopin: false,
191
- hidden: false,
192
- position: 0,
193
- loading: false,
194
- parentContentTitle: 'From "Developing the review app" course',
195
- questionText: 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
196
- });
197
- t.is(props.stack.validateButton.disabled, true);
198
- t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
199
- help: 'Type your answer.',
200
- model: {
201
- placeholder: 'Type here',
202
- type: 'freeText',
203
- value: ''
204
- }
205
- });
206
- t.deepEqual(omit(['0'], props.stack.slides), {
207
- '1': {
208
- hidden: false,
209
- position: 1,
210
- loading: true
211
- },
212
- '2': {
213
- hidden: false,
214
- position: 2,
215
- loading: true
216
- },
217
- '3': {
218
- hidden: false,
219
- position: 3,
220
- loading: true
221
- },
222
- '4': {
223
- hidden: false,
224
- position: 4,
225
- loading: true
226
- }
227
- });
228
- });
229
- test('should create props when slide is on the state and user has selected answers', t => {
230
- // This is the case after EDIT_ANSWER and before POST_ANSWER_REQUEST
231
- const state = {
232
- data: {
233
- progression: createdProgression,
234
- skills: [],
235
- slides: {
236
- sli_VJYjJnJhg: freeTextSlide
237
- },
238
- token: '1234',
239
- corrections: {},
240
- rank: {}
241
- },
242
- ui: {
243
- currentSlideRef: 'sli_VJYjJnJhg',
244
- navigation: ['loader', 'slides'],
245
- answers: ['My value'],
246
- slide: {
247
- validateButton: true
248
- }
249
- }
250
- };
251
- const props = mapStateToSlidesProps(state, identity);
252
- t.is(props.congratsProps, undefined);
253
- t.deepEqual(omit(['onQuitClick'], props.header), {
254
- 'aria-label': 'aria-header-wrapper',
255
- closeButtonAriaLabel: 'aria-close-button',
256
- mode: '__revision_mode',
257
- skillName: '__agility',
258
- steps: [
259
- {
260
- current: true,
261
- icon: 'no-answer',
262
- value: '1'
263
- },
264
- {
265
- current: false,
266
- icon: 'no-answer',
267
- value: '2'
268
- },
269
- {
270
- current: false,
271
- icon: 'no-answer',
272
- value: '3'
273
- },
274
- {
275
- current: false,
276
- icon: 'no-answer',
277
- value: '4'
278
- },
279
- {
280
- current: false,
281
- icon: 'no-answer',
282
- value: '5'
283
- }
284
- ]
285
- });
286
- t.deepEqual(omit(['validateButton', 'slides'], props.stack), {
287
- correctionPopinProps: undefined,
288
- endReview: false
289
- });
290
- t.deepEqual(omit('answerUI', props.stack.slides['0']), {
291
- animateCorrectionPopin: false,
292
- showCorrectionPopin: false,
293
- hidden: false,
294
- position: 0,
295
- loading: false,
296
- parentContentTitle: 'From "Developing the review app" course',
297
- questionText: 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
298
- });
299
- t.is(props.stack.validateButton.disabled, false);
300
- t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
301
- help: 'Type your answer.',
302
- model: {
303
- placeholder: 'Type here',
304
- type: 'freeText',
305
- value: 'My value'
306
- }
307
- });
308
- t.deepEqual(omit(['0'], props.stack.slides), {
309
- '1': {
310
- hidden: false,
311
- position: 1,
312
- loading: true
313
- },
314
- '2': {
315
- hidden: false,
316
- position: 2,
317
- loading: true
318
- },
319
- '3': {
320
- hidden: false,
321
- position: 3,
322
- loading: true
323
- },
324
- '4': {
325
- hidden: false,
326
- position: 4,
327
- loading: true
328
- }
329
- });
330
- });
331
- test('should verify props when first slide was answered correctly and next slide is not fetched yet', t => {
332
- // Scenario: after POST_ANSWER_SUCCESS and during SLIDE_FETCH_REQUEST for the nextContent.ref slide
333
- const state = {
334
- data: {
335
- progression: postAnswerResponses.sli_VJYjJnJhg,
336
- skills: [],
337
- slides: {
338
- sli_VJYjJnJhg: freeTextSlide,
339
- sli_VkSQroQnx: null
340
- },
341
- token: '1234',
342
- corrections: {},
343
- rank: {}
344
- },
345
- ui: {
346
- currentSlideRef: 'sli_VJYjJnJhg',
347
- navigation: ['loader', 'slides'],
348
- answers: ['My value'],
349
- slide: {
350
- validateButton: false
351
- }
352
- }
353
- };
354
- const props = mapStateToSlidesProps(state, identity);
355
- t.is(props.congratsProps, undefined);
356
- t.deepEqual(omit(['onQuitClick'], props.header), {
357
- 'aria-label': 'aria-header-wrapper',
358
- closeButtonAriaLabel: 'aria-close-button',
359
- mode: '__revision_mode',
360
- skillName: '__agility',
361
- steps: [
362
- {
363
- current: true,
364
- icon: 'right',
365
- value: '1'
366
- },
367
- {
368
- current: false,
369
- icon: 'no-answer',
370
- value: '2'
371
- },
372
- {
373
- current: false,
374
- icon: 'no-answer',
375
- value: '3'
376
- },
377
- {
378
- current: false,
379
- icon: 'no-answer',
380
- value: '4'
381
- },
382
- {
383
- current: false,
384
- icon: 'no-answer',
385
- value: '5'
386
- }
387
- ]
388
- });
389
- t.deepEqual(omit(['validateButton', 'slides'], props.stack), {
390
- correctionPopinProps: undefined,
391
- endReview: false
392
- });
393
- t.deepEqual(omit('answerUI', props.stack.slides['0']), {
394
- animateCorrectionPopin: false,
395
- showCorrectionPopin: false,
396
- hidden: false,
397
- position: 0,
398
- loading: false,
399
- parentContentTitle: 'From "Developing the review app" course',
400
- questionText: 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
401
- });
402
- t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
403
- help: 'Type your answer.',
404
- model: {
405
- placeholder: 'Type here',
406
- type: 'freeText',
407
- value: 'My value'
408
- }
409
- });
410
- t.is(props.stack.validateButton.disabled, true);
411
- t.deepEqual(omit(['0'], props.stack.slides), {
412
- '1': {
413
- hidden: false,
414
- position: 1,
415
- loading: true
416
- },
417
- '2': {
418
- hidden: false,
419
- position: 2,
420
- loading: true
421
- },
422
- '3': {
423
- hidden: false,
424
- position: 3,
425
- loading: true
426
- },
427
- '4': {
428
- hidden: false,
429
- position: 4,
430
- loading: true
431
- }
432
- });
433
- });
434
- test('should verify props when first slide was answered with error and next slide is not fetched yet', t => {
435
- // Scenario: after POST_ANSWER_SUCCESS and during SLIDE_FETCH_REQUEST for the nextContent.ref slide
436
- const state = {
437
- data: {
438
- progression: set(['state', 'allAnswers', 0, 'isCorrect'], false, postAnswerResponses.sli_VJYjJnJhg),
439
- skills: [],
440
- slides: {
441
- sli_VJYjJnJhg: freeTextSlide,
442
- sli_VkSQroQnx: null
443
- },
444
- token: '1234',
445
- corrections: {},
446
- rank: {}
447
- },
448
- ui: {
449
- currentSlideRef: 'sli_VJYjJnJhg',
450
- navigation: ['loader', 'slides'],
451
- answers: ['My value'],
452
- slide: {
453
- validateButton: false
454
- }
455
- }
456
- };
457
- const props = mapStateToSlidesProps(state, identity);
458
- t.is(props.congratsProps, undefined);
459
- t.deepEqual(omit(['onQuitClick'], props.header), {
460
- 'aria-label': 'aria-header-wrapper',
461
- closeButtonAriaLabel: 'aria-close-button',
462
- mode: '__revision_mode',
463
- skillName: '__agility',
464
- steps: [
465
- {
466
- current: true,
467
- icon: 'wrong',
468
- value: '1'
469
- },
470
- {
471
- current: false,
472
- icon: 'no-answer',
473
- value: '2'
474
- },
475
- {
476
- current: false,
477
- icon: 'no-answer',
478
- value: '3'
479
- },
480
- {
481
- current: false,
482
- icon: 'no-answer',
483
- value: '4'
484
- },
485
- {
486
- current: false,
487
- icon: 'no-answer',
488
- value: '5'
489
- }
490
- ]
491
- });
492
- });
493
- test('should verify props when first slide was answered, next slide is fetched & correction is fetched', t => {
494
- // Scenario: after POST_ANSWER_SUCCESS and SLIDE_FETCH_SUCCESS for the nextContent.ref slide
495
- const state = {
496
- data: {
497
- progression: postAnswerResponses.sli_VJYjJnJhg,
498
- skills: [],
499
- slides: {
500
- sli_VJYjJnJhg: freeTextSlide,
501
- sli_VkSQroQnx: qcmGraphicSlide
502
- },
503
- token: '1234',
504
- corrections: {
505
- [freeTextSlide._id]: getChoicesCorrection(freeTextSlide._id)
506
- },
507
- rank: {}
508
- },
509
- ui: {
510
- currentSlideRef: 'sli_VJYjJnJhg',
511
- navigation: ['loader', 'slides'],
512
- answers: ['My value'],
513
- slide: {
514
- validateButton: false,
515
- animateCorrectionPopin: true,
516
- showCorrectionPopin: true
517
- }
518
- }
519
- };
520
- const props = mapStateToSlidesProps(state, identity);
521
- t.is(props.congratsProps, undefined);
522
- t.deepEqual(omit(['onQuitClick'], props.header), {
523
- 'aria-label': 'aria-header-wrapper',
524
- closeButtonAriaLabel: 'aria-close-button',
525
- mode: '__revision_mode',
526
- skillName: '__agility',
527
- steps: [
528
- {
529
- current: true,
530
- icon: 'right',
531
- value: '1'
532
- },
533
- {
534
- current: false,
535
- icon: 'no-answer',
536
- value: '2'
537
- },
538
- {
539
- current: false,
540
- icon: 'no-answer',
541
- value: '3'
542
- },
543
- {
544
- current: false,
545
- icon: 'no-answer',
546
- value: '4'
547
- },
548
- {
549
- current: false,
550
- icon: 'no-answer',
551
- value: '5'
552
- }
553
- ]
554
- });
555
- t.deepEqual(omit(['validateButton', 'slides', 'correctionPopinProps.klf.onClick'], props.stack), {
556
- correctionPopinProps: popinPropsRightAnswer,
557
- endReview: false
558
- });
559
- t.deepEqual(omit('answerUI', props.stack.slides['0']), {
560
- animateCorrectionPopin: true,
561
- showCorrectionPopin: true,
562
- hidden: false,
563
- position: 0,
564
- loading: false,
565
- parentContentTitle: 'From "Developing the review app" course',
566
- questionText: 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
567
- });
568
- t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
569
- help: 'Type your answer.',
570
- model: {
571
- placeholder: 'Type here',
572
- type: 'freeText',
573
- value: 'My value'
574
- }
575
- });
576
- t.deepEqual(omit('answerUI', props.stack.slides['1']), {
577
- animateCorrectionPopin: false,
578
- showCorrectionPopin: false,
579
- hidden: false,
580
- position: 1,
581
- loading: false,
582
- parentContentTitle: 'From "Developing the review app" course',
583
- questionText: 'Quels sont les 4 piliers de l’apprentissage ?'
584
- });
585
- t.is(props.stack.validateButton.disabled, true);
586
- t.deepEqual(omit(['0', '1'], props.stack.slides), {
587
- '2': {
588
- hidden: false,
589
- position: 2,
590
- loading: true
591
- },
592
- '3': {
593
- hidden: false,
594
- position: 3,
595
- loading: true
596
- },
597
- '4': {
598
- hidden: false,
599
- position: 4,
600
- loading: true
601
- }
602
- });
603
- });
604
- test('should verify props when first slide was answered incorrectly, next slide is fetched & correction is fetched', t => {
605
- // Scenario: after POST_ANSWER_SUCCESS and SLIDE_FETCH_SUCCESS for the nextContent.ref slide
606
- const state = {
607
- data: {
608
- progression: incorrectFreeTextPostAnswerResponse,
609
- skills: [],
610
- slides: {
611
- sli_VJYjJnJhg: freeTextSlide,
612
- sli_VkSQroQnx: qcmGraphicSlide
613
- },
614
- token: '1234',
615
- corrections: {
616
- [freeTextSlide._id]: getChoicesCorrection(freeTextSlide._id, true)
617
- },
618
- rank: {}
619
- },
620
- ui: {
621
- currentSlideRef: 'sli_VJYjJnJhg',
622
- navigation: ['loader', 'slides'],
623
- answers: ['My value'],
624
- slide: {
625
- validateButton: false,
626
- animateCorrectionPopin: true,
627
- showCorrectionPopin: true
628
- }
629
- }
630
- };
631
- const props = mapStateToSlidesProps(state, identity);
632
- t.is(props.congratsProps, undefined);
633
- t.deepEqual(omit(['onQuitClick'], props.header), {
634
- 'aria-label': 'aria-header-wrapper',
635
- closeButtonAriaLabel: 'aria-close-button',
636
- mode: '__revision_mode',
637
- skillName: '__agility',
638
- steps: [
639
- {
640
- current: true,
641
- icon: 'wrong',
642
- value: '1'
643
- },
644
- {
645
- current: false,
646
- icon: 'no-answer',
647
- value: '2'
648
- },
649
- {
650
- current: false,
651
- icon: 'no-answer',
652
- value: '3'
653
- },
654
- {
655
- current: false,
656
- icon: 'no-answer',
657
- value: '4'
658
- },
659
- {
660
- current: false,
661
- icon: 'no-answer',
662
- value: '5'
663
- }
664
- ]
665
- });
666
- t.deepEqual(omit(['validateButton', 'slides', 'correctionPopinProps.klf.onClick'], props.stack), {
667
- correctionPopinProps: popinPropsWrongAnswer,
668
- endReview: false
669
- });
670
- t.deepEqual(omit('answerUI', props.stack.slides['0']), {
671
- animateCorrectionPopin: true,
672
- showCorrectionPopin: true,
673
- hidden: false,
674
- position: 0,
675
- loading: false,
676
- parentContentTitle: 'From "Developing the review app" course',
677
- questionText: 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
678
- });
679
- t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
680
- help: 'Type your answer.',
681
- model: {
682
- placeholder: 'Type here',
683
- type: 'freeText',
684
- value: 'My value'
685
- }
686
- });
687
- t.deepEqual(omit('answerUI', props.stack.slides['1']), {
688
- animateCorrectionPopin: false,
689
- showCorrectionPopin: false,
690
- hidden: false,
691
- position: 1,
692
- loading: false,
693
- parentContentTitle: 'From "Developing the review app" course',
694
- questionText: 'Quels sont les 4 piliers de l’apprentissage ?'
695
- });
696
- t.is(props.stack.validateButton.disabled, true);
697
- t.deepEqual(omit(['0', '1'], props.stack.slides), {
698
- '2': {
699
- hidden: false,
700
- position: 2,
701
- loading: true
702
- },
703
- '3': {
704
- hidden: false,
705
- position: 3,
706
- loading: true
707
- },
708
- '4': {
709
- hidden: false,
710
- position: 4,
711
- loading: true
712
- }
713
- });
714
- });
715
- test('should verify props when currentSlideRef has changed to nextContent of progression after first answered question', t => {
716
- // state after click on NEXT_SLIDE
717
- const state = {
718
- data: {
719
- progression: postAnswerResponses.sli_VJYjJnJhg,
720
- skills: [],
721
- slides: {
722
- sli_VJYjJnJhg: freeTextSlide,
723
- sli_VkSQroQnx: qcmGraphicSlide
724
- },
725
- token: '1234',
726
- corrections: {
727
- [freeTextSlide._id]: getChoicesCorrection(freeTextSlide._id)
728
- },
729
- rank: {}
730
- },
731
- ui: {
732
- currentSlideRef: 'sli_VkSQroQnx',
733
- navigation: ['loader', 'slides'],
734
- answers: [],
735
- slide: {
736
- validateButton: false
737
- }
738
- }
739
- };
740
- const props = mapStateToSlidesProps(state, identity);
741
- t.is(props.congratsProps, undefined);
742
- t.deepEqual(omit(['onQuitClick'], props.header), {
743
- 'aria-label': 'aria-header-wrapper',
744
- closeButtonAriaLabel: 'aria-close-button',
745
- mode: '__revision_mode',
746
- skillName: '__agility',
747
- steps: [
748
- {
749
- current: false,
750
- icon: 'right',
751
- value: '1'
752
- },
753
- {
754
- current: true,
755
- icon: 'no-answer',
756
- value: '2'
757
- },
758
- {
759
- current: false,
760
- icon: 'no-answer',
761
- value: '3'
762
- },
763
- {
764
- current: false,
765
- icon: 'no-answer',
766
- value: '4'
767
- },
768
- {
769
- current: false,
770
- icon: 'no-answer',
771
- value: '5'
772
- }
773
- ]
774
- });
775
- // TODO update test with props.stack validations when NEXT_SLIDE implemented
776
- });
777
- test('should verify props when progression is in success', t => {
778
- // state after receive last POST_ANSWER_SUCCESS and before last NEXT_SLIDE
779
- const state = {
780
- data: {
781
- progression: postAnswerResponses[templateSlide.universalRef],
782
- skills: [],
783
- slides: {
784
- [freeTextSlide.universalRef]: freeTextSlide,
785
- [qcmGraphicSlide.universalRef]: qcmGraphicSlide,
786
- [qcmSlide.universalRef]: qcmSlide,
787
- [sliderSlide.universalRef]: sliderSlide,
788
- [templateSlide.universalRef]: templateSlide
789
- },
790
- token: '1234',
791
- corrections: {
792
- [freeTextSlide._id]: getChoicesCorrection(freeTextSlide._id),
793
- [qcmGraphicSlide.universalRef]: getChoicesCorrection(qcmGraphicSlide._id),
794
- [qcmSlide.universalRef]: getChoicesCorrection(qcmSlide._id),
795
- [sliderSlide.universalRef]: getChoicesCorrection(sliderSlide._id),
796
- [templateSlide.universalRef]: getChoicesCorrection(templateSlide._id)
797
- },
798
- rank: {}
799
- },
800
- ui: {
801
- currentSlideRef: templateSlide.universalRef,
802
- navigation: ['loader', 'slides'],
803
- answers: [],
804
- slide: {
805
- validateButton: false
806
- }
807
- }
808
- };
809
- const props = mapStateToSlidesProps(state, identity);
810
- t.is(props.congratsProps, undefined);
811
- t.deepEqual(omit(['onQuitClick'], props.header), {
812
- 'aria-label': 'aria-header-wrapper',
813
- closeButtonAriaLabel: 'aria-close-button',
814
- mode: '__revision_mode',
815
- skillName: '__agility',
816
- steps: [
817
- {
818
- current: false,
819
- icon: 'right',
820
- value: '1'
821
- },
822
- {
823
- current: false,
824
- icon: 'right',
825
- value: '2'
826
- },
827
- {
828
- current: false,
829
- icon: 'right',
830
- value: '3'
831
- },
832
- {
833
- current: false,
834
- icon: 'right',
835
- value: '4'
836
- },
837
- {
838
- current: true,
839
- icon: 'right',
840
- value: '5'
841
- }
842
- ]
843
- });
844
- // TODO update test with props.stack validations when NEXT_SLIDE implemented
845
- });
846
- test('should verify props when progression has answered a current pendingSlide', t => {
847
- // Scenario, freeTextSlide and qcmSlide are pending slides, freeTextSlide was answered correctly, qcmSlide remains but not yet the currentSlideRef
848
- const state = {
849
- data: {
850
- progression: progressionSlideWithPendingSlide,
851
- skills: [],
852
- slides: {
853
- [freeTextSlide.universalRef]: freeTextSlide,
854
- [qcmGraphicSlide.universalRef]: qcmGraphicSlide,
855
- [qcmSlide.universalRef]: qcmSlide,
856
- [sliderSlide.universalRef]: sliderSlide,
857
- [templateSlide.universalRef]: templateSlide
858
- },
859
- token: '1234',
860
- corrections: {
861
- [freeTextSlide._id]: getChoicesCorrection(freeTextSlide._id),
862
- [qcmGraphicSlide.universalRef]: getChoicesCorrection(qcmGraphicSlide._id),
863
- [qcmSlide.universalRef]: getChoicesCorrection(qcmSlide._id, true),
864
- [sliderSlide.universalRef]: getChoicesCorrection(sliderSlide._id),
865
- [templateSlide.universalRef]: getChoicesCorrection(templateSlide._id)
866
- },
867
- rank: {}
868
- },
869
- ui: {
870
- currentSlideRef: freeTextSlide.universalRef,
871
- navigation: ['loader', 'slides'],
872
- answers: [],
873
- slide: {
874
- validateButton: false
875
- }
876
- }
877
- };
878
- const props = mapStateToSlidesProps(state, identity);
879
- t.deepEqual(omit(['onQuitClick'], props.header), {
880
- 'aria-label': 'aria-header-wrapper',
881
- closeButtonAriaLabel: 'aria-close-button',
882
- mode: '__revision_mode',
883
- skillName: '__agility',
884
- steps: [
885
- {
886
- current: true,
887
- icon: 'right',
888
- value: '1'
889
- },
890
- {
891
- current: false,
892
- icon: 'right',
893
- value: '2'
894
- },
895
- {
896
- current: false,
897
- icon: 'wrong',
898
- value: '3'
899
- },
900
- {
901
- current: false,
902
- icon: 'right',
903
- value: '4'
904
- },
905
- {
906
- current: false,
907
- icon: 'right',
908
- value: '5'
909
- }
910
- ]
911
- });
912
- });
913
- test('should verify props when progression still has a pendingSlide', t => {
914
- // Scenario, freeTextSlide and qcmSlide are pending slides, freeTextSlide was answered correctly, qcmSlide remains and it is the currentSlideRef
915
- const state = {
916
- data: {
917
- progression: progressionSlideWithPendingSlide,
918
- skills: [],
919
- slides: {
920
- [freeTextSlide.universalRef]: freeTextSlide,
921
- [qcmGraphicSlide.universalRef]: qcmGraphicSlide,
922
- [qcmSlide.universalRef]: qcmSlide,
923
- [sliderSlide.universalRef]: sliderSlide,
924
- [templateSlide.universalRef]: templateSlide
925
- },
926
- token: '1234',
927
- corrections: {
928
- [freeTextSlide._id]: getChoicesCorrection(freeTextSlide._id),
929
- [qcmGraphicSlide.universalRef]: getChoicesCorrection(qcmGraphicSlide._id),
930
- [qcmSlide.universalRef]: getChoicesCorrection(qcmSlide._id, true),
931
- [sliderSlide.universalRef]: getChoicesCorrection(sliderSlide._id),
932
- [templateSlide.universalRef]: getChoicesCorrection(templateSlide._id)
933
- },
934
- rank: {}
935
- },
936
- ui: {
937
- currentSlideRef: qcmSlide.universalRef,
938
- navigation: ['loader', 'slides'],
939
- answers: [],
940
- slide: {
941
- validateButton: false
942
- }
943
- }
944
- };
945
- const props = mapStateToSlidesProps(state, identity);
946
- t.deepEqual(omit(['onQuitClick'], props.header), {
947
- 'aria-label': 'aria-header-wrapper',
948
- closeButtonAriaLabel: 'aria-close-button',
949
- mode: '__revision_mode',
950
- skillName: '__agility',
951
- steps: [
952
- {
953
- current: false,
954
- icon: 'right',
955
- value: '1'
956
- },
957
- {
958
- current: false,
959
- icon: 'right',
960
- value: '2'
961
- },
962
- {
963
- current: true,
964
- icon: 'no-answer',
965
- value: '3'
966
- },
967
- {
968
- current: false,
969
- icon: 'right',
970
- value: '4'
971
- },
972
- {
973
- current: false,
974
- icon: 'right',
975
- value: '5'
976
- }
977
- ]
978
- });
979
- });