@coorpacademy/app-review 0.5.7-alpha.0 → 0.6.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 (280) hide show
  1. package/es/sandbox/index.d.ts +9 -0
  2. package/es/sandbox/index.js +41 -0
  3. package/es/{actions → src/actions}/api/fetch-correction.d.ts +2 -2
  4. package/{lib → es/src}/actions/api/fetch-rank.d.ts +3 -3
  5. package/{lib → es/src}/actions/api/fetch-skills.d.ts +2 -2
  6. package/{lib → es/src}/actions/api/fetch-slide.d.ts +2 -2
  7. package/{lib → es/src}/actions/api/post-answer.d.ts +2 -2
  8. package/es/{actions → src/actions}/api/post-progression.d.ts +2 -2
  9. package/es/{actions → src/actions}/test/create-test-store.d.ts +2 -2
  10. package/es/{actions → src/actions}/test/create-test-store.js +2 -2
  11. package/es/src/actions/ui/navigation.d.ts +19 -0
  12. package/es/src/actions/ui/navigation.js +26 -0
  13. package/{lib → es/src}/common/index.d.ts +0 -5
  14. package/es/{common → src/common}/index.js +0 -5
  15. package/es/{configure-store.js → src/configure-store.js} +5 -1
  16. package/es/{index.js → src/index.js} +3 -3
  17. package/{lib → es/src}/reducers/index.d.ts +1 -1
  18. package/es/{reducers → src/reducers}/ui/index.d.ts +1 -1
  19. package/{lib → es/src}/reducers/ui/navigation.d.ts +2 -2
  20. package/es/{reducers → src/reducers}/ui/navigation.js +1 -1
  21. package/{lib → es/src}/types/common.d.ts +7 -4
  22. package/{lib → es/src}/views/skills/index.d.ts +1 -3
  23. package/es/{views → src/views}/skills/index.js +0 -2
  24. package/es/src/views/slides/index.d.ts +34 -0
  25. package/es/{views → src/views}/slides/index.js +6 -4
  26. package/lib/sandbox/index.d.ts +9 -0
  27. package/lib/sandbox/index.js +43 -0
  28. package/lib/{actions → src/actions}/api/fetch-correction.d.ts +2 -2
  29. package/{es → lib/src}/actions/api/fetch-rank.d.ts +3 -3
  30. package/{es → lib/src}/actions/api/fetch-skills.d.ts +2 -2
  31. package/{es → lib/src}/actions/api/fetch-slide.d.ts +2 -2
  32. package/{es → lib/src}/actions/api/post-answer.d.ts +2 -2
  33. package/lib/{actions → src/actions}/api/post-progression.d.ts +2 -2
  34. package/lib/{actions → src/actions}/test/create-test-store.d.ts +2 -2
  35. package/lib/{actions → src/actions}/test/create-test-store.js +2 -2
  36. package/lib/src/actions/ui/navigation.d.ts +19 -0
  37. package/lib/src/actions/ui/navigation.js +86 -0
  38. package/{es → lib/src}/common/index.d.ts +0 -5
  39. package/lib/{common → src/common}/index.js +0 -5
  40. package/lib/{configure-store.js → src/configure-store.js} +5 -1
  41. package/lib/{index.js → src/index.js} +3 -3
  42. package/{es → lib/src}/reducers/index.d.ts +1 -1
  43. package/lib/{reducers → src/reducers}/ui/index.d.ts +1 -1
  44. package/{es → lib/src}/reducers/ui/navigation.d.ts +2 -2
  45. package/lib/{reducers → src/reducers}/ui/navigation.js +1 -1
  46. package/{es → lib/src}/types/common.d.ts +7 -4
  47. package/{es → lib/src}/views/skills/index.d.ts +1 -3
  48. package/lib/{views → src/views}/skills/index.js +0 -2
  49. package/lib/src/views/slides/index.d.ts +34 -0
  50. package/lib/{views → src/views}/slides/index.js +6 -4
  51. package/package.json +3 -3
  52. package/src/actions/api/fetch-correction.ts +2 -2
  53. package/src/actions/api/fetch-rank.ts +3 -3
  54. package/src/actions/api/fetch-skills.ts +2 -2
  55. package/src/actions/api/fetch-slide.ts +6 -2
  56. package/src/actions/api/post-answer.ts +2 -2
  57. package/src/actions/api/post-progression.ts +6 -2
  58. package/src/actions/api/test/fetch-correction.test.ts +2 -2
  59. package/src/actions/api/test/fetch-rank.test.ts +4 -4
  60. package/src/actions/api/test/fetch-skills.test.ts +2 -2
  61. package/src/actions/api/test/fetch-slide.test.ts +2 -2
  62. package/src/actions/api/test/post-answer.test.ts +11 -7
  63. package/src/actions/api/test/post-progression.test.ts +2 -2
  64. package/src/actions/data/test/token.test.ts +1 -1
  65. package/src/actions/test/create-test-store.ts +3 -3
  66. package/src/actions/ui/navigation.ts +49 -17
  67. package/src/actions/ui/test/answers.test.ts +8 -8
  68. package/src/actions/ui/test/navigation.test.ts +95 -0
  69. package/src/actions/ui/test/next-slide.test.ts +2 -2
  70. package/src/actions/ui/test/quit-popin.test.ts +2 -2
  71. package/src/actions/ui/test/slides.test.ts +1 -1
  72. package/src/common/index.ts +0 -10
  73. package/src/configure-store.ts +8 -2
  74. package/src/index.tsx +8 -6
  75. package/src/reducers/ui/navigation.ts +5 -5
  76. package/src/reducers/ui/test/navigation.test.ts +5 -5
  77. package/src/types/common.ts +9 -5
  78. package/src/views/skills/index.ts +1 -5
  79. package/src/views/skills/test/skills.test.ts +0 -4
  80. package/src/views/slides/index.ts +20 -132
  81. package/src/views/slides/test/header.on-click.test.ts +1 -1
  82. package/src/views/slides/test/index.test.ts +21 -6
  83. package/src/views/slides/test/on-quit-popin.on-click.test.ts +6 -5
  84. package/src/views/slides/test/slide.free-text.on-change.test.ts +3 -4
  85. package/src/views/slides/test/slide.next-slide.on-click.test.ts +7 -5
  86. package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +1 -1
  87. package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +1 -1
  88. package/src/views/slides/test/slide.qcm.on-click.test.ts +1 -1
  89. package/src/views/slides/test/slide.slider.on-change.test.ts +1 -1
  90. package/src/views/slides/test/slide.slider.on-slider-change.test.ts +1 -1
  91. package/src/views/slides/test/slide.template.on-change.test.ts +2 -2
  92. package/es/actions/index.d.ts +0 -5
  93. package/es/actions/index.js +0 -1
  94. package/es/actions/ui/navigation.d.ts +0 -18
  95. package/es/actions/ui/navigation.js +0 -10
  96. package/es/views/slides/index.d.ts +0 -142
  97. package/lib/actions/index.d.ts +0 -5
  98. package/lib/actions/index.js +0 -1
  99. package/lib/actions/ui/navigation.d.ts +0 -18
  100. package/lib/actions/ui/navigation.js +0 -10
  101. package/lib/views/slides/index.d.ts +0 -142
  102. package/src/actions/index.ts +0 -6
  103. /package/es/{actions → src/actions}/api/fetch-correction.js +0 -0
  104. /package/es/{actions → src/actions}/api/fetch-rank.js +0 -0
  105. /package/es/{actions → src/actions}/api/fetch-skills.js +0 -0
  106. /package/es/{actions → src/actions}/api/fetch-slide.js +0 -0
  107. /package/es/{actions → src/actions}/api/post-answer.js +0 -0
  108. /package/es/{actions → src/actions}/api/post-progression.js +0 -0
  109. /package/es/{actions → src/actions}/data/token.d.ts +0 -0
  110. /package/es/{actions → src/actions}/data/token.js +0 -0
  111. /package/es/{actions → src/actions}/ui/answers.d.ts +0 -0
  112. /package/es/{actions → src/actions}/ui/answers.js +0 -0
  113. /package/es/{actions → src/actions}/ui/next-slide.d.ts +0 -0
  114. /package/es/{actions → src/actions}/ui/next-slide.js +0 -0
  115. /package/es/{actions → src/actions}/ui/quit-popin.d.ts +0 -0
  116. /package/es/{actions → src/actions}/ui/quit-popin.js +0 -0
  117. /package/es/{actions → src/actions}/ui/slides.d.ts +0 -0
  118. /package/es/{actions → src/actions}/ui/slides.js +0 -0
  119. /package/es/{configure-store.d.ts → src/configure-store.d.ts} +0 -0
  120. /package/es/{helpers → src/helpers}/css-register.d.ts +0 -0
  121. /package/es/{helpers → src/helpers}/css-register.js +0 -0
  122. /package/es/{index.d.ts → src/index.d.ts} +0 -0
  123. /package/es/{reducers → src/reducers}/data/corrections.d.ts +0 -0
  124. /package/es/{reducers → src/reducers}/data/corrections.js +0 -0
  125. /package/es/{reducers → src/reducers}/data/index.d.ts +0 -0
  126. /package/es/{reducers → src/reducers}/data/index.js +0 -0
  127. /package/es/{reducers → src/reducers}/data/progression.d.ts +0 -0
  128. /package/es/{reducers → src/reducers}/data/progression.js +0 -0
  129. /package/es/{reducers → src/reducers}/data/rank.d.ts +0 -0
  130. /package/es/{reducers → src/reducers}/data/rank.js +0 -0
  131. /package/es/{reducers → src/reducers}/data/skills.d.ts +0 -0
  132. /package/es/{reducers → src/reducers}/data/skills.js +0 -0
  133. /package/es/{reducers → src/reducers}/data/slides.d.ts +0 -0
  134. /package/es/{reducers → src/reducers}/data/slides.js +0 -0
  135. /package/es/{reducers → src/reducers}/data/token.d.ts +0 -0
  136. /package/es/{reducers → src/reducers}/data/token.js +0 -0
  137. /package/es/{reducers → src/reducers}/index.js +0 -0
  138. /package/es/{reducers → src/reducers}/ui/answers.d.ts +0 -0
  139. /package/es/{reducers → src/reducers}/ui/answers.js +0 -0
  140. /package/es/{reducers → src/reducers}/ui/current-slide-ref.d.ts +0 -0
  141. /package/es/{reducers → src/reducers}/ui/current-slide-ref.js +0 -0
  142. /package/es/{reducers → src/reducers}/ui/index.js +0 -0
  143. /package/es/{reducers → src/reducers}/ui/positions.d.ts +0 -0
  144. /package/es/{reducers → src/reducers}/ui/positions.js +0 -0
  145. /package/es/{reducers → src/reducers}/ui/quit-popin.d.ts +0 -0
  146. /package/es/{reducers → src/reducers}/ui/quit-popin.js +0 -0
  147. /package/es/{reducers → src/reducers}/ui/show-congrats.d.ts +0 -0
  148. /package/es/{reducers → src/reducers}/ui/show-congrats.js +0 -0
  149. /package/es/{reducers → src/reducers}/ui/slide.d.ts +0 -0
  150. /package/es/{reducers → src/reducers}/ui/slide.js +0 -0
  151. /package/es/{services → src/services}/fetch-correction.d.ts +0 -0
  152. /package/es/{services → src/services}/fetch-correction.js +0 -0
  153. /package/es/{services → src/services}/fetch-rank.d.ts +0 -0
  154. /package/es/{services → src/services}/fetch-rank.js +0 -0
  155. /package/es/{services → src/services}/fetch-skills.d.ts +0 -0
  156. /package/es/{services → src/services}/fetch-skills.js +0 -0
  157. /package/es/{services → src/services}/fetch-slide.d.ts +0 -0
  158. /package/es/{services → src/services}/fetch-slide.js +0 -0
  159. /package/es/{services → src/services}/fetch-slides-to-review-by-skill-ref.d.ts +0 -0
  160. /package/es/{services → src/services}/fetch-slides-to-review-by-skill-ref.js +0 -0
  161. /package/es/{services → src/services}/index.d.ts +0 -0
  162. /package/es/{services → src/services}/index.js +0 -0
  163. /package/es/{services → src/services}/post-answer.d.ts +0 -0
  164. /package/es/{services → src/services}/post-answer.js +0 -0
  165. /package/es/{services → src/services}/post-progression.d.ts +0 -0
  166. /package/es/{services → src/services}/post-progression.js +0 -0
  167. /package/es/{services → src/services}/tools/fetch-responses.d.ts +0 -0
  168. /package/es/{services → src/services}/tools/fetch-responses.js +0 -0
  169. /package/es/{services → src/services}/tools/sleep.d.ts +0 -0
  170. /package/es/{services → src/services}/tools/sleep.js +0 -0
  171. /package/es/{test → src/test}/index.test.d.ts +0 -0
  172. /package/es/{test → src/test}/index.test.js +0 -0
  173. /package/es/{test → src/test}/util/services.mock.d.ts +0 -0
  174. /package/es/{test → src/test}/util/services.mock.js +0 -0
  175. /package/es/{types → src/types}/common.js +0 -0
  176. /package/es/{types → src/types}/slides.d.ts +0 -0
  177. /package/es/{types → src/types}/slides.js +0 -0
  178. /package/es/{views → src/views}/slides/map-api-slide-to-ui.d.ts +0 -0
  179. /package/es/{views → src/views}/slides/map-api-slide-to-ui.js +0 -0
  180. /package/es/{views → src/views}/slides/test/fixtures/free-text.d.ts +0 -0
  181. /package/es/{views → src/views}/slides/test/fixtures/free-text.js +0 -0
  182. /package/es/{views → src/views}/slides/test/fixtures/qcm-drag.d.ts +0 -0
  183. /package/es/{views → src/views}/slides/test/fixtures/qcm-drag.js +0 -0
  184. /package/es/{views → src/views}/slides/test/fixtures/qcm-graphic.d.ts +0 -0
  185. /package/es/{views → src/views}/slides/test/fixtures/qcm-graphic.js +0 -0
  186. /package/es/{views → src/views}/slides/test/fixtures/qcm.d.ts +0 -0
  187. /package/es/{views → src/views}/slides/test/fixtures/qcm.js +0 -0
  188. /package/es/{views → src/views}/slides/test/fixtures/slider.d.ts +0 -0
  189. /package/es/{views → src/views}/slides/test/fixtures/slider.js +0 -0
  190. /package/es/{views → src/views}/slides/test/fixtures/template.d.ts +0 -0
  191. /package/es/{views → src/views}/slides/test/fixtures/template.js +0 -0
  192. /package/lib/{actions → src/actions}/api/fetch-correction.js +0 -0
  193. /package/lib/{actions → src/actions}/api/fetch-rank.js +0 -0
  194. /package/lib/{actions → src/actions}/api/fetch-skills.js +0 -0
  195. /package/lib/{actions → src/actions}/api/fetch-slide.js +0 -0
  196. /package/lib/{actions → src/actions}/api/post-answer.js +0 -0
  197. /package/lib/{actions → src/actions}/api/post-progression.js +0 -0
  198. /package/lib/{actions → src/actions}/data/token.d.ts +0 -0
  199. /package/lib/{actions → src/actions}/data/token.js +0 -0
  200. /package/lib/{actions → src/actions}/ui/answers.d.ts +0 -0
  201. /package/lib/{actions → src/actions}/ui/answers.js +0 -0
  202. /package/lib/{actions → src/actions}/ui/next-slide.d.ts +0 -0
  203. /package/lib/{actions → src/actions}/ui/next-slide.js +0 -0
  204. /package/lib/{actions → src/actions}/ui/quit-popin.d.ts +0 -0
  205. /package/lib/{actions → src/actions}/ui/quit-popin.js +0 -0
  206. /package/lib/{actions → src/actions}/ui/slides.d.ts +0 -0
  207. /package/lib/{actions → src/actions}/ui/slides.js +0 -0
  208. /package/lib/{configure-store.d.ts → src/configure-store.d.ts} +0 -0
  209. /package/lib/{helpers → src/helpers}/css-register.d.ts +0 -0
  210. /package/lib/{helpers → src/helpers}/css-register.js +0 -0
  211. /package/lib/{index.d.ts → src/index.d.ts} +0 -0
  212. /package/lib/{reducers → src/reducers}/data/corrections.d.ts +0 -0
  213. /package/lib/{reducers → src/reducers}/data/corrections.js +0 -0
  214. /package/lib/{reducers → src/reducers}/data/index.d.ts +0 -0
  215. /package/lib/{reducers → src/reducers}/data/index.js +0 -0
  216. /package/lib/{reducers → src/reducers}/data/progression.d.ts +0 -0
  217. /package/lib/{reducers → src/reducers}/data/progression.js +0 -0
  218. /package/lib/{reducers → src/reducers}/data/rank.d.ts +0 -0
  219. /package/lib/{reducers → src/reducers}/data/rank.js +0 -0
  220. /package/lib/{reducers → src/reducers}/data/skills.d.ts +0 -0
  221. /package/lib/{reducers → src/reducers}/data/skills.js +0 -0
  222. /package/lib/{reducers → src/reducers}/data/slides.d.ts +0 -0
  223. /package/lib/{reducers → src/reducers}/data/slides.js +0 -0
  224. /package/lib/{reducers → src/reducers}/data/token.d.ts +0 -0
  225. /package/lib/{reducers → src/reducers}/data/token.js +0 -0
  226. /package/lib/{reducers → src/reducers}/index.js +0 -0
  227. /package/lib/{reducers → src/reducers}/ui/answers.d.ts +0 -0
  228. /package/lib/{reducers → src/reducers}/ui/answers.js +0 -0
  229. /package/lib/{reducers → src/reducers}/ui/current-slide-ref.d.ts +0 -0
  230. /package/lib/{reducers → src/reducers}/ui/current-slide-ref.js +0 -0
  231. /package/lib/{reducers → src/reducers}/ui/index.js +0 -0
  232. /package/lib/{reducers → src/reducers}/ui/positions.d.ts +0 -0
  233. /package/lib/{reducers → src/reducers}/ui/positions.js +0 -0
  234. /package/lib/{reducers → src/reducers}/ui/quit-popin.d.ts +0 -0
  235. /package/lib/{reducers → src/reducers}/ui/quit-popin.js +0 -0
  236. /package/lib/{reducers → src/reducers}/ui/show-congrats.d.ts +0 -0
  237. /package/lib/{reducers → src/reducers}/ui/show-congrats.js +0 -0
  238. /package/lib/{reducers → src/reducers}/ui/slide.d.ts +0 -0
  239. /package/lib/{reducers → src/reducers}/ui/slide.js +0 -0
  240. /package/lib/{services → src/services}/fetch-correction.d.ts +0 -0
  241. /package/lib/{services → src/services}/fetch-correction.js +0 -0
  242. /package/lib/{services → src/services}/fetch-rank.d.ts +0 -0
  243. /package/lib/{services → src/services}/fetch-rank.js +0 -0
  244. /package/lib/{services → src/services}/fetch-skills.d.ts +0 -0
  245. /package/lib/{services → src/services}/fetch-skills.js +0 -0
  246. /package/lib/{services → src/services}/fetch-slide.d.ts +0 -0
  247. /package/lib/{services → src/services}/fetch-slide.js +0 -0
  248. /package/lib/{services → src/services}/fetch-slides-to-review-by-skill-ref.d.ts +0 -0
  249. /package/lib/{services → src/services}/fetch-slides-to-review-by-skill-ref.js +0 -0
  250. /package/lib/{services → src/services}/index.d.ts +0 -0
  251. /package/lib/{services → src/services}/index.js +0 -0
  252. /package/lib/{services → src/services}/post-answer.d.ts +0 -0
  253. /package/lib/{services → src/services}/post-answer.js +0 -0
  254. /package/lib/{services → src/services}/post-progression.d.ts +0 -0
  255. /package/lib/{services → src/services}/post-progression.js +0 -0
  256. /package/lib/{services → src/services}/tools/fetch-responses.d.ts +0 -0
  257. /package/lib/{services → src/services}/tools/fetch-responses.js +0 -0
  258. /package/lib/{services → src/services}/tools/sleep.d.ts +0 -0
  259. /package/lib/{services → src/services}/tools/sleep.js +0 -0
  260. /package/lib/{test → src/test}/index.test.d.ts +0 -0
  261. /package/lib/{test → src/test}/index.test.js +0 -0
  262. /package/lib/{test → src/test}/util/services.mock.d.ts +0 -0
  263. /package/lib/{test → src/test}/util/services.mock.js +0 -0
  264. /package/lib/{types → src/types}/common.js +0 -0
  265. /package/lib/{types → src/types}/slides.d.ts +0 -0
  266. /package/lib/{types → src/types}/slides.js +0 -0
  267. /package/lib/{views → src/views}/slides/map-api-slide-to-ui.d.ts +0 -0
  268. /package/lib/{views → src/views}/slides/map-api-slide-to-ui.js +0 -0
  269. /package/lib/{views → src/views}/slides/test/fixtures/free-text.d.ts +0 -0
  270. /package/lib/{views → src/views}/slides/test/fixtures/free-text.js +0 -0
  271. /package/lib/{views → src/views}/slides/test/fixtures/qcm-drag.d.ts +0 -0
  272. /package/lib/{views → src/views}/slides/test/fixtures/qcm-drag.js +0 -0
  273. /package/lib/{views → src/views}/slides/test/fixtures/qcm-graphic.d.ts +0 -0
  274. /package/lib/{views → src/views}/slides/test/fixtures/qcm-graphic.js +0 -0
  275. /package/lib/{views → src/views}/slides/test/fixtures/qcm.d.ts +0 -0
  276. /package/lib/{views → src/views}/slides/test/fixtures/qcm.js +0 -0
  277. /package/lib/{views → src/views}/slides/test/fixtures/slider.d.ts +0 -0
  278. /package/lib/{views → src/views}/slides/test/fixtures/slider.js +0 -0
  279. /package/lib/{views → src/views}/slides/test/fixtures/template.d.ts +0 -0
  280. /package/lib/{views → src/views}/slides/test/fixtures/template.js +0 -0
