@coorpacademy/app-review 0.1.15 → 0.1.17

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 (289) hide show
  1. package/es/actions/api/fetch-skills.d.ts +5 -7
  2. package/es/actions/api/fetch-skills.js +12 -4
  3. package/es/actions/api/fetch-slide.d.ts +14 -7
  4. package/es/actions/api/fetch-slide.js +23 -18
  5. package/es/actions/api/post-answer.d.ts +10 -0
  6. package/es/actions/api/post-answer.js +25 -0
  7. package/es/actions/api/post-progression.d.ts +5 -7
  8. package/es/actions/api/post-progression.js +16 -8
  9. package/es/actions/api/test/fetch-skills.test.js +57 -0
  10. package/es/actions/api/test/fetch-slide.test.js +64 -0
  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.d.ts +1 -0
  14. package/es/actions/api/test/post-progression.test.js +105 -0
  15. package/es/actions/data/test/token.test.d.ts +1 -0
  16. package/es/actions/data/test/token.test.js +25 -0
  17. package/es/actions/index.d.ts +1 -8
  18. package/es/actions/test/create-test-store.d.ts +5 -0
  19. package/es/actions/test/create-test-store.js +16 -0
  20. package/es/actions/ui/answers.d.ts +21 -0
  21. package/es/actions/ui/answers.js +43 -0
  22. package/es/actions/ui/slides.d.ts +0 -5
  23. package/es/actions/ui/slides.js +0 -4
  24. package/es/actions/ui/test/answers.test.d.ts +1 -0
  25. package/es/actions/ui/test/answers.test.js +90 -0
  26. package/es/actions/ui/test/slides.test.d.ts +1 -0
  27. package/es/actions/ui/test/slides.test.js +26 -0
  28. package/es/common/index.d.ts +0 -3
  29. package/es/common/index.js +0 -4
  30. package/es/index.js +11 -19
  31. package/es/reducers/data/index.d.ts +2 -2
  32. package/es/reducers/data/progression.d.ts +2 -3
  33. package/es/reducers/data/progression.js +0 -5
  34. package/es/reducers/data/slides.d.ts +3 -4
  35. package/es/reducers/data/slides.js +5 -1
  36. package/es/reducers/data/test/progression.test.d.ts +1 -0
  37. package/es/reducers/data/test/progression.test.js +38 -0
  38. package/es/reducers/data/test/skills.test.d.ts +1 -0
  39. package/es/reducers/data/test/skills.test.js +12 -0
  40. package/es/reducers/data/test/slides.test.d.ts +1 -0
  41. package/es/reducers/data/test/slides.test.js +20 -0
  42. package/es/reducers/data/test/token.test.d.ts +1 -0
  43. package/es/reducers/data/test/token.test.js +11 -0
  44. package/es/reducers/index.d.ts +3 -2
  45. package/es/reducers/ui/answers.d.ts +4 -0
  46. package/es/reducers/ui/answers.js +9 -0
  47. package/es/reducers/ui/index.d.ts +7 -4
  48. package/es/reducers/ui/index.js +4 -2
  49. package/es/reducers/ui/slide.d.ts +8 -0
  50. package/es/reducers/ui/slide.js +26 -0
  51. package/es/reducers/ui/test/answers.test.d.ts +1 -0
  52. package/es/reducers/ui/test/answers.test.js +27 -0
  53. package/es/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
  54. package/es/reducers/ui/test/current-slide-ref.test.js +12 -0
  55. package/es/reducers/ui/test/navigation.test.d.ts +1 -0
  56. package/es/reducers/ui/test/navigation.test.js +15 -0
  57. package/es/reducers/ui/test/slide.test.d.ts +1 -0
  58. package/es/reducers/ui/test/slide.test.js +12 -0
  59. package/es/services/fetch-slide.js +1 -1
  60. package/es/services/index.js +3 -1
  61. package/es/services/post-answer.d.ts +2 -0
  62. package/es/services/post-answer.js +18 -0
  63. package/es/services/test/fetch-slide.test.d.ts +1 -0
  64. package/es/services/test/fetch-slide.test.js +22 -0
  65. package/es/services/test/post-answer.test.d.ts +1 -0
  66. package/es/services/test/post-answer.test.js +57 -0
  67. package/es/services/test/post-progression.test.js +9 -1
  68. package/es/test/util/services.mock.d.ts +2 -1
  69. package/es/test/util/services.mock.js +88 -44
  70. package/es/types/common.d.ts +22 -33
  71. package/es/views/skills/index.d.ts +1 -1
  72. package/es/views/skills/index.js +0 -3
  73. package/es/views/skills/test/skills.test.d.ts +1 -0
  74. package/es/views/skills/test/skills.test.js +94 -0
  75. package/es/views/slides/index.d.ts +89 -2
  76. package/es/views/slides/index.js +80 -10
  77. package/es/views/slides/map-api-slide-to-ui.d.ts +8 -0
  78. package/es/views/slides/map-api-slide-to-ui.js +165 -0
  79. package/es/{helpers → views/slides}/test/fixtures/free-text.d.ts +2 -1
  80. package/es/views/slides/test/fixtures/free-text.js +38 -0
  81. package/es/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +2 -1
  82. package/es/views/slides/test/fixtures/qcm-drag.js +108 -0
  83. package/es/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +2 -1
  84. package/es/views/slides/test/fixtures/qcm-graphic.js +88 -0
  85. package/es/{helpers → views/slides}/test/fixtures/qcm.d.ts +2 -1
  86. package/es/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
  87. package/es/{helpers → views/slides}/test/fixtures/select-template.d.ts +2 -1
  88. package/es/views/slides/test/fixtures/select-template.js +92 -0
  89. package/es/{helpers → views/slides}/test/fixtures/slider.d.ts +2 -1
  90. package/es/views/slides/test/fixtures/slider.js +36 -0
  91. package/es/{helpers → views/slides}/test/fixtures/text-template.d.ts +2 -1
  92. package/es/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
  93. package/es/views/slides/test/index.test.d.ts +1 -0
  94. package/es/views/slides/test/index.test.js +234 -0
  95. package/es/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
  96. package/es/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
  97. package/lib/actions/api/fetch-skills.d.ts +5 -7
  98. package/lib/actions/api/fetch-skills.js +58 -7
  99. package/lib/actions/api/fetch-slide.d.ts +14 -7
  100. package/lib/actions/api/fetch-slide.js +72 -20
  101. package/lib/actions/api/post-answer.d.ts +10 -0
  102. package/lib/actions/api/post-answer.js +75 -0
  103. package/lib/actions/api/post-progression.d.ts +5 -7
  104. package/lib/actions/api/post-progression.js +67 -10
  105. package/lib/actions/api/test/fetch-skills.test.d.ts +1 -0
  106. package/lib/actions/api/test/fetch-skills.test.js +116 -0
  107. package/lib/actions/api/test/fetch-slide.test.d.ts +1 -0
  108. package/lib/actions/api/test/fetch-slide.test.js +123 -0
  109. package/lib/actions/api/test/post-answer.test.d.ts +1 -0
  110. package/lib/actions/api/test/post-answer.test.js +145 -0
  111. package/lib/actions/api/test/post-progression.test.d.ts +1 -0
  112. package/lib/actions/api/test/post-progression.test.js +163 -0
  113. package/lib/actions/data/test/token.test.d.ts +1 -0
  114. package/lib/actions/data/test/token.test.js +70 -0
  115. package/lib/actions/index.d.ts +1 -8
  116. package/lib/actions/test/create-test-store.d.ts +5 -0
  117. package/lib/actions/test/create-test-store.js +18 -0
  118. package/lib/actions/ui/answers.d.ts +21 -0
  119. package/lib/actions/ui/answers.js +54 -0
  120. package/lib/actions/ui/slides.d.ts +0 -5
  121. package/lib/actions/ui/slides.js +0 -4
  122. package/lib/actions/ui/test/answers.test.d.ts +1 -0
  123. package/lib/actions/ui/test/answers.test.js +171 -0
  124. package/lib/actions/ui/test/slides.test.d.ts +1 -0
  125. package/lib/actions/ui/test/slides.test.js +71 -0
  126. package/lib/common/index.d.ts +0 -3
  127. package/lib/common/index.js +0 -4
  128. package/lib/index.js +22 -21
  129. package/lib/reducers/data/index.d.ts +2 -2
  130. package/lib/reducers/data/progression.d.ts +2 -3
  131. package/lib/reducers/data/progression.js +0 -5
  132. package/lib/reducers/data/slides.d.ts +3 -4
  133. package/lib/reducers/data/slides.js +5 -1
  134. package/lib/reducers/data/test/progression.test.d.ts +1 -0
  135. package/lib/reducers/data/test/progression.test.js +38 -0
  136. package/lib/reducers/data/test/skills.test.d.ts +1 -0
  137. package/lib/reducers/data/test/skills.test.js +12 -0
  138. package/lib/reducers/data/test/slides.test.d.ts +1 -0
  139. package/lib/reducers/data/test/slides.test.js +20 -0
  140. package/lib/reducers/data/test/token.test.d.ts +1 -0
  141. package/lib/reducers/data/test/token.test.js +11 -0
  142. package/lib/reducers/index.d.ts +3 -2
  143. package/lib/reducers/ui/answers.d.ts +4 -0
  144. package/lib/reducers/ui/answers.js +10 -0
  145. package/lib/reducers/ui/index.d.ts +7 -4
  146. package/lib/reducers/ui/index.js +4 -2
  147. package/lib/reducers/ui/slide.d.ts +8 -0
  148. package/lib/reducers/ui/slide.js +27 -0
  149. package/lib/reducers/ui/test/answers.test.d.ts +1 -0
  150. package/lib/reducers/ui/test/answers.test.js +27 -0
  151. package/lib/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
  152. package/lib/reducers/ui/test/current-slide-ref.test.js +12 -0
  153. package/lib/reducers/ui/test/navigation.test.d.ts +1 -0
  154. package/lib/reducers/ui/test/navigation.test.js +15 -0
  155. package/lib/reducers/ui/test/slide.test.d.ts +1 -0
  156. package/lib/reducers/ui/test/slide.test.js +12 -0
  157. package/lib/services/fetch-slide.js +1 -1
  158. package/lib/services/index.js +3 -1
  159. package/lib/services/post-answer.d.ts +2 -0
  160. package/lib/services/post-answer.js +62 -0
  161. package/lib/services/test/fetch-slide.test.d.ts +1 -0
  162. package/lib/services/test/fetch-slide.test.js +76 -0
  163. package/lib/services/test/post-answer.test.d.ts +1 -0
  164. package/lib/services/test/post-answer.test.js +111 -0
  165. package/lib/services/test/post-progression.test.js +9 -1
  166. package/lib/test/util/services.mock.d.ts +2 -1
  167. package/lib/test/util/services.mock.js +88 -44
  168. package/lib/types/common.d.ts +22 -33
  169. package/lib/views/skills/index.d.ts +1 -1
  170. package/lib/views/skills/index.js +0 -3
  171. package/lib/views/skills/test/skills.test.d.ts +1 -0
  172. package/lib/views/skills/test/skills.test.js +94 -0
  173. package/lib/views/slides/index.d.ts +89 -2
  174. package/lib/views/slides/index.js +80 -10
  175. package/lib/views/slides/map-api-slide-to-ui.d.ts +8 -0
  176. package/lib/views/slides/map-api-slide-to-ui.js +179 -0
  177. package/lib/{helpers → views/slides}/test/fixtures/free-text.d.ts +2 -1
  178. package/lib/views/slides/test/fixtures/free-text.js +38 -0
  179. package/lib/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +2 -1
  180. package/lib/views/slides/test/fixtures/qcm-drag.js +108 -0
  181. package/lib/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +2 -1
  182. package/lib/views/slides/test/fixtures/qcm-graphic.js +88 -0
  183. package/lib/{helpers → views/slides}/test/fixtures/qcm.d.ts +2 -1
  184. package/lib/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
  185. package/lib/{helpers → views/slides}/test/fixtures/select-template.d.ts +2 -1
  186. package/lib/views/slides/test/fixtures/select-template.js +92 -0
  187. package/lib/{helpers → views/slides}/test/fixtures/slider.d.ts +2 -1
  188. package/lib/views/slides/test/fixtures/slider.js +36 -0
  189. package/lib/{helpers → views/slides}/test/fixtures/text-template.d.ts +2 -1
  190. package/lib/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
  191. package/lib/views/slides/test/index.test.d.ts +1 -0
  192. package/lib/views/slides/test/index.test.js +234 -0
  193. package/lib/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
  194. package/lib/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
  195. package/package.json +6 -5
  196. package/src/actions/api/fetch-skills.ts +19 -12
  197. package/src/actions/api/fetch-slide.ts +35 -29
  198. package/src/actions/api/post-answer.ts +39 -0
  199. package/src/actions/api/post-progression.ts +22 -22
  200. package/src/actions/api/test/fetch-skills.test.ts +73 -0
  201. package/src/actions/api/test/fetch-slide.test.ts +80 -0
  202. package/src/actions/api/test/post-answer.test.ts +101 -0
  203. package/src/actions/api/test/post-progression.test.ts +122 -0
  204. package/src/actions/data/test/token.test.ts +29 -0
  205. package/src/actions/index.ts +1 -17
  206. package/src/actions/test/create-test-store.ts +25 -0
  207. package/src/actions/ui/answers.ts +63 -0
  208. package/src/actions/ui/slides.ts +1 -8
  209. package/src/actions/ui/test/answers.test.ts +103 -0
  210. package/src/actions/ui/test/slides.test.ts +30 -0
  211. package/src/common/index.ts +0 -7
  212. package/src/index.tsx +15 -32
  213. package/src/reducers/data/index.ts +1 -1
  214. package/src/reducers/data/progression.ts +2 -7
  215. package/src/reducers/data/slides.ts +12 -4
  216. package/src/reducers/data/test/progression.test.ts +42 -0
  217. package/src/reducers/data/test/skills.test.ts +14 -0
  218. package/src/reducers/data/test/slides.test.ts +26 -0
  219. package/src/reducers/data/test/token.test.ts +13 -0
  220. package/src/reducers/ui/answers.ts +15 -0
  221. package/src/reducers/ui/index.ts +6 -3
  222. package/src/reducers/ui/slide.ts +43 -0
  223. package/src/reducers/ui/test/answers.test.ts +33 -0
  224. package/src/reducers/ui/test/current-slide-ref.test.ts +14 -0
  225. package/src/reducers/ui/test/navigation.test.ts +19 -0
  226. package/src/reducers/ui/test/slide.test.ts +15 -0
  227. package/src/services/fetch-slide.ts +1 -1
  228. package/src/services/index.ts +3 -1
  229. package/src/services/post-answer.ts +27 -0
  230. package/src/services/test/fetch-slide.test.ts +30 -0
  231. package/src/services/test/post-answer.test.ts +68 -0
  232. package/src/services/test/post-progression.test.ts +9 -1
  233. package/src/test/util/services.mock.ts +93 -45
  234. package/src/types/common.ts +34 -44
  235. package/src/views/skills/index.ts +1 -5
  236. package/src/views/skills/test/skills.test.ts +101 -0
  237. package/src/views/slides/index.ts +186 -12
  238. package/src/views/slides/map-api-slide-to-ui.ts +251 -0
  239. package/src/views/slides/test/fixtures/free-text.ts +44 -0
  240. package/src/views/slides/test/fixtures/qcm-drag.ts +112 -0
  241. package/src/views/slides/test/fixtures/qcm-graphic.ts +95 -0
  242. package/src/{helpers → views/slides}/test/fixtures/qcm.ts +7 -2
  243. package/src/views/slides/test/fixtures/select-template.ts +99 -0
  244. package/src/views/slides/test/fixtures/slider.ts +42 -0
  245. package/src/{helpers → views/slides}/test/fixtures/text-template.ts +7 -2
  246. package/src/views/slides/test/index.test.ts +240 -0
  247. package/src/{helpers → views/slides}/test/map-api-slide-to-ui.test.ts +22 -10
  248. package/es/fixtures/qcm-slide.d.ts +0 -2
  249. package/es/fixtures/qcm-slide.js +0 -33
  250. package/es/fixtures/temp-fixture.d.ts +0 -3
  251. package/es/fixtures/temp-fixture.js +0 -84
  252. package/es/helpers/map-api-slide-to-ui.d.ts +0 -11
  253. package/es/helpers/map-api-slide-to-ui.js +0 -193
  254. package/es/helpers/test/fixtures/free-text.js +0 -30
  255. package/es/helpers/test/fixtures/qcm-drag.js +0 -112
  256. package/es/helpers/test/fixtures/qcm-graphic.js +0 -76
  257. package/es/helpers/test/fixtures/select-template.js +0 -94
  258. package/es/helpers/test/fixtures/slider.js +0 -33
  259. package/es/reducers/ui/slides.d.ts +0 -9
  260. package/es/reducers/ui/slides.js +0 -42
  261. package/es/types/views/slides.d.ts +0 -74
  262. package/es/types/views/slides.js +0 -6
  263. package/lib/fixtures/qcm-slide.d.ts +0 -2
  264. package/lib/fixtures/qcm-slide.js +0 -33
  265. package/lib/fixtures/temp-fixture.d.ts +0 -3
  266. package/lib/fixtures/temp-fixture.js +0 -84
  267. package/lib/helpers/map-api-slide-to-ui.d.ts +0 -11
  268. package/lib/helpers/map-api-slide-to-ui.js +0 -201
  269. package/lib/helpers/test/fixtures/free-text.js +0 -30
  270. package/lib/helpers/test/fixtures/qcm-drag.js +0 -112
  271. package/lib/helpers/test/fixtures/qcm-graphic.js +0 -76
  272. package/lib/helpers/test/fixtures/select-template.js +0 -94
  273. package/lib/helpers/test/fixtures/slider.js +0 -33
  274. package/lib/reducers/ui/slides.d.ts +0 -9
  275. package/lib/reducers/ui/slides.js +0 -43
  276. package/lib/types/views/slides.d.ts +0 -74
  277. package/lib/types/views/slides.js +0 -6
  278. package/src/fixtures/qcm-slide.ts +0 -35
  279. package/src/fixtures/temp-fixture.ts +0 -94
  280. package/src/helpers/map-api-slide-to-ui.ts +0 -279
  281. package/src/helpers/test/fixtures/free-text.ts +0 -33
  282. package/src/helpers/test/fixtures/qcm-drag.ts +0 -115
  283. package/src/helpers/test/fixtures/qcm-graphic.ts +0 -79
  284. package/src/helpers/test/fixtures/select-template.ts +0 -97
  285. package/src/helpers/test/fixtures/slider.ts +0 -36
  286. package/src/reducers/ui/slides.ts +0 -58
  287. package/src/types/views/slides.ts +0 -90
  288. /package/es/{helpers/test/map-api-slide-to-ui.test.d.ts → actions/api/test/fetch-skills.test.d.ts} +0 -0
  289. /package/{lib/helpers/test/map-api-slide-to-ui.test.d.ts → es/actions/api/test/fetch-slide.test.d.ts} +0 -0
