@coorpacademy/app-review 0.0.21-alpha.8 → 0.1.2

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 (232) hide show
  1. package/es/actions/courses.d.ts +0 -1
  2. package/es/actions/{api → data}/is-fetching.d.ts +0 -1
  3. package/{lib/actions/api → es/actions/data}/validate-slide.d.ts +0 -1
  4. package/es/actions/finished-slides.d.ts +0 -1
  5. package/es/actions/index.d.ts +0 -1
  6. package/es/actions/navigation.d.ts +0 -1
  7. package/es/actions/review-status.d.ts +0 -1
  8. package/es/actions/slides.d.ts +0 -1
  9. package/es/actions/step-items.d.ts +0 -1
  10. package/es/actions/token.d.ts +0 -1
  11. package/es/common/index.d.ts +1 -1
  12. package/es/common/index.js +1 -0
  13. package/es/configure-store.d.ts +2 -3
  14. package/es/configure-store.js +3 -9
  15. package/es/fixtures/qcm-slide.d.ts +2 -0
  16. package/es/fixtures/qcm-slide.js +29 -0
  17. package/es/{temp-fixture.d.ts → fixtures/temp-fixture.d.ts} +1 -2
  18. package/es/helpers/css-register.js +2 -0
  19. package/es/index.d.ts +1 -3
  20. package/es/index.js +43 -27
  21. package/es/index.test.js +52 -0
  22. package/es/middlewares/on-start-app.d.ts +0 -1
  23. package/es/middlewares/on-start-app.js +2 -0
  24. package/es/reducers/courses.d.ts +0 -1
  25. package/es/reducers/data.d.ts +7 -0
  26. package/es/reducers/{api.js → data.js} +15 -8
  27. package/es/reducers/finished-slides.d.ts +1 -2
  28. package/es/reducers/finished-slides.js +17 -7
  29. package/es/reducers/index.d.ts +9 -14
  30. package/es/reducers/index.js +7 -6
  31. package/es/reducers/navigation.d.ts +0 -1
  32. package/es/reducers/navigation.js +1 -1
  33. package/es/reducers/review-status.d.ts +0 -1
  34. package/es/reducers/slides.d.ts +1 -2
  35. package/es/reducers/slides.js +37 -25
  36. package/es/reducers/step-items.d.ts +1 -2
  37. package/es/reducers/step-items.js +19 -12
  38. package/es/reducers/token.d.ts +4 -7
  39. package/es/reducers/token.js +3 -14
  40. package/es/services/fetch-demo.d.ts +0 -1
  41. package/es/services/fetch-demo.test.d.ts +0 -1
  42. package/es/services/fetch-responses.d.ts +0 -1
  43. package/es/services/fetch.mocks.d.ts +0 -1
  44. package/es/types/common.d.ts +0 -1
  45. package/es/types/data/index.d.ts +14 -0
  46. package/es/types/data/index.js +1 -0
  47. package/es/types/dispatchers.d.ts +1 -2
  48. package/es/types/finished-slides.d.ts +4 -2
  49. package/es/types/review-status.d.ts +0 -1
  50. package/es/types/slides.d.ts +4 -2
  51. package/es/types/states.d.ts +1 -3
  52. package/es/types/step-items.d.ts +4 -2
  53. package/es/types/store-state.d.ts +10 -10
  54. package/es/types/utils.d.ts +0 -1
  55. package/es/types/views.d.ts +9 -3
  56. package/lib/actions/courses.d.ts +0 -1
  57. package/lib/actions/{api → data}/is-fetching.d.ts +0 -1
  58. package/{es/actions/api → lib/actions/data}/validate-slide.d.ts +0 -1
  59. package/lib/actions/finished-slides.d.ts +0 -1
  60. package/lib/actions/index.d.ts +0 -1
  61. package/lib/actions/navigation.d.ts +0 -1
  62. package/lib/actions/review-status.d.ts +0 -1
  63. package/lib/actions/slides.d.ts +0 -1
  64. package/lib/actions/step-items.d.ts +0 -1
  65. package/lib/actions/token.d.ts +0 -1
  66. package/lib/common/index.d.ts +1 -1
  67. package/lib/common/index.js +1 -0
  68. package/lib/configure-store.d.ts +2 -3
  69. package/lib/configure-store.js +10 -66
  70. package/lib/fixtures/qcm-slide.d.ts +2 -0
  71. package/lib/fixtures/qcm-slide.js +29 -0
  72. package/lib/{temp-fixture.d.ts → fixtures/temp-fixture.d.ts} +1 -2
  73. package/lib/helpers/css-register.d.ts +1 -0
  74. package/lib/helpers/css-register.js +2 -0
  75. package/lib/index.d.ts +1 -3
  76. package/lib/index.js +52 -52
  77. package/lib/index.test.d.ts +1 -0
  78. package/lib/index.test.js +160 -0
  79. package/lib/middlewares/on-start-app.d.ts +0 -1
  80. package/lib/middlewares/on-start-app.js +2 -0
  81. package/lib/reducers/courses.d.ts +0 -1
  82. package/lib/reducers/courses.js +1 -17
  83. package/lib/reducers/data.d.ts +7 -0
  84. package/lib/reducers/{api.js → data.js} +15 -8
  85. package/lib/reducers/finished-slides.d.ts +1 -2
  86. package/lib/reducers/finished-slides.js +28 -45
  87. package/lib/reducers/index.d.ts +9 -14
  88. package/lib/reducers/index.js +7 -6
  89. package/lib/reducers/navigation.d.ts +0 -1
  90. package/lib/reducers/navigation.js +3 -19
  91. package/lib/reducers/review-status.d.ts +0 -1
  92. package/lib/reducers/slides.d.ts +1 -2
  93. package/lib/reducers/slides.js +58 -106
  94. package/lib/reducers/step-items.d.ts +1 -2
  95. package/lib/reducers/step-items.js +21 -52
  96. package/lib/reducers/token.d.ts +4 -7
  97. package/lib/reducers/token.js +3 -15
  98. package/lib/services/fetch-demo.d.ts +0 -1
  99. package/lib/services/fetch-demo.test.d.ts +0 -1
  100. package/lib/services/fetch-responses.d.ts +0 -1
  101. package/lib/services/fetch.mocks.d.ts +0 -1
  102. package/lib/types/common.d.ts +0 -1
  103. package/lib/types/data/index.d.ts +14 -0
  104. package/lib/types/data/index.js +1 -0
  105. package/lib/types/dispatchers.d.ts +1 -2
  106. package/lib/types/finished-slides.d.ts +4 -2
  107. package/lib/types/review-status.d.ts +0 -1
  108. package/lib/types/slides.d.ts +4 -2
  109. package/lib/types/states.d.ts +1 -3
  110. package/lib/types/step-items.d.ts +4 -2
  111. package/lib/types/store-state.d.ts +10 -10
  112. package/lib/types/utils.d.ts +0 -1
  113. package/lib/types/views.d.ts +9 -3
  114. package/package.json +10 -7
  115. package/src/common/index.ts +2 -0
  116. package/src/configure-store.ts +10 -20
  117. package/src/fixtures/qcm-slide.ts +31 -0
  118. package/src/{temp-fixture.ts → fixtures/temp-fixture.ts} +1 -1
  119. package/src/helpers/css-modules-require-hook.d.ts +4 -0
  120. package/src/helpers/css-register.ts +3 -0
  121. package/src/index.test.tsx +82 -0
  122. package/src/index.tsx +48 -34
  123. package/src/middlewares/on-start-app.ts +2 -0
  124. package/src/reducers/{api.ts → data.ts} +17 -14
  125. package/src/reducers/finished-slides.ts +22 -7
  126. package/src/reducers/index.ts +8 -6
  127. package/src/reducers/navigation.ts +1 -1
  128. package/src/reducers/slides.ts +38 -25
  129. package/src/reducers/step-items.ts +22 -12
  130. package/src/reducers/token.ts +5 -17
  131. package/src/types/data/index.ts +16 -0
  132. package/src/types/dispatchers.ts +1 -1
  133. package/src/types/finished-slides.ts +5 -2
  134. package/src/types/globals.d.ts +6 -0
  135. package/src/types/slides.ts +6 -3
  136. package/src/types/states.ts +1 -2
  137. package/src/types/step-items.ts +4 -1
  138. package/src/types/store-state.ts +11 -11
  139. package/src/types/views.tsx +9 -2
  140. package/es/actions/api/is-fetching.d.ts.map +0 -1
  141. package/es/actions/api/validate-slide.d.ts.map +0 -1
  142. package/es/actions/courses.d.ts.map +0 -1
  143. package/es/actions/finished-slides.d.ts.map +0 -1
  144. package/es/actions/index.d.ts.map +0 -1
  145. package/es/actions/navigation.d.ts.map +0 -1
  146. package/es/actions/review-status.d.ts.map +0 -1
  147. package/es/actions/slides.d.ts.map +0 -1
  148. package/es/actions/step-items.d.ts.map +0 -1
  149. package/es/actions/token.d.ts.map +0 -1
  150. package/es/common/index.d.ts.map +0 -1
  151. package/es/configure-store.d.ts.map +0 -1
  152. package/es/index.d.ts.map +0 -1
  153. package/es/middlewares/on-start-app.d.ts.map +0 -1
  154. package/es/reducers/api.d.ts +0 -12
  155. package/es/reducers/api.d.ts.map +0 -1
  156. package/es/reducers/courses.d.ts.map +0 -1
  157. package/es/reducers/finished-slides.d.ts.map +0 -1
  158. package/es/reducers/index.d.ts.map +0 -1
  159. package/es/reducers/navigation.d.ts.map +0 -1
  160. package/es/reducers/review-status.d.ts.map +0 -1
  161. package/es/reducers/slides.d.ts.map +0 -1
  162. package/es/reducers/step-items.d.ts.map +0 -1
  163. package/es/reducers/token.d.ts.map +0 -1
  164. package/es/services/fetch-demo.d.ts.map +0 -1
  165. package/es/services/fetch-demo.test.d.ts.map +0 -1
  166. package/es/services/fetch-responses.d.ts.map +0 -1
  167. package/es/services/fetch.mocks.d.ts.map +0 -1
  168. package/es/temp-fixture.d.ts.map +0 -1
  169. package/es/types/api/index.d.ts +0 -16
  170. package/es/types/api/index.d.ts.map +0 -1
  171. package/es/types/common.d.ts.map +0 -1
  172. package/es/types/dispatchers.d.ts.map +0 -1
  173. package/es/types/finished-slides.d.ts.map +0 -1
  174. package/es/types/review-status.d.ts.map +0 -1
  175. package/es/types/slides.d.ts.map +0 -1
  176. package/es/types/states.d.ts.map +0 -1
  177. package/es/types/step-items.d.ts.map +0 -1
  178. package/es/types/store-state.d.ts.map +0 -1
  179. package/es/types/utils.d.ts.map +0 -1
  180. package/es/types/views.d.ts.map +0 -1
  181. package/lib/actions/api/is-fetching.d.ts.map +0 -1
  182. package/lib/actions/api/validate-slide.d.ts.map +0 -1
  183. package/lib/actions/courses.d.ts.map +0 -1
  184. package/lib/actions/finished-slides.d.ts.map +0 -1
  185. package/lib/actions/index.d.ts.map +0 -1
  186. package/lib/actions/navigation.d.ts.map +0 -1
  187. package/lib/actions/review-status.d.ts.map +0 -1
  188. package/lib/actions/slides.d.ts.map +0 -1
  189. package/lib/actions/step-items.d.ts.map +0 -1
  190. package/lib/actions/token.d.ts.map +0 -1
  191. package/lib/common/index.d.ts.map +0 -1
  192. package/lib/configure-store.d.ts.map +0 -1
  193. package/lib/index.d.ts.map +0 -1
  194. package/lib/middlewares/on-start-app.d.ts.map +0 -1
  195. package/lib/reducers/api.d.ts +0 -12
  196. package/lib/reducers/api.d.ts.map +0 -1
  197. package/lib/reducers/courses.d.ts.map +0 -1
  198. package/lib/reducers/finished-slides.d.ts.map +0 -1
  199. package/lib/reducers/index.d.ts.map +0 -1
  200. package/lib/reducers/navigation.d.ts.map +0 -1
  201. package/lib/reducers/review-status.d.ts.map +0 -1
  202. package/lib/reducers/slides.d.ts.map +0 -1
  203. package/lib/reducers/step-items.d.ts.map +0 -1
  204. package/lib/reducers/token.d.ts.map +0 -1
  205. package/lib/services/fetch-demo.d.ts.map +0 -1
  206. package/lib/services/fetch-demo.test.d.ts.map +0 -1
  207. package/lib/services/fetch-responses.d.ts.map +0 -1
  208. package/lib/services/fetch.mocks.d.ts.map +0 -1
  209. package/lib/temp-fixture.d.ts.map +0 -1
  210. package/lib/types/api/index.d.ts +0 -16
  211. package/lib/types/api/index.d.ts.map +0 -1
  212. package/lib/types/common.d.ts.map +0 -1
  213. package/lib/types/dispatchers.d.ts.map +0 -1
  214. package/lib/types/finished-slides.d.ts.map +0 -1
  215. package/lib/types/review-status.d.ts.map +0 -1
  216. package/lib/types/slides.d.ts.map +0 -1
  217. package/lib/types/states.d.ts.map +0 -1
  218. package/lib/types/step-items.d.ts.map +0 -1
  219. package/lib/types/store-state.d.ts.map +0 -1
  220. package/lib/types/utils.d.ts.map +0 -1
  221. package/lib/types/views.d.ts.map +0 -1
  222. package/src/types/api/index.ts +0 -16
  223. /package/es/actions/{api → data}/is-fetching.js +0 -0
  224. /package/es/actions/{api → data}/validate-slide.js +0 -0
  225. /package/es/{temp-fixture.js → fixtures/temp-fixture.js} +0 -0
  226. /package/es/{types/api/index.js → helpers/css-register.d.ts} +0 -0
  227. /package/{lib/types/api/index.js → es/index.test.d.ts} +0 -0
  228. /package/lib/actions/{api → data}/is-fetching.js +0 -0
  229. /package/lib/actions/{api → data}/validate-slide.js +0 -0
  230. /package/lib/{temp-fixture.js → fixtures/temp-fixture.js} +0 -0
  231. /package/src/actions/{api → data}/is-fetching.ts +0 -0
  232. /package/src/actions/{api → data}/validate-slide.ts +0 -0