@@ -96,7 +96,7 @@ test('should dispatch POST_PROGRESSION_SUCCESS and SLIDE_FETCH_REQUEST actions w
96
96
  {type: SET_CURRENT_SLIDE, payload: freeTextSlide}
97
97
  ];
98
98
 
99
- const {dispatch} = createTestStore(t, initialState, services, expectedActions);
99
+ const {dispatch} = createTestStore(t, initialState, {services}, expectedActions);
100
100
 
101
101
  await dispatch(postProgression('skill_12345'));
102
102
  });
@@ -121,7 +121,7 @@ test('should dispatch POST_PROGRESSION_FAILURE action when postProgression fails
121
121
  }
122
122
  ];
123
123
 
124
- const {dispatch} = createTestStore(t, initialState, services, expectedActions);
124
+ const {dispatch} = createTestStore(t, initialState, {services}, expectedActions);
125
125
 
126
126
  await dispatch(postProgression('skill_12345'));
127
127
  });
@@ -27,6 +27,6 @@ const initialState: StoreState = {
27
27
  test('should dispatch STORE_TOKEN action when storeToken is called', async t => {
28
28
  const expectedActions = [{type: STORE_TOKEN, payload: 'JWT.token'}];
29
29
 
30
- const {dispatch} = createTestStore(t, initialState, services, expectedActions);
30
+ const {dispatch} = createTestStore(t, initialState, {services}, expectedActions);
31
31
  await dispatch(storeToken('JWT.token'));
32
32
  });
@@ -2,8 +2,8 @@ import type {ExecutionContext} from 'ava';
2
2
  import constant from 'lodash/fp/constant';
3
3
  import {AnyAction, applyMiddleware, compose, createStore, Dispatch, Middleware, Store} from 'redux';
4
4
  import thunk from 'redux-thunk';
5
+ import {ThunkOptions} from '../../types/common';
5
6
  import rootReducer, {StoreState} from '../../reducers';
6
- import {Services} from '../../types/common';
7
7
 
8
8
  const assertActionsMiddleware = (t: ExecutionContext, ACTIONS: AnyAction[]): Middleware =>
9
9
  constant((next: Dispatch) => (action: AnyAction): unknown => {
@@ -16,10 +16,10 @@ const assertActionsMiddleware = (t: ExecutionContext, ACTIONS: AnyAction[]): Mid
16
16
  export const createTestStore = (
17
17
  t: ExecutionContext,
18
18
  initialState: StoreState,
19
- services: Services,
19
+ thunkOptions: ThunkOptions,
20
20
  actions: AnyAction[]
21
21
  ): Store<StoreState, AnyAction> => {
22
- const thunkMiddleware = thunk.withExtraArgument({services});
22
+ const thunkMiddleware = thunk.withExtraArgument(thunkOptions);
23
23
  const enhancer = compose(applyMiddleware(thunkMiddleware, assertActionsMiddleware(t, actions)));
24
24
  return createStore(rootReducer, initialState, enhancer);
25
25
  };
@@ -1,17 +1,13 @@
1
- import {AppOptions} from '../../types/common';
1
+ import {Dispatch} from 'redux';
2
+ import type {StoreState} from '../../reducers';
3
+ import {ThunkOptions, AppOptions, ViewName} from '../../types/common';
2
4
 
3
- export const NAVIGATE_TO = '@@navigation/NAVIGATE_TO';
4
- export const NAVIGATE_BACK = '@@navigation/NAVIGATE_BACK';
5
- export const START_APP = '@@navigation/START_APP';
6
-
7
- export type ViewPath = 'skills' | 'onboarding' | 'slides' | 'loader';
8
-
9
- export type NavigateTo = {
5
+ export type NavigateToAction = {
10
6
  type: '@@navigation/NAVIGATE_TO';
11
- payload: ViewPath;
7
+ payload: ViewName;
12
8
  };
13
9
 
14
- export type NavigateBack = {
10
+ export type NavigateBackAction = {
15
11
  type: '@@navigation/NAVIGATE_BACK';
16
12
  };
17
13
 
@@ -20,11 +16,47 @@ export type StartApp = {
20
16
  payload: AppOptions;
21
17
  };
22
18
 
23
- export const navigateTo = (newPath: ViewPath): NavigateTo => ({
24
- type: NAVIGATE_TO,
25
- payload: newPath
26
- });
19
+ export const NAVIGATE_TO = '@@navigation/NAVIGATE_TO';
20
+ export const NAVIGATE_BACK = '@@navigation/NAVIGATE_BACK';
21
+ export const START_APP = '@@navigation/START_APP';
22
+
23
+ export const navigateTo =
24
+ (newViewName: ViewName) =>
25
+ async (
26
+ dispatch: Dispatch,
27
+ getState: () => StoreState,
28
+ {callbackOnViewChanged}: ThunkOptions
29
+ ): Promise<NavigateToAction> => {
30
+ const action: NavigateToAction = {
31
+ type: NAVIGATE_TO,
32
+ payload: newViewName
33
+ };
34
+
35
+ const res = await dispatch(action);
36
+
37
+ if (callbackOnViewChanged) {
38
+ callbackOnViewChanged(newViewName);
39
+ }
40
+
41
+ return res;
42
+ };
27
43
 
28
- export const navigateBack = (): NavigateBack => ({
29
- type: NAVIGATE_BACK
30
- });
44
+ export const navigateBack = async (
45
+ dispatch: Dispatch,
46
+ getState: () => StoreState,
47
+ {callbackOnViewChanged}: ThunkOptions
48
+ ): Promise<NavigateBackAction> => {
49
+ const action: NavigateBackAction = {
50
+ type: NAVIGATE_BACK
51
+ };
52
+
53
+ const res = await dispatch(action);
54
+
55
+ if (callbackOnViewChanged) {
56
+ const storeState: StoreState = getState();
57
+ const viewName = storeState.ui.navigation[storeState.ui.navigation.length - 1];
58
+ callbackOnViewChanged(viewName);
59
+ }
60
+
61
+ return res;
62
+ };
@@ -73,7 +73,7 @@ test('editAnswer should throw an Error if the slide is not found', async t => {
73
73
  const {dispatch} = createTestStore(
74
74
  t,
75
75
  omit(['data', 'slides'], state) as StoreState,
76
- services,
76
+ {services},
77
77
  expectedActions
78
78
  );
79
79
  await t.throws(
@@ -88,7 +88,7 @@ test('editAnswer should throw an Error for unsupported questions', async t => {
88
88
  ...freeTextSlide,
89
89
  question: {...freeTextSlide.question, type: 'unsupportedType'} as unknown as Question
90
90
  });
91
- const {dispatch} = createTestStore(t, state, services, []);
91
+ const {dispatch} = createTestStore(t, state, {services}, []);
92
92
  await t.throws(
93
93
  () => dispatch(editAnswer(['Some kind of answer'])),
94
94
  undefined,
@@ -101,7 +101,7 @@ test('should dispatch EDIT_BASIC action when editAnswer is called', async t => {
101
101
  const expectedActions = [
102
102
  {type: ANSWER_EDIT.basic, meta: {slideRef: freeTextSlide.universalRef}, payload: ['My Answer']}
103
103
  ];
104
- const {dispatch} = createTestStore(t, state, services, expectedActions);
104
+ const {dispatch} = createTestStore(t, state, {services}, expectedActions);
105
105
  await dispatch(editAnswer(['My Answer']));
106
106
  });
107
107
 
@@ -112,7 +112,7 @@ test('should dispatch EDIT_QCM action when editAnswer is called', async t => {
112
112
  const expectedActions = [
113
113
  {type: ANSWER_EDIT.qcm, meta: {slideRef: qcmSlide.universalRef}, payload: ['My First Answer']}
114
114
  ];
115
- const {dispatch} = createTestStore(t, state, services, expectedActions);
115
+ const {dispatch} = createTestStore(t, state, {services}, expectedActions);
116
116
  await dispatch(editAnswer(['My Second Answer']));
117
117
  });
118
118
 
@@ -131,7 +131,7 @@ test('should dispatch EDIT_QCM_GRAPHIC action when editAnswer is called', async
131
131
  payload: ['My First Answer', 'My Third Answer']
132
132
  }
133
133
  ];
134
- const {dispatch} = createTestStore(t, state, services, expectedActions);
134
+ const {dispatch} = createTestStore(t, state, {services}, expectedActions);
135
135
  await dispatch(editAnswer(['My Second Answer']));
136
136
  });
137
137
 
@@ -146,7 +146,7 @@ test('should dispatch EDIT_QCM_DRAG action when editAnswer is called', async t =
146
146
  payload: ['My First Answer', 'My Second Answer', 'My Third Answer']
147
147
  }
148
148
  ];
149
- const {dispatch} = createTestStore(t, state, services, expectedActions);
149
+ const {dispatch} = createTestStore(t, state, {services}, expectedActions);
150
150
  await dispatch(editAnswer(['My Third Answer']));
151
151
  });
152
152
 
@@ -155,7 +155,7 @@ test('should dispatch EDIT_SLIDER action when editAnswer is called', async t =>
155
155
  const expectedActions = [
156
156
  {type: ANSWER_EDIT.slider, meta: {slideRef: sliderSlide.universalRef}, payload: ['5']}
157
157
  ];
158
- const {dispatch} = createTestStore(t, state, services, expectedActions);
158
+ const {dispatch} = createTestStore(t, state, {services}, expectedActions);
159
159
  await dispatch(editAnswer(['5']));
160
160
  });
161
161
 
@@ -169,6 +169,6 @@ test('should dispatch EDIT_TEMPLATE action when editAnswer is called', async t =
169
169
  payload: ['Catalogue', 'My Answer', 'étoiles']
170
170
  }
171
171
  ];
172
- const {dispatch} = createTestStore(t, state, services, expectedActions);
172
+ const {dispatch} = createTestStore(t, state, {services}, expectedActions);
173
173
  await dispatch(editAnswer(['Catalogue', 'My Answer', 'étoiles']));
174
174
  });
