@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.
- package/es/actions/courses.d.ts +0 -1
- package/es/actions/{api → data}/is-fetching.d.ts +0 -1
- package/{lib/actions/api → es/actions/data}/validate-slide.d.ts +0 -1
- package/es/actions/finished-slides.d.ts +0 -1
- package/es/actions/index.d.ts +0 -1
- package/es/actions/navigation.d.ts +0 -1
- package/es/actions/review-status.d.ts +0 -1
- package/es/actions/slides.d.ts +0 -1
- package/es/actions/step-items.d.ts +0 -1
- package/es/actions/token.d.ts +0 -1
- package/es/common/index.d.ts +1 -1
- package/es/common/index.js +1 -0
- package/es/configure-store.d.ts +2 -3
- package/es/configure-store.js +3 -9
- package/es/fixtures/qcm-slide.d.ts +2 -0
- package/es/fixtures/qcm-slide.js +29 -0
- package/es/{temp-fixture.d.ts → fixtures/temp-fixture.d.ts} +1 -2
- package/es/helpers/css-register.js +2 -0
- package/es/index.d.ts +1 -3
- package/es/index.js +43 -27
- package/es/index.test.js +52 -0
- package/es/middlewares/on-start-app.d.ts +0 -1
- package/es/middlewares/on-start-app.js +2 -0
- package/es/reducers/courses.d.ts +0 -1
- package/es/reducers/data.d.ts +7 -0
- package/es/reducers/{api.js → data.js} +15 -8
- package/es/reducers/finished-slides.d.ts +1 -2
- package/es/reducers/finished-slides.js +17 -7
- package/es/reducers/index.d.ts +9 -14
- package/es/reducers/index.js +7 -6
- package/es/reducers/navigation.d.ts +0 -1
- package/es/reducers/navigation.js +1 -1
- package/es/reducers/review-status.d.ts +0 -1
- package/es/reducers/slides.d.ts +1 -2
- package/es/reducers/slides.js +37 -25
- package/es/reducers/step-items.d.ts +1 -2
- package/es/reducers/step-items.js +19 -12
- package/es/reducers/token.d.ts +4 -7
- package/es/reducers/token.js +3 -14
- package/es/services/fetch-demo.d.ts +0 -1
- package/es/services/fetch-demo.test.d.ts +0 -1
- package/es/services/fetch-responses.d.ts +0 -1
- package/es/services/fetch.mocks.d.ts +0 -1
- package/es/types/common.d.ts +0 -1
- package/es/types/data/index.d.ts +14 -0
- package/es/types/data/index.js +1 -0
- package/es/types/dispatchers.d.ts +1 -2
- package/es/types/finished-slides.d.ts +4 -2
- package/es/types/review-status.d.ts +0 -1
- package/es/types/slides.d.ts +4 -2
- package/es/types/states.d.ts +1 -3
- package/es/types/step-items.d.ts +4 -2
- package/es/types/store-state.d.ts +10 -10
- package/es/types/utils.d.ts +0 -1
- package/es/types/views.d.ts +9 -3
- package/lib/actions/courses.d.ts +0 -1
- package/lib/actions/{api → data}/is-fetching.d.ts +0 -1
- package/{es/actions/api → lib/actions/data}/validate-slide.d.ts +0 -1
- package/lib/actions/finished-slides.d.ts +0 -1
- package/lib/actions/index.d.ts +0 -1
- package/lib/actions/navigation.d.ts +0 -1
- package/lib/actions/review-status.d.ts +0 -1
- package/lib/actions/slides.d.ts +0 -1
- package/lib/actions/step-items.d.ts +0 -1
- package/lib/actions/token.d.ts +0 -1
- package/lib/common/index.d.ts +1 -1
- package/lib/common/index.js +1 -0
- package/lib/configure-store.d.ts +2 -3
- package/lib/configure-store.js +10 -66
- package/lib/fixtures/qcm-slide.d.ts +2 -0
- package/lib/fixtures/qcm-slide.js +29 -0
- package/lib/{temp-fixture.d.ts → fixtures/temp-fixture.d.ts} +1 -2
- package/lib/helpers/css-register.d.ts +1 -0
- package/lib/helpers/css-register.js +2 -0
- package/lib/index.d.ts +1 -3
- package/lib/index.js +52 -52
- package/lib/index.test.d.ts +1 -0
- package/lib/index.test.js +160 -0
- package/lib/middlewares/on-start-app.d.ts +0 -1
- package/lib/middlewares/on-start-app.js +2 -0
- package/lib/reducers/courses.d.ts +0 -1
- package/lib/reducers/courses.js +1 -17
- package/lib/reducers/data.d.ts +7 -0
- package/lib/reducers/{api.js → data.js} +15 -8
- package/lib/reducers/finished-slides.d.ts +1 -2
- package/lib/reducers/finished-slides.js +28 -45
- package/lib/reducers/index.d.ts +9 -14
- package/lib/reducers/index.js +7 -6
- package/lib/reducers/navigation.d.ts +0 -1
- package/lib/reducers/navigation.js +3 -19
- package/lib/reducers/review-status.d.ts +0 -1
- package/lib/reducers/slides.d.ts +1 -2
- package/lib/reducers/slides.js +58 -106
- package/lib/reducers/step-items.d.ts +1 -2
- package/lib/reducers/step-items.js +21 -52
- package/lib/reducers/token.d.ts +4 -7
- package/lib/reducers/token.js +3 -15
- package/lib/services/fetch-demo.d.ts +0 -1
- package/lib/services/fetch-demo.test.d.ts +0 -1
- package/lib/services/fetch-responses.d.ts +0 -1
- package/lib/services/fetch.mocks.d.ts +0 -1
- package/lib/types/common.d.ts +0 -1
- package/lib/types/data/index.d.ts +14 -0
- package/lib/types/data/index.js +1 -0
- package/lib/types/dispatchers.d.ts +1 -2
- package/lib/types/finished-slides.d.ts +4 -2
- package/lib/types/review-status.d.ts +0 -1
- package/lib/types/slides.d.ts +4 -2
- package/lib/types/states.d.ts +1 -3
- package/lib/types/step-items.d.ts +4 -2
- package/lib/types/store-state.d.ts +10 -10
- package/lib/types/utils.d.ts +0 -1
- package/lib/types/views.d.ts +9 -3
- package/package.json +10 -7
- package/src/common/index.ts +2 -0
- package/src/configure-store.ts +10 -20
- package/src/fixtures/qcm-slide.ts +31 -0
- package/src/{temp-fixture.ts → fixtures/temp-fixture.ts} +1 -1
- package/src/helpers/css-modules-require-hook.d.ts +4 -0
- package/src/helpers/css-register.ts +3 -0
- package/src/index.test.tsx +82 -0
- package/src/index.tsx +48 -34
- package/src/middlewares/on-start-app.ts +2 -0
- package/src/reducers/{api.ts → data.ts} +17 -14
- package/src/reducers/finished-slides.ts +22 -7
- package/src/reducers/index.ts +8 -6
- package/src/reducers/navigation.ts +1 -1
- package/src/reducers/slides.ts +38 -25
- package/src/reducers/step-items.ts +22 -12
- package/src/reducers/token.ts +5 -17
- package/src/types/data/index.ts +16 -0
- package/src/types/dispatchers.ts +1 -1
- package/src/types/finished-slides.ts +5 -2
- package/src/types/globals.d.ts +6 -0
- package/src/types/slides.ts +6 -3
- package/src/types/states.ts +1 -2
- package/src/types/step-items.ts +4 -1
- package/src/types/store-state.ts +11 -11
- package/src/types/views.tsx +9 -2
- package/es/actions/api/is-fetching.d.ts.map +0 -1
- package/es/actions/api/validate-slide.d.ts.map +0 -1
- package/es/actions/courses.d.ts.map +0 -1
- package/es/actions/finished-slides.d.ts.map +0 -1
- package/es/actions/index.d.ts.map +0 -1
- package/es/actions/navigation.d.ts.map +0 -1
- package/es/actions/review-status.d.ts.map +0 -1
- package/es/actions/slides.d.ts.map +0 -1
- package/es/actions/step-items.d.ts.map +0 -1
- package/es/actions/token.d.ts.map +0 -1
- package/es/common/index.d.ts.map +0 -1
- package/es/configure-store.d.ts.map +0 -1
- package/es/index.d.ts.map +0 -1
- package/es/middlewares/on-start-app.d.ts.map +0 -1
- package/es/reducers/api.d.ts +0 -12
- package/es/reducers/api.d.ts.map +0 -1
- package/es/reducers/courses.d.ts.map +0 -1
- package/es/reducers/finished-slides.d.ts.map +0 -1
- package/es/reducers/index.d.ts.map +0 -1
- package/es/reducers/navigation.d.ts.map +0 -1
- package/es/reducers/review-status.d.ts.map +0 -1
- package/es/reducers/slides.d.ts.map +0 -1
- package/es/reducers/step-items.d.ts.map +0 -1
- package/es/reducers/token.d.ts.map +0 -1
- package/es/services/fetch-demo.d.ts.map +0 -1
- package/es/services/fetch-demo.test.d.ts.map +0 -1
- package/es/services/fetch-responses.d.ts.map +0 -1
- package/es/services/fetch.mocks.d.ts.map +0 -1
- package/es/temp-fixture.d.ts.map +0 -1
- package/es/types/api/index.d.ts +0 -16
- package/es/types/api/index.d.ts.map +0 -1
- package/es/types/common.d.ts.map +0 -1
- package/es/types/dispatchers.d.ts.map +0 -1
- package/es/types/finished-slides.d.ts.map +0 -1
- package/es/types/review-status.d.ts.map +0 -1
- package/es/types/slides.d.ts.map +0 -1
- package/es/types/states.d.ts.map +0 -1
- package/es/types/step-items.d.ts.map +0 -1
- package/es/types/store-state.d.ts.map +0 -1
- package/es/types/utils.d.ts.map +0 -1
- package/es/types/views.d.ts.map +0 -1
- package/lib/actions/api/is-fetching.d.ts.map +0 -1
- package/lib/actions/api/validate-slide.d.ts.map +0 -1
- package/lib/actions/courses.d.ts.map +0 -1
- package/lib/actions/finished-slides.d.ts.map +0 -1
- package/lib/actions/index.d.ts.map +0 -1
- package/lib/actions/navigation.d.ts.map +0 -1
- package/lib/actions/review-status.d.ts.map +0 -1
- package/lib/actions/slides.d.ts.map +0 -1
- package/lib/actions/step-items.d.ts.map +0 -1
- package/lib/actions/token.d.ts.map +0 -1
- package/lib/common/index.d.ts.map +0 -1
- package/lib/configure-store.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/middlewares/on-start-app.d.ts.map +0 -1
- package/lib/reducers/api.d.ts +0 -12
- package/lib/reducers/api.d.ts.map +0 -1
- package/lib/reducers/courses.d.ts.map +0 -1
- package/lib/reducers/finished-slides.d.ts.map +0 -1
- package/lib/reducers/index.d.ts.map +0 -1
- package/lib/reducers/navigation.d.ts.map +0 -1
- package/lib/reducers/review-status.d.ts.map +0 -1
- package/lib/reducers/slides.d.ts.map +0 -1
- package/lib/reducers/step-items.d.ts.map +0 -1
- package/lib/reducers/token.d.ts.map +0 -1
- package/lib/services/fetch-demo.d.ts.map +0 -1
- package/lib/services/fetch-demo.test.d.ts.map +0 -1
- package/lib/services/fetch-responses.d.ts.map +0 -1
- package/lib/services/fetch.mocks.d.ts.map +0 -1
- package/lib/temp-fixture.d.ts.map +0 -1
- package/lib/types/api/index.d.ts +0 -16
- package/lib/types/api/index.d.ts.map +0 -1
- package/lib/types/common.d.ts.map +0 -1
- package/lib/types/dispatchers.d.ts.map +0 -1
- package/lib/types/finished-slides.d.ts.map +0 -1
- package/lib/types/review-status.d.ts.map +0 -1
- package/lib/types/slides.d.ts.map +0 -1
- package/lib/types/states.d.ts.map +0 -1
- package/lib/types/step-items.d.ts.map +0 -1
- package/lib/types/store-state.d.ts.map +0 -1
- package/lib/types/utils.d.ts.map +0 -1
- package/lib/types/views.d.ts.map +0 -1
- package/src/types/api/index.ts +0 -16
- /package/es/actions/{api → data}/is-fetching.js +0 -0
- /package/es/actions/{api → data}/validate-slide.js +0 -0
- /package/es/{temp-fixture.js → fixtures/temp-fixture.js} +0 -0
- /package/es/{types/api/index.js → helpers/css-register.d.ts} +0 -0
- /package/{lib/types/api/index.js → es/index.test.d.ts} +0 -0
- /package/lib/actions/{api → data}/is-fetching.js +0 -0
- /package/lib/actions/{api → data}/validate-slide.js +0 -0
- /package/lib/{temp-fixture.js → fixtures/temp-fixture.js} +0 -0
- /package/src/actions/{api → data}/is-fetching.ts +0 -0
- /package/src/actions/{api → data}/validate-slide.ts +0 -0
package/es/actions/courses.d.ts
CHANGED
package/es/actions/index.d.ts
CHANGED
|
@@ -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
|
package/es/actions/slides.d.ts
CHANGED
|
@@ -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
|
package/es/actions/token.d.ts
CHANGED
package/es/common/index.d.ts
CHANGED
package/es/common/index.js
CHANGED
package/es/configure-store.d.ts
CHANGED
|
@@ -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():
|
|
3
|
+
export default function configureStore(): Store<EmptyObject & StoreState, AnyAction> & {
|
|
4
4
|
dispatch: {};
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=configure-store.d.ts.map
|
|
5
|
+
};
|
package/es/configure-store.js
CHANGED
|
@@ -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
|
|
8
|
-
const
|
|
9
|
-
|
|
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,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 '
|
|
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
|
package/es/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
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/
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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;
|
package/es/index.test.js
ADDED
|
@@ -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
|
+
});
|
|
@@ -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;
|
package/es/reducers/courses.d.ts
CHANGED
|
@@ -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 {
|
|
5
|
-
import {
|
|
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
|
-
|
|
9
|
+
isFetching: true,
|
|
10
|
+
slideValidationResult: null,
|
|
11
|
+
token: null
|
|
8
12
|
};
|
|
9
13
|
// eslint-disable-next-line default-param-last
|
|
10
|
-
const
|
|
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, '
|
|
20
|
+
const previousSlideNumber = getOr(-1, 'slideValidationResult.slideNumber', state);
|
|
14
21
|
// hard coded for now
|
|
15
|
-
return set(
|
|
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('
|
|
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
|
|
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:
|
|
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
|
-
|
|
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 =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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:
|
package/es/reducers/index.d.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
package/es/reducers/index.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { combineReducers } from 'redux';
|
|
2
|
-
import
|
|
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
|
-
|
|
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
|
-
|
|
15
|
+
stepItems
|
|
16
|
+
});
|
|
17
|
+
export default combineReducers({
|
|
18
|
+
ui,
|
|
19
|
+
data
|
|
19
20
|
});
|
|
@@ -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;
|
package/es/reducers/slides.d.ts
CHANGED
|
@@ -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:
|
|
5
|
+
declare const reducer: (state: State, action: SlidesAction) => State;
|
|
6
6
|
export default reducer;
|
|
7
|
-
//# sourceMappingURL=slides.d.ts.map
|