@@ -4,4 +4,3 @@ export declare type ReceivedCourse = {
4
4
  payload: unknown;
5
5
  };
6
6
  export declare const receivedCourse: (course: unknown) => ReceivedCourse;
7
- //# sourceMappingURL=courses.d.ts.map
@@ -3,4 +3,3 @@ export declare type IsFetching = {
3
3
  type: typeof IS_FETCHING_TRUE;
4
4
  };
5
5
  export declare const setIsFetching: () => IsFetching;
6
- //# sourceMappingURL=is-fetching.d.ts.map
@@ -3,4 +3,3 @@ export declare type ValidateSlide = {
3
3
  type: typeof VALIDATE_SLIDE;
4
4
  };
5
5
  export declare const validateSlide: () => ValidateSlide;
6
- //# sourceMappingURL=validate-slide.d.ts.map
@@ -5,4 +5,3 @@ export declare type UpdateFinishedSlides = {
5
5
  payload: UpdateFinishedSlidesPayload;
6
6
  };
7
7
  export declare const updateFinishedSlides: (payload: UpdateFinishedSlidesPayload) => UpdateFinishedSlides;
8
- //# sourceMappingURL=finished-slides.d.ts.map
@@ -3,4 +3,3 @@ import { NavigateBack, NavigateTo, StartApp } from './navigation';
3
3
  import { StoreToken } from './token';