@@ -0,0 +1,95 @@
1
+ import test from 'ava';
2
+ import {createTestStore} from '../../test/create-test-store';
3
+ import type {StoreState} from '../../../reducers';
4
+ import {services} from '../../../test/util/services.mock';
5
+ import {navigateBack, navigateTo} from '../navigation';
6
+
7
+ const initialState: StoreState = {
8
+ data: {
9
+ progression: null,
10
+ slides: {},
11
+ skills: [],
12
+ token: '1234',
13
+ corrections: {},
14
+ rank: {start: 10, end: Number.NaN}
15
+ },
16
+ ui: {
17
+ positions: [0, 1, 2, 3, 4],
18
+ currentSlideRef: '',
19
+ navigation: ['loader', 'skills'],
20
+ answers: {},
21
+ slide: {},
22
+ showCongrats: false,
23
+ showQuitPopin: false
24
+ }
25
+ };
26
+
27
+ test('should dispatch NAVIGATE_TO', async t => {
28
+ const expectedActions = [
29
+ {
30
+ type: '@@navigation/NAVIGATE_TO',
31
+ payload: 'slides'
32
+ }
33
+ ];
34
+
35
+ const {dispatch} = createTestStore(t, initialState, {services}, expectedActions);
36
+ await dispatch(navigateTo('slides'));
37
+ });
38
+
39
+ test('should dispatch NAVIGATE_BACK', t => {
40
+ const expectedActions = [
41
+ {
42
+ type: '@@navigation/NAVIGATE_BACK'
43
+ }
44
+ ];
45
+
46
+ const {dispatch} = createTestStore(t, initialState, {services}, expectedActions);
47
+ dispatch(navigateBack);
48
+ });
49
+
50
+ test('should dispatch NAVIGATE_TO with callbackOnViewChanged', async t => {
51
+ t.plan(2);
52
+
53
+ const callbackOnViewChanged = (viewName: string): void => {
54
+ t.is(viewName, 'slides');
55
+ };
56
+
57
+ const expectedActions = [
58
+ {
59
+ type: '@@navigation/NAVIGATE_TO',
60
+ payload: 'slides'
61
+ }
62
+ ];
63
+
64
+ const {dispatch} = createTestStore(
65
+ t,
66
+ initialState,
67
+ {callbackOnViewChanged, services},
68
+ expectedActions
69
+ );
70
+
71
+ await dispatch(navigateTo('slides'));
72
+ });
73
+
74
+ test('should dispatch NAVIGATE_BACK with callbackOnViewChanged', async t => {
75
+ t.plan(2);
76
+
77
+ const callbackOnViewChanged = (viewName: string): void => {
78
+ t.is(viewName, 'loader');
79
+ };
80
+
81
+ const expectedActions = [
82
+ {
83
+ type: '@@navigation/NAVIGATE_BACK'
84
+ }
85
+ ];
86
+
87
+ const {dispatch} = createTestStore(
88
+ t,
89
+ initialState,
90
+ {callbackOnViewChanged, services},
91
+ expectedActions
92
+ );
93
+
94
+ await dispatch(navigateBack);
95
+ });
@@ -60,7 +60,7 @@ test('should dispatch NEXT_SLIDE action when nextSlide is called and the progres
60
60
  }