@@ -0,0 +1,240 @@
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
+ });
@@ -1,6 +1,8 @@
1
1
  import test from 'ava';
2
- import {SlideFromAPI, UISlide} from '../../types/common';
2
+ import identity from 'lodash/fp/identity';
3
+ import {SlideFromAPI} from '../../../types/common';
3
4
  import {mapApiSlideToUi} from '../map-api-slide-to-ui';
5
+ import {UISlide} from '..';
4
6
  import {qcmUISlide, qcmSlide} from './fixtures/qcm';
5
7
  import {qcmDragUISlide, qcmDragSlide} from './fixtures/qcm-drag';
6
8
  import {freeTextSlide, freeTextUISlide} from './fixtures/free-text';
@@ -9,7 +11,7 @@ import {textTemplateSlide, textTemplateUISlide} from './fixtures/text-template';
9
11
  import {selectTemplateSlide, selectTemplateUISlide} from './fixtures/select-template';
10
12
  import {sliderSlide, sliderUISlide} from './fixtures/slider';
11
13
 
12
- const _mapApiSlideToUi = mapApiSlideToUi({translate: (text: string) => text});
14
+ const _mapApiSlideToUi = mapApiSlideToUi(identity);
13
15
 
14
16
  const macro = test.macro({
15
17
  title(providedTitle) {
@@ -19,28 +21,38 @@ const macro = test.macro({
19
21
  t,
20
22
  arg: {
21
23
  slide: SlideFromAPI;
24
+ answers: string[];
22
25
  expectedUiSlide: Partial<UISlide>;
23
26
  }
24
27
  ) {
25
28
  t.deepEqual(
26
- JSON.parse(JSON.stringify(_mapApiSlideToUi(arg.slide))),
29
+ JSON.parse(JSON.stringify(_mapApiSlideToUi(arg.slide, arg.answers))),
27
30
  JSON.parse(JSON.stringify(arg.expectedUiSlide))
28
31
  );
29
32
  }
30
33
  });
31
34
 
32
- test('qcm', macro, {slide: qcmSlide, expectedUiSlide: qcmUISlide});
33
- test('qcm drag', macro, {slide: qcmDragSlide, expectedUiSlide: qcmDragUISlide});
34
- test('qcm graphic', macro, {slide: qcmGraphicSlide, expectedUiSlide: qcmGraphicUISlide});
35
- test('text template', macro, {slide: textTemplateSlide, expectedUiSlide: textTemplateUISlide});
35
+ test('qcm', macro, {slide: qcmSlide, answers: [], expectedUiSlide: qcmUISlide});
36
+ test('qcm drag', macro, {slide: qcmDragSlide, answers: [], expectedUiSlide: qcmDragUISlide});
37
+ test('qcm graphic', macro, {
38
+ slide: qcmGraphicSlide,
39
+ answers: [],
40
+ expectedUiSlide: qcmGraphicUISlide
41
+ });
42
+ test('text template', macro, {
43
+ slide: textTemplateSlide,
44
+ answers: [],
45
+ expectedUiSlide: textTemplateUISlide
46
+ });
36
47
  test('select template', macro, {
37
48
  slide: selectTemplateSlide,
49
+ answers: [],
38
50
  expectedUiSlide: selectTemplateUISlide
39
51
  });
40
- test('free text', macro, {slide: freeTextSlide, expectedUiSlide: freeTextUISlide});
41
- test('slider', macro, {slide: sliderSlide, expectedUiSlide: sliderUISlide});
52
+ test('free text', macro, {slide: freeTextSlide, answers: [], expectedUiSlide: freeTextUISlide});
53
+ test('slider', macro, {slide: sliderSlide, answers: [], expectedUiSlide: sliderUISlide});
42
54
 
43
55
  test('should throw an error if the question type can not be handled', t => {
44
56
  const faultySlide = {...qcmSlide, question: {type: 'lol'}};
45
- t.throws(() => _mapApiSlideToUi(faultySlide as SlideFromAPI));
57
+ t.throws(() => _mapApiSlideToUi(faultySlide as SlideFromAPI, []));
46
58
  });
@@ -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 '../types/views/slides';
2
- export declare const correctionPopinProps: CorrectionPopinProps;
3
- export declare const congratsProps: SlidesViewProps['congratsProps'];
@@ -1,84 +0,0 @@
1
- export const correctionPopinProps = {
2
- klf: {
3
- label: 'Key learning factor',
4
- tooltip: 'Some tooltip info.',
5
- onClick: () => {
6
- console.log('klf onClick');
7
- }
8
- },
9
- information: {
10
- label: 'Key learning factor',
11
- message: 'info msg'
12
- },
13
- next: {
14
- label: 'Next',
15
- ariaLabel: 'Next'
16
- },
17
- successLabel: 'CORRECT ANSWER',
18
- failureLabel: 'WRONG ANSWER'
19
- };
20
- const confettiAnimationProps = {
21
- 'aria-label': 'aria lottie',
22
- 'data-name': 'default-lottie',
23
- className: undefined,
24
- animationSrc: 'https://static-staging.coorpacademy.com/animations/review/confetti.json',
25
- loop: undefined,
26
- autoplay: true,
27
- rendererSettings: {
28
- hideOnTransparent: false,
29
- animationClassName: ''
30
- },
31
- ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/conffeti_congrats.svg',
32
- animationControl: undefined
33
- };
34
- const starAnimationProps = {
35
- 'aria-label': 'Review Card Congrats Container',
36
- 'data-name': 'card-star',
37
- animationLottie: {
38
- 'aria-label': 'aria lottie',
39
- 'data-name': 'default-lottie',
40
- animationSrc: 'https://static-staging.coorpacademy.com/animations/review/star.json',
41
- ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg'
42
- },
43
- iconAriaLabel: 'Image without information',
44
- cardType: 'card-star',
45
- reviewCardTitle: 'You have won',
46
- reviewCardValue: '100',
47
- timerAnimation: 200
48
- };
49
- const rankAnimationProps = {
50
- 'aria-label': 'Review Card Congrats Container',
51
- 'data-name': 'card-rank',
52
- animationLottie: {
53
- 'aria-label': 'aria lottie',
54
- 'data-name': 'default-lottie',
55
- animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',
56
- ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg'
57
- },
58
- cardType: 'card-rank',
59
- iconAriaLabel: 'Image without information',
60
- reviewCardTitle: 'You are now',
61
- reviewCardValue: '14',
62
- rankSuffix: 'th',
63
- timerAnimation: 200
64
- };
65
- export const congratsProps = {
66
- 'aria-label': 'Review Congratulations',
67
- 'data-name': 'review-congrats',
68
- animationLottie: confettiAnimationProps,
69
- title: 'Congratulations!',
70
- cardCongratsStar: starAnimationProps,
71
- cardCongratsRank: rankAnimationProps,
72
- buttonRevising: {
73
- 'aria-label': 'Continue revising button',
74
- label: 'Continue revising',
75
- onClick: () => console.log('Continue revising'),
76
- type: 'tertiary'
77
- },
78
- buttonRevisingSkill: {
79
- label: 'Revise another skill',
80
- 'aria-label': 'Revise another skill button',
81
- onClick: () => console.log('Revise another skill'),
82
- type: 'primary'
83
- }
84
- };
@@ -1,11 +0,0 @@
1
- import { AnswerUI } from '../types/slides';
2
- import { SlideFromAPI } from '../types/common';
3
- declare type UiUtils = {
4
- translate: (text: string) => string;
5
- };
6
- export declare const getQuestionType: (slide: SlideFromAPI) => SlideFromAPI['question']['type'];
7
- export declare const mapApiSlideToUi: (uiUtils: UiUtils) => (slide: SlideFromAPI) => {
8
- questionText: string;
9
- answerUI: AnswerUI;
10
- };
11
- export {};
@@ -1,193 +0,0 @@
1
- import { concat, divide, get, getOr, head, includes, indexOf, isEmpty, map, pipe, rangeStep, size, toInteger } from 'lodash/fp';
2
- const qcmProps = (question) => {
3
- // TODO: EDIT_CHOICES -> getAnswerValues
4
- const answers = [];
5
- return {
6
- type: 'qcm',
7
- answers: map(choice => ({
8
- title: choice.label,
9
- selected: includes(choice.label, answers),
10
- // TODO: EDIT_CHOICES
11
- // eslint-disable-next-line no-console
12
- onClick: () => console.log('TODO: on choice click'),
13
- ariaLabel: choice.label
14
- }),
15
- // TODO: EDIT_CHOICES -> getChoices
16
- question.content.choices)
17
- };
18
- };
19
- const qcmDragProps = (question) => {
20
- // TODO: EDIT_CHOICES -> getAnswerValues
21
- const answers = [];
22
- return {
23
- type: 'qcmDrag',
24
- answers: map(choice => {
25
- const indexInAnswer = indexOf(choice.label, answers);
26
- return {
27
- title: choice.label,
28
- selected: indexInAnswer !== -1,
29
- order: indexInAnswer,
30
- // TODO: EDIT_CHOICES
31
- // eslint-disable-next-line no-console
32
- onClick: () => console.log('TODO: on choice click')
33
- };
34
- // TODO: EDIT_CHOICES -> getChoices
35
- }, question.content.choices)
36
- };
37
- };
38
- const qcmGraphicProps = (question) => {
39
- // mock the answers
40
- // TODO: EDIT_CHOICES -> getAnswerValues
41
- const answers = [];
42
- return {
43
- type: 'qcmGraphic',
44
- answers: map(choice => ({
45
- title: choice.label,
46
- image: get('media.src.0.url', choice),
47
- selected: includes(choice.label, answers),
48
- // TODO: EDIT_CHOICES
49
- // eslint-disable-next-line no-console
50
- onClick: () => console.log('TODO: on choice click')
51
- }),
52
- // TODO: EDIT_CHOICES -> getChoices
53
- question.content.choices)
54
- };
55
- };
56
- const templateTextProps = (uiUtils) => (choice, index) => {
57
- const { translate } = uiUtils;
58
- // TODO: EDIT_CHOICES -> getAnswerValues
59
- const answers = [];
60
- return {
61
- type: 'text',
62
- name: getOr('', 'name', choice),
63
- placeholder: translate('Type here'),
64
- value: get(index, answers),
65
- // TODO: EDIT_CHOICES
66
- // eslint-disable-next-line no-console
67
- onChange: () => console.log('TODO: on choice change')
68
- };
69
- };
70
- // const getItemText = (item: ChoiceFromAPI['items'][0]): item['text'] is string =>
71
- const templateSelectProps = (uiUtils) => {
72
- return (choice, index) => {
73
- const { translate } = uiUtils;
74
- // TODO: EDIT_CHOICES -> getAnswerValues
75
- const answers = [];
76
- const answer = get(index, answers);
77
- const temporaryOption = {
78
- name: translate('Select an answer'),
79
- value: '',
80
- validOption: false,
81
- selected: true
82
- };
83
- const selectOptions = choice.items.map(item => {
84
- const itemText = getOr('', 'text', item);
85
- return {
86
- name: itemText,
87
- value: itemText,
88
- validOption: true,
89
- selected: itemText === answer
90
- };
91
- });
92
- return {
93
- type: 'select',
94
- name: getOr('', 'name', choice),
95
- // TODO: EDIT_CHOICES
96
- // eslint-disable-next-line no-console
97
- onChange: () => console.log('TODO: on choice change'),
98
- options: isEmpty(answer) ? concat([temporaryOption], selectOptions) : selectOptions
99
- };
100
- };
101
- };
102
- const templateProps = (uiUtils) => {
103
- const templateTextProps_ = templateTextProps(uiUtils);
104
- const templateSelectProps_ = templateSelectProps(uiUtils);
105
- return question => {
106
- // TODO: EDIT_CHOICES -> getChoices
107
- const choices = question.content.choices;
108
- return {
109
- type: 'template',
110
- template: get('content.template', question),
111
- answers: choices.map((choice, index) => choice.type === 'text'
112
- ? templateTextProps_(choice, index)
113
- : templateSelectProps_(choice, index))
114
- };
115
- };
116
- };
117
- const basicProps = (uiUtils) => {
118
- const { translate } = uiUtils;
119
- // TODO: EDIT_CHOICES -> getAnswerValues
120
- const answers = [];
121
- return () => {
122
- return {
123
- type: 'freeText',
124
- placeholder: translate('Type here'),
125
- value: head(answers),
126
- // TODO: EDIT_CHOICES
127
- // eslint-disable-next-line no-console
128
- onChange: () => console.log('TODO: on choice change')
129
- };
130
- };
131
- };
132
- const sliderProps = (question) => {
133
- const values = rangeStep(getOr(1, 'content.step', question), getOr(Number.NaN, 'content.min', question), getOr(Number.NaN, 'content.max', question) + 1
134
- // Lodash doesn't infer the type very well here
135
- );
136
- // TODO: EDIT_CHOICES -> getAnswerValues
137
- const answers = [];
138
- const stateValue = head(answers);
139
- const currentValue = toInteger(stateValue);
140
- const indexValue = indexOf(currentValue, values);
141
- const sliderPosition = divide(indexValue, size(values) - 1);
142
- const unitLabel = get('question.content.unitLabel', question);
143
- return {
144
- type: 'slider',
145
- placeholder: question.explanation,
146
- minLabel: `${question.content.min} ${unitLabel}`,
147
- maxLabel: `${question.content.max} ${unitLabel}`,
148
- title: `${currentValue} ${question.content.unitLabel}`,
149
- value: sliderPosition,
150
- // TODO: EDIT_CHOICES
151
- // eslint-disable-next-line no-console
152
- onChange: () => console.log('TODO: on choice change')
153
- };
154
- };
155
- export const getQuestionType = (slide) => slide.question.type;
156
- const getHelp = (uiUtils) => (slide) => {
157
- const { translate } = uiUtils;
158
- return get('question.explanation', slide) || translate('Select something below');
159
- };
160
- const getAnswerUIModel = (uiUtils) => {
161
- const basicProps_ = basicProps(uiUtils);
162
- const templateProps_ = templateProps(uiUtils);
163
- return slide => {
164
- const type = getQuestionType(slide);
165
- switch (type) {
166
- case 'qcm':
167
- return pipe(get('question'), qcmProps)(slide);
168
- case 'qcmGraphic':
169
- return pipe(get('question'), qcmGraphicProps)(slide);
170
- case 'qcmDrag':
171
- return pipe(get('question'), qcmDragProps)(slide);
172
- case 'basic':
173
- return basicProps_();
174
- case 'template':
175
- return pipe(get('question'), templateProps_)(slide);
176
- case 'slider':
177
- return pipe(get('question'), sliderProps)(slide);
178
- default:
179
- throw new Error(`${type} is not an handled question.type`);
180
- }
181
- };
182
- };
183
- export const mapApiSlideToUi = (uiUtils) => {
184
- const getAnswerUIModel_ = getAnswerUIModel(uiUtils);
185
- const getHelp_ = getHelp(uiUtils);
186
- return slide => {
187
- if (!slide) {
188
- throw new Error('no slide was found');
189
- }
190
- const questionText = pipe(getOr('', 'question.header'), uiUtils.translate)(slide);
191
- return { questionText, answerUI: { model: getAnswerUIModel_(slide), help: getHelp_(slide) } };
192
- };
193
- };
@@ -1,30 +0,0 @@
1
- import noop from 'lodash/fp/noop';
2
- export const freeTextSlide = {
3
- id: 'sli_E1Pcl-XAYbi',
4
- universalRef: 'sli_E1Pcl-XAYbi',
5
- question: {
6
- type: 'basic',
7
- header: 'sli_E1Pcl-XAYbi.header',
8
- explanation: 'sli_E1Pcl-XAYbi.explanation',
9
- content: {
10
- label: 'sli_E1Pcl-XAYbi.label',
11
- placeholder: 'sli_E1Pcl-XAYbi.placeholder',
12
- id: 'sli_E1Pcl-XAYbi.choice_1'
13
- }
14
- },
15
- clue: 'sli_E1Pcl-XAYbi.clue',
16
- klf: 'sli_E1Pcl-XAYbi.klf',
17
- tips: 'sli_E1Pcl-XAYbi.tips'
18
- };
19
- export const freeTextUISlide = {
20
- answerUI: {
21
- help: 'sli_E1Pcl-XAYbi.explanation',
22
- model: {
23
- type: 'freeText',
24
- placeholder: 'Type here',
25
- value: undefined,
26
- onChange: noop
27
- }
28
- },
29
- questionText: 'sli_E1Pcl-XAYbi.header'
30
- };