4
4
  import { StoreFirstSlide } from './slides';
5
5
  export declare type Action = NavigateBack | NavigateTo | ReceivedCourse | StartApp | StoreFirstSlide | StoreToken;
6
- //# sourceMappingURL=index.d.ts.map
@@ -17,4 +17,3 @@ export declare type StartApp = {
17
17
  export declare const navigateTo: (newPath: ViewPath) => NavigateTo;
18
18
  export declare const navigateBack: () => NavigateBack;
19
19
  export declare const startApp: (options: AppOptions) => StartApp;
20
- //# sourceMappingURL=navigation.d.ts.map
@@ -5,4 +5,3 @@ export declare type UpdateReviewStatus = {
5
5
  payload: UpdateReviewStatusPayload;
6
6
  };
7
7
  export declare const updateReviewStatus: (payload: UpdateReviewStatusPayload) => UpdateReviewStatus;
8
- //# sourceMappingURL=review-status.d.ts.map
@@ -18,4 +18,3 @@ export declare type SlidesAction = StoreFirstSlide | UpdateSlidesOnValidation |
18
18
  export declare const storeFirstSlide: (slide: Slide) => StoreFirstSlide;
19
19
  export declare const updateSlidesOnValidation: (payload: UpdateSlidesOnValidationPayload) => UpdateSlidesOnValidation;
20
20
  export declare const updateSlidesOnNext: (payload: UpdateSlidesOnNextPayload) => UpdateSlidesOnNext;
21
- //# sourceMappingURL=slides.d.ts.map
@@ -12,4 +12,3 @@ export declare type UpdateStepItemsOnNext = {
12
12
  export declare type StepItemsAction = UpdateStepItemsOnValidation | UpdateStepItemsOnNext;
13
13
  export declare const updateStepItemsOnValidation: (payload: UpdateStepItemsOnValidationClickPayload) => UpdateStepItemsOnValidation;
14
14
  export declare const updateStepItemsOnNext: (payload: UpdateStepItemsOnNextClickPayload) => UpdateStepItemsOnNext;
15
- //# sourceMappingURL=step-items.d.ts.map
@@ -4,4 +4,3 @@ export declare type StoreToken = {
4
4
  payload: string;
5
5
  };
6
6
  export declare const storeToken: (token: string) => StoreToken;
7
- //# sourceMappingURL=token.d.ts.map
@@ -5,4 +5,4 @@ export declare const VIEWS: {
5
5
  readonly onboarding: 'onboarding';
6
6
  readonly slides: 'slides';
7
7
  };
8
- //# sourceMappingURL=index.d.ts.map
8
+ export declare const slideNumbers: number[];
@@ -5,3 +5,4 @@ export const VIEWS = {
5
5
  onboarding: 'onboarding',
6
6
  slides: 'slides'
7
7
  };
8
+ export const slideNumbers = [0, 1, 2, 3, 4];
@@ -1,6 +1,5 @@
1
1
  import { AnyAction, EmptyObject, Store } from 'redux';
2
2
  import { StoreState } from './types/store-state';
3
- export default function configureStore(): Promise<Store<EmptyObject & StoreState, AnyAction> & {
3
+ export default function configureStore(): Store<EmptyObject & StoreState, AnyAction> & {
4
4
  dispatch: {};
5
- }>;
6
- //# sourceMappingURL=configure-store.d.ts.map
5
+ };
@@ -4,15 +4,9 @@ import rootReducer from './reducers';
4
4
  import onStartApp from './middlewares/on-start-app';
5
5
  const preloadedState = undefined;
6
6
  // -----------------------------------------------------------------------------
7
- export default async function configureStore() {
8
- const isExtensionEnabled = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__;
9
- const isProd = process.env.NODE_ENV !== 'production';
10
- const { composeWithDevTools } = isProd
11
- ? { composeWithDevTools: null }
12
- : // eslint-disable-next-line node/no-unsupported-features/es-syntax, import/dynamic-import-chunkname
13
- await import('redux-devtools-extension');
14
- const _compose = !isProd && isExtensionEnabled
15
- ? composeWithDevTools({
7
+ export default function configureStore() {
8
+ const _compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
9
+ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
16
10
  name: 'app-review',
17
11
  trace: true,
18
12
  traceLimit: 25
@@ -0,0 +1,2 @@
1
+ import { Slide } from '../types/slides';
2
+ export declare const slide: Slide;
@@ -0,0 +1,29 @@
1
+ export const slide = {
2
+ questionText: 'QCM',
3
+ answerUI: {
4
+ help: '__help',
5
+ model: {
6
+ type: 'qcm',
7
+ choices: [
8
+ {
9
+ selected: false,
10
+ title: 'choix1',
11
+ help: '(help choix1)',
12
+ ariaLabel: '__ariaLabel1'
13
+ },
14
+ {
15
+ selected: false,
16
+ title: 'choix2',
17
+ help: '(help choix2)',
18
+ ariaLabel: '__ariaLabel2'
19
+ },
20
+ {
21
+ selected: false,
22
+ title: 'choix3',
23
+ help: '(help choix3)',
24
+ ariaLabel: '__ariaLabel3'
25
+ }
26
+ ]
27
+ }
28
+ }
29
+ };
@@ -1,4 +1,3 @@
1
- import { SlidesViewProps } from './types/views';
1
+ import { SlidesViewProps } from '../types/views';
2
2
  export declare const correctionPopinProps: SlidesViewProps['correctionPopinProps'];
3
3
  export declare const congratsProps: SlidesViewProps['congratsProps'];
4
- //# sourceMappingURL=temp-fixture.d.ts.map
@@ -0,0 +1,2 @@
1
+ import cssRegister from '@coorpacademy/css-modules-require-hook';
2
+ cssRegister();
package/es/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
- import { AppOptions } from './types/common';
1
+ import type { AppOptions } from './types/common';
3
2
  declare const AppReview: ({ options }: {
4
3
  options: AppOptions;
5
4
  }) => JSX.Element;
@@ -9,4 +8,3 @@ declare global {
9
8
  }
10
9
  }
11
10
  export default AppReview;
12
- //# sourceMappingURL=index.d.ts.map
package/es/index.js CHANGED
@@ -5,11 +5,11 @@ import configureStore from './configure-store';
5
5
  import { navigateTo, navigateBack, startApp } from './actions/navigation';
6
6
  import { updateSlidesOnNext, updateSlidesOnValidation } from './actions/slides';
7
7
  import { getCurrentViewName } from './reducers/navigation';
8
- import { congratsProps, correctionPopinProps } from './temp-fixture';
8
+ import { congratsProps, correctionPopinProps } from './fixtures/temp-fixture';
9
9
  import { updateFinishedSlides } from './actions/finished-slides';
10
10
  import { updateReviewStatus } from './actions/review-status';
11
11
  import { updateStepItemsOnValidation, updateStepItemsOnNext } from './actions/step-items';
12
- import { validateSlide } from './actions/api/validate-slide';
12
+ import { validateSlide } from './actions/data/validate-slide';
13
13
  // -----------------------------------------------------------------------------
14
14
  const mapDispatchToProps = {
15
15
  navigateTo,
@@ -22,40 +22,56 @@ const mapDispatchToProps = {
22
22
  updateStepItemsOnNext,
23
23
  updateFinishedSlides
24
24
  };
25
- // StaticProps
26
- const mapStateToProps = (state) => ({
27
- viewName: getCurrentViewName(state),
28
- slides: {
29
- slides: state.slides,
30
- validate: {
31
- label: '__validate'
32
- },
33
- finishedSlides: state.finishedSlides,
34
- stepItems: state.stepItems,
35
- reviewStatus: state.reviewStatus,
36
- correctionPopinProps,
37
- congratsProps,
38
- slideValidationResult: state.api.entities.slideValidationResult
39
- }
40
- });
25
+ const mapStateToProps = (state) => {
26
+ return {
27
+ viewName: getCurrentViewName(state),
28
+ slides: {
29
+ headerProps: {
30
+ mode: '__revision_mode',
31
+ skillName: '__agility',
32
+ onQuitClick: () => {
33
+ // eslint-disable-next-line no-console
34
+ console.log('onQuitClick');
35
+ },
36
+ 'aria-label': 'aria-header-wrapper',
37
+ closeButtonAriaLabel: 'aria-close-button'
38
+ },
39
+ slides: state.ui.slides,
40
+ validate: {
41
+ label: '__validate'
42
+ },
43
+ finishedSlides: state.ui.finishedSlides,
44
+ stepItems: state.ui.stepItems,
45
+ reviewStatus: state.ui.reviewStatus,
46
+ correctionPopinProps,
47
+ congratsProps,
48
+ slideValidationResult: state.data.slideValidationResult
49
+ }
50
+ };
51
+ };
41
52
  // Props = StaticProps && Dispatchers
42
53
  const App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
43
54
  // -----------------------------------------------------------------------------
44
55
  const AppReview = ({ options }) => {
45
56
  const [store, setStore] = useState(null);
57
+ const [appStarted, setAppStarted] = useState(false);
46
58
  useEffect(() => {
47
- const _configure = async () => {
48
- const _store = await configureStore();
49
- _store.dispatch(startApp(options));
50
- setStore(_store);
51
- };
52
- _configure();
53
- }, [options]);
54
- if (!store)
59
+ if (store) {
60
+ store.dispatch(startApp(options));
61
+ setAppStarted(true);
62
+ }
63
+ else {
64
+ const _configure = async () => {
65
+ const _store = await configureStore();
66
+ setStore(_store);
67
+ };
68
+ _configure();
69
+ }
70
+ }, [options, store]);
71
+ if (!store || !appStarted)
55
72
  return null;
56
73
  return (React.createElement(Provider, { store: store },
57
74
  React.createElement(App, null)));
58
75
  };
59
- // type Props = {options: AppOptions};
60
76
  // -----------------------------------------------------------------------------
61
77
  export default AppReview;
@@ -0,0 +1,52 @@
1
+ import browserEnv from 'browser-env';
2
+ import test from 'ava';
3
+ import React from 'react';
4
+ import { render, fireEvent, act } from '@testing-library/react';
5
+ import { slide } from './fixtures/qcm-slide';
6
+ import AppReview from '.';
7
+ browserEnv({ pretendToBeVisual: true });
8
+ const elementExists = (foundElements) => foundElements && foundElements[0];
9
+ const sleep = (msToSleep) => new Promise(resolve => {
10
+ setTimeout(resolve, msToSleep);
11
+ });
12
+ const waitForChanges = async (msToWait = 3000) => {
13
+ await act(async () => {
14
+ await sleep(msToWait); // wait *just* a little longer than the timeout in the component
15
+ });
16
+ };
17
+ const LIMIT = 5;
18
+ const clickAllSlides = async (t, container, accumulator = 0) => {
19
+ if (accumulator === LIMIT)
20
+ return;
21
+ // last one needs to wait for more calculations && components updates
22
+ if (accumulator === 4)
23
+ await act(async () => {
24
+ await sleep(1000);
25
+ });
26
+ const validateButton = container.querySelectorAll(`[data-name="slide-validate-button-${accumulator}"]`);
27
+ t.truthy(elementExists(validateButton));
28
+ await act(async () => {
29
+ await fireEvent.click(validateButton[0]);
30
+ });
31
+ const nextButton = container.querySelectorAll(`[data-name="next-question-button-${accumulator}"]`);
32
+ t.truthy(elementExists(nextButton));
33
+ await act(async () => {
34
+ await fireEvent.click(nextButton[0]);
35
+ });
36
+ await clickAllSlides(t, container, accumulator + 1);
37
+ };
38
+ const appOptions = {
39
+ token: process.env.API_TEST_TOKEN || '',
40
+ slide
41
+ };
42
+ test('should validate all the slides (all correct scenario)', async (t) => {
43
+ t.plan(13);
44
+ const { container } = render(React.createElement(AppReview, { options: appOptions, key: 0 }));
45
+ await waitForChanges(1000);
46
+ const wrapper = container.querySelector('[data-name="slides-revision-container"]');
47
+ t.truthy(wrapper);
48
+ const stackedSlidesContainer = wrapper.querySelector('[data-name="stacked-slides-container"]');
49
+ t.truthy(stackedSlidesContainer);
50
+ await clickAllSlides(t, container);
51
+ t.pass();
52
+ });
@@ -4,4 +4,3 @@ import { Action } from '../actions';
4
4
  import { StoreState } from '../types/store-state';
5
5
  declare const onStartApp: Middleware<{}, StoreState, Dispatch<Action>>;
6
6
  export default onStartApp;
7
- //# sourceMappingURL=on-start-app.d.ts.map
@@ -5,6 +5,8 @@ import { storeToken } from '../actions/token';
5
5
  import { storeFirstSlide } from '../actions/slides';
6
6
  const onStartApp = ({ dispatch }) => next => (action) => {
7
7
  if (action.type === START_APP) {
8
+ // eslint-disable-next-line no-warning-comments
9
+ // TODO: fetchProgression + fetchSlide à partir de la progression passée dans les options de l'app
8
10
  const { slide } = action.payload;
9
11
  if (slide) {
10
12
  const { token } = action.payload;
@@ -3,4 +3,3 @@ export declare type State = Array<unknown>;
3
3
  export declare const initialState: State;
4
4
  declare const reducer: (state: State, action: ReceivedCourse) => State;
5
5
  export default reducer;
6
- //# sourceMappingURL=courses.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { StoreToken } from '../actions/token';
2
+ import { IsFetching } from '../actions/data/is-fetching';
3
+ import { ValidateSlide } from '../actions/data/validate-slide';
4
+ import { DataState } from '../types/data';
5
+ declare type ApiActions = IsFetching | ValidateSlide | StoreToken;
6
+ declare const data: (state: DataState, action: ApiActions) => DataState;
7
+ export default data;
@@ -1,18 +1,25 @@
1
1
  import getOr from 'lodash/fp/getOr';
2
2
  import noop from 'lodash/fp/noop';
3
3
  import set from 'lodash/fp/set';
4
- import { IS_FETCHING_TRUE } from '../actions/api/is-fetching';
5
- import { VALIDATE_SLIDE } from '../actions/api/validate-slide';
4
+ import { STORE_TOKEN } from '../actions/token';
5
+ import { IS_FETCHING_TRUE } from '../actions/data/is-fetching';
6
+ import { VALIDATE_SLIDE } from '../actions/data/validate-slide';
7
+ import { setToken } from './token';
6
8
  const defaultState = {
7
- entities: { isFetching: true, slideValidationResult: null }
9
+ isFetching: true,
10
+ slideValidationResult: null,
11
+ token: null
8
12
  };
9
13
  // eslint-disable-next-line default-param-last
10
- const api = (state = defaultState, action) => {
14
+ const data = (state = defaultState, action) => {
11
15
  switch (action.type) {
16
+ case STORE_TOKEN: {
17
+ return setToken(action.payload, state);
18
+ }
12
19
  case VALIDATE_SLIDE: {
13
- const previousSlideNumber = getOr(-1, 'entities.slideValidationResult.slideNumber', state);
20
+ const previousSlideNumber = getOr(-1, 'slideValidationResult.slideNumber', state);
14
21
  // hard coded for now
15
- return set(['entities', 'slideValidationResult'], {
22
+ return set('slideValidationResult', {
16
23
  slideNumber: previousSlideNumber + 1,
17
24
  result: 'success',
18
25
  // exitNode
@@ -57,7 +64,7 @@ const api = (state = defaultState, action) => {
57
64
  }, state);
58
65
  }
59
66
  case IS_FETCHING_TRUE: {
60
- return set('entities.isFetching', true, state);
67
+ return set('isFetching', true, state);
61
68
  }
62
69
  // case VALIDATE_SLIDE_FAILURE: {
63
70
  // return set('entities.isFetching', false, state);
@@ -66,4 +73,4 @@ const api = (state = defaultState, action) => {
66
73
  return state;
67
74
  }
68
75
  };
69
- export default api;
76
+ export default data;
@@ -2,6 +2,5 @@ import { UpdateFinishedSlides } from '../actions/finished-slides';
2
2
  import { FinishedSlides } from '../types/finished-slides';
3
3
  export declare type State = FinishedSlides;
4
4
  export declare const initialState: State;
5
- declare const reducer: (state: FinishedSlides, action: UpdateFinishedSlides) => FinishedSlides;
5
+ declare const reducer: (state: State, action: UpdateFinishedSlides) => State;
6
6
  export default reducer;
7
- //# sourceMappingURL=finished-slides.d.ts.map
@@ -1,17 +1,27 @@
1
+ import forEach from 'lodash/fp/forEach';
1
2
  import { UPDATE_FINISHED_SLIDES } from '../actions/finished-slides';
2
- export const initialState = new Map();
3
+ import { slideNumbers } from '../common';
4
+ const _forEach = forEach.convert({
5
+ cap: false
6
+ });
7
+ export const initialState = {
8
+ slideNumbers
9
+ };
3
10
  // -----------------------------------------------------------------------------
4
11
  // eslint-disable-next-line default-param-last
5
12
  const reducer = (state = initialState, action) => {
6
13
  switch (action.type) {
7
14
  case UPDATE_FINISHED_SLIDES: {
15
+ const { slideNumbers: _slideNumbers, ...rest } = state;
8
16
  const { slideNumber, value } = action.payload;
9
- const _state = new Map();
10
- // eslint-disable-next-line fp/no-loops
11
- for (const [index, previousValue] of state) {
12
- _state.set(index, previousValue);
13
- }
14
- _state.set(slideNumber, value);
17
+ const _state = {
18
+ slideNumbers: _slideNumbers
19
+ };
20
+ _forEach((finishedSlide, index) => {
21
+ const previousValue = finishedSlide;
22
+ _state[index] = previousValue;
23
+ }, rest);
24
+ _state[slideNumber] = value;
15
25
  return _state;
16
26
  }
17
27
  default:
@@ -1,17 +1,12 @@
1
1
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
2
- api: import("../types/api").ApiState | {
3
- entities: {
4
- isFetching: boolean;
5
- slideValidationResult: any;
6
- };
7
- };
8
- courses: import("./courses").State;
9
- finishedSlides: import("../types/finished-slides").FinishedSlides;
10
- navigation: import("../types/states").NavigationState;
11
- reviewStatus: import("./review-status").State;
12
- slides: import("../types/slides").Slides;
13
- stepItems: import("../types/step-items").StepItems;
14
- token: string;
2
+ ui: import("redux").CombinedState<{
3
+ courses: import("./courses").State;
4
+ finishedSlides: import("../types/finished-slides").FinishedSlides;
5
+ navigation: import("../types/states").NavigationState;
6
+ reviewStatus: import("./review-status").State;
7
+ slides: import("../types/slides").Slides;
8
+ stepItems: import("../types/step-items").StepItems;
9
+ }>;
10
+ data: import("../types/data").DataState;
15
11
  }>, import("redux").AnyAction>;
16
12
  export default _default;
17
- //# sourceMappingURL=index.d.ts.map
@@ -1,19 +1,20 @@
1
1
  import { combineReducers } from 'redux';
2
- import api from './api';
2
+ import data from './data';
3
3
  import courses from './courses';
4
4
  import finishedSlides from './finished-slides';
5
5
  import navigation from './navigation';
6
6
  import reviewStatus from './review-status';
7
7
  import slides from './slides';
8
8
  import stepItems from './step-items';
9
- import token from './token';
10
- export default combineReducers({
11
- api,
9
+ const ui = combineReducers({
12
10
  courses,
13
11
  finishedSlides,
14
12
  navigation,
15
13
  reviewStatus,
16
14
  slides,
17
- stepItems,
18
- token
15
+ stepItems
16
+ });
17
+ export default combineReducers({
18
+ ui,
19
+ data
19
20
  });
@@ -6,4 +6,3 @@ export declare const initialState: State;
6
6
  declare const reducer: (state: State, action: NavigateTo | NavigateBack) => State;
7
7
  export declare const getCurrentViewName: (appState: StoreState) => ViewPath;
8
8
  export default reducer;
9
- //# sourceMappingURL=navigation.d.ts.map
@@ -19,6 +19,6 @@ const reducer = (state = initialState, action) => {
19
19
  }
20
20
  };
21
21
  // -----------------------------------------------------------------------------
22
- export const getCurrentViewName = (appState) => appState.navigation[appState.navigation.length - 1];
22
+ export const getCurrentViewName = (appState) => appState.ui.navigation[appState.ui.navigation.length - 1];
23
23
  // -----------------------------------------------------------------------------
24
24
  export default reducer;
@@ -3,4 +3,3 @@ export declare type State = 'finished' | 'ongoing';
3
3
  export declare const initialState: State;
4
4
  declare const reducer: (state: State, action: UpdateReviewStatus) => State;
5
5
  export default reducer;
6
- //# sourceMappingURL=review-status.d.ts.map
@@ -2,6 +2,5 @@ import { SlidesAction } from '../actions/slides';
2
2
  import { Slides } from '../types/slides';
3
3
  export declare type State = Slides;
4
4
  export declare const initialState: State;
5
- declare const reducer: (state: Slides, action: SlidesAction) => Slides;
5
+ declare const reducer: (state: State, action: SlidesAction) => State;
6
6
  export default reducer;
7
- //# sourceMappingURL=slides.d.ts.map