61
61
  }
62
62
  ];
63
- const {dispatch} = createTestStore(t, state, services, expectedActions);
63
+ const {dispatch} = createTestStore(t, state, {services}, expectedActions);
64
64
  dispatch(nextSlide);
65
65
  });
66
66
 
@@ -82,6 +82,6 @@ test('should dispatch NEXT_SLIDE action when nextSlide is called and the progres
82
82
  }
83
83
  }
84
84
  ];
85
- const {dispatch} = createTestStore(t, stateWithWrongAnswer, services, expectedActions);
85
+ const {dispatch} = createTestStore(t, stateWithWrongAnswer, {services}, expectedActions);
86
86
  dispatch(nextSlide);
87
87
  });
@@ -27,13 +27,13 @@ const initialState: StoreState = {
27
27
  test('should dispatch OPEN_POPIN when openQuitPopin action is called', async t => {
28
28
  const expectedAction = [{type: OPEN_POPIN}];
29
29
 
30
- const {dispatch} = createTestStore(t, initialState, services, expectedAction);
30
+ const {dispatch} = createTestStore(t, initialState, {services}, expectedAction);
31
31
  await dispatch(openQuitPopin);
32
32
  });
33
33
 
34
34
  test('should dispatch CLOSE_POPIN when closeQuitPopin action is called', async t => {
35
35
  const expectedAction = [{type: CLOSE_POPIN}];
36
36
 
37
- const {dispatch} = createTestStore(t, initialState, services, expectedAction);
37
+ const {dispatch} = createTestStore(t, initialState, {services}, expectedAction);
38
38
  await dispatch(closeQuitPopin);
39
39
  });
@@ -28,6 +28,6 @@ const initialState: StoreState = {
28
28
  test('should dispatch SET_CURRENT_SLIDE action when setCurrentSlide is called', async t => {
29
29
  const expectedActions = [{type: SET_CURRENT_SLIDE, payload: freeTextSlide}];
30
30
 
31
- const {dispatch} = createTestStore(t, initialState, services, expectedActions);
31
+ const {dispatch} = createTestStore(t, initialState, {services}, expectedActions);
32
32
  await dispatch(setCurrentSlide(freeTextSlide));
33
33
  });
@@ -2,16 +2,6 @@ import concat from 'lodash/fp/concat';
2
2
  import slice from 'lodash/fp/slice';
3
3
  import type {ProgressionFromAPI} from '../types/common';
4
4
 
5
- export const VIEWS: {
6
- readonly skills: 'skills';
7
- readonly onboarding: 'onboarding';
8
- readonly slides: 'slides';
9
- } = {
10
- skills: 'skills',
11
- onboarding: 'onboarding',
12
- slides: 'slides'
13
- };
14
-
15
5
  export const slideIndexes = ['0', '1', '2', '3', '4'] as const;
16
6
 
17
7
  export type SlideIndexes = typeof slideIndexes[number];
@@ -3,7 +3,7 @@ import thunk from 'redux-thunk';
3
3
  import rootReducer, {StoreState} from './reducers';
4
4
  import {getServices} from './services';
5
5
 
6
- import {AppOptions} from './types/common';
6
+ import {AppOptions, ThunkOptions} from './types/common';
7
7
 
8
8
  export default function configureStore(options: AppOptions): Store<StoreState, AnyAction> {
9
9
  const _compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
@@ -14,7 +14,13 @@ export default function configureStore(options: AppOptions): Store<StoreState, A
14
14
  })
15
15
  : compose;
16
16
 
17
- const thunkMiddleware = thunk.withExtraArgument({services: options.services || getServices()});
17
+ const thunkOptions: ThunkOptions = {
18
+ services: options.services || getServices(),
19
+ callbackOnViewChanged: options.callbackOnViewChanged
20
+ };
21
+
22
+ const thunkMiddleware = thunk.withExtraArgument(thunkOptions);
23
+
18
24
  const enhancer = _compose(applyMiddleware(thunkMiddleware));
19
25
  const store = createStore(rootReducer, undefined, enhancer);
20
26
 
package/src/index.tsx CHANGED
@@ -3,26 +3,27 @@ import type {} from 'redux-thunk/extend-redux'; // https://github.com/reduxjs/re
3
3
  import {AnyAction, Store} from 'redux';
4
4
  import {useSelector, useDispatch, Provider} from 'react-redux';
5
5
  import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
6
+ import {AppReviewProps} from '@coorpacademy/components/es/template/app-review/prop-types';
6
7
 
7
8
  import isEmpty from 'lodash/fp/isEmpty';
8
9
  import get from 'lodash/fp/get';
9
10
  import configureStore from './configure-store';
10
11
 
11
- import type {AppOptions} from './types/common';
12
+ import type {AppOptions, ViewName} from './types/common';
12
13
  import type {StoreState} from './reducers';
13
14
 
14
- import {navigateTo, ViewPath} from './actions/ui/navigation';
15
+ import {navigateBack, navigateTo} from './actions/ui/navigation';
15
16
  import {storeToken} from './actions/data/token';
16
17
  import {fetchSkills} from './actions/api/fetch-skills';
17
18
  import {postProgression} from './actions/api/post-progression';
18
- import {VIEWS} from './common';
19
19
  import {mapStateToSlidesProps} from './views/slides';
20
20
  import {mapStateToSkillsProps} from './views/skills';
21
21
 
22
- const ConnectedApp = ({onQuitClick}: {onQuitClick: Function}): JSX.Element => {
22
+ const ConnectedApp = ({onQuitClick}: {onQuitClick: () => void}): JSX.Element => {
23
23
  const dispatch = useDispatch();
24
24
 
25
- const props = {
25
+ const props: AppReviewProps = {
26
+ navigateBack: () => dispatch(navigateBack),
26
27
  viewName: useSelector(
27
28
  (state: StoreState) => state.ui.navigation[state.ui.navigation.length - 1]
28
29
  ),
@@ -30,6 +31,7 @@ const ConnectedApp = ({onQuitClick}: {onQuitClick: Function}): JSX.Element => {
30
31
  skills: useSelector((state: StoreState) => mapStateToSkillsProps(state)),
31
32
  onboarding: {}
32
33
  };
34
+
33
35
  return <AppReviewTemplate {...props} />;
34
36
  };
35
37
 
@@ -82,7 +84,7 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
82
84
  return;
83
85
  }
84
86
 
85
- const initialView: ViewPath = skillRef ? VIEWS.slides : VIEWS.skills;
87
+ const initialView: ViewName = skillRef ? 'slides' : 'skills';
86
88
  store.dispatch(navigateTo(initialView));
87
89
  }, [isProgressionCreated, options, store]);
88
90
 
@@ -1,8 +1,8 @@
1
1
  import {
2
- type NavigateTo,
3
- type NavigateBack,
4
- NAVIGATE_BACK,
5
- NAVIGATE_TO
2
+ NavigateToAction,
3
+ NavigateBackAction,
4
+ NAVIGATE_TO,
5
+ NAVIGATE_BACK
6
6
  } from '../../actions/ui/navigation';
7
7
 
8
8
  export type NavigationState = Array<'skills' | 'onboarding' | 'slides' | 'loader'>;
@@ -10,7 +10,7 @@ export type NavigationState = Array<'skills' | 'onboarding' | 'slides' | 'loader
10
10
  const reducer = (
11
11
  // eslint-disable-next-line default-param-last
12
12
  state: NavigationState = [],
13
- action: NavigateTo | NavigateBack
13
+ action: NavigateToAction | NavigateBackAction
14
14
  ): NavigationState => {
15
15
  switch (action.type) {
16
16
  case NAVIGATE_TO: {
@@ -1,19 +1,19 @@
1
1
  import test from 'ava';
2
2
  import reducer from '../navigation';
3
- import {NavigateTo, navigateBack, navigateTo} from '../../../actions/ui/navigation';
3
+ import {NavigateToAction, NAVIGATE_BACK, NAVIGATE_TO} from '../../../actions/ui/navigation';
4
4
 
5
5
  test('should have initial value', t => {
6
- const state = reducer(undefined, {} as NavigateTo);
6
+ const state = reducer(undefined, {} as NavigateToAction);
7
7
  t.deepEqual(state, []);
8
8
  });
9
9
 
10
10
  test('should set the value of NAVIGATE_TO and NAVIGATE_BACK action', t => {
11
- const state = reducer([], navigateTo('loader'));
11
+ const state = reducer([], {type: NAVIGATE_TO, payload: 'loader'});
12
12
  t.deepEqual(state, ['loader']);
13
13
 
14
- const updatedState = reducer(state, navigateTo('skills'));
14
+ const updatedState = reducer(state, {type: NAVIGATE_TO, payload: 'skills'});
15
15
  t.deepEqual(updatedState, ['loader', 'skills']);
16
16
 
17
- const _updatedState = reducer(updatedState, navigateBack());
17
+ const _updatedState = reducer(updatedState, {type: NAVIGATE_BACK});
18
18
  t.deepEqual(_updatedState, ['loader']);
19
19
  });
@@ -1,3 +1,5 @@
1
+ export type ViewName = 'skills' | 'onboarding' | 'slides' | 'loader';
2
+
1
3
  export type ChoiceFromAPI = {
2
4
  _id: string;
3
5
  id?: string;
@@ -175,16 +177,18 @@ export type Services = {
175
177
  ): Promise<SlideIdFromAPI[]>;
176
178
  };
177
179
 
178
- export type Options = {
179
- services: Services;
180
- };
181
-
182
180
  export type AppOptions = {
183
181
  token: string;
184
182
  skillRef?: string;
185
183
  services: Services;
186
- onQuitClick: Function;
184
+ onQuitClick: () => void;
187
185
  url: string;
186
+ callbackOnViewChanged?: (viewName: ViewName) => void;
187
+ };
188
+
189
+ export type ThunkOptions = {
190
+ callbackOnViewChanged?: AppOptions['callbackOnViewChanged'];
191
+ services: Services;
188
192
  };
189
193
 
190
194
  export type JWT = {
@@ -9,12 +9,10 @@ type SkillCard = {
9
9
  reviseLabel: string;
10
10
  reviseAriaLabel: string;
11
11
  isCustom: boolean;
12
- onClick: Function;
12
+ onClick: () => void;
13
13
  };
14
14
 
15
15
  type NoSkillsProps = {
16
- titleNoSkills: string;
17
- textNoSkills: string;
18
16
  iconSkillAriaLabel: string;
19
17
  };
20
18
 
@@ -31,8 +29,6 @@ export {SkillsProps};
31
29
  export const mapStateToSkillsProps = (state: StoreState): SkillsProps => {
32
30
  return {
33
31
  title: '@todo title',
34
- titleNoSkills: '@todo titleNoSkills',
35
- textNoSkills: '@todo textNoSkills',
36
32
  iconSkillAriaLabel: '@todo iconSkillAriaLabel',
37
33
  isLoading: false,
38
34
  isLoadingAriaLabel: '@todo loading',
@@ -29,8 +29,6 @@ test('should create initial props when there are no skills on the state', t => {
29
29
 
30
30
  t.deepEqual(props, {
31
31
  title: '@todo title',
32
- titleNoSkills: '@todo titleNoSkills',
33
- textNoSkills: '@todo textNoSkills',
34
32
  iconSkillAriaLabel: '@todo iconSkillAriaLabel',
35
33
  isLoading: false,
36
34
  isLoadingAriaLabel: '@todo loading',
@@ -76,8 +74,6 @@ test('should create initial props when skills on the state', t => {
76
74
 
77
75
  t.deepEqual(omit('listSkills', props), {
78
76
  title: '@todo title',
79
- titleNoSkills: '@todo titleNoSkills',
80
- textNoSkills: '@todo textNoSkills',
81
77
  iconSkillAriaLabel: '@todo iconSkillAriaLabel',
82
78
  isLoading: false,
83
79
  isLoadingAriaLabel: '@todo loading'