@coorpacademy/app-review 0.1.14 → 0.1.16
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/api/fetch-skills.d.ts +4 -6
- package/es/actions/api/fetch-skills.js +7 -4
- package/es/actions/api/fetch-slide.d.ts +14 -7
- package/es/actions/api/fetch-slide.js +27 -4
- package/es/actions/api/post-progression.d.ts +4 -6
- package/es/actions/api/post-progression.js +13 -9
- package/es/actions/api/test/create-test-store.d.ts +5 -0
- package/es/actions/api/test/create-test-store.js +16 -0
- package/es/actions/api/test/fetch-skills.test.js +54 -0
- package/es/actions/api/test/fetch-slide.test.js +61 -0
- package/es/actions/api/test/post-progression.test.js +102 -0
- package/es/actions/index.d.ts +1 -10
- package/es/actions/ui/answers.d.ts +7 -0
- package/es/actions/ui/answers.js +7 -0
- package/es/actions/ui/is-fetching.js +0 -2
- package/es/actions/ui/slides.d.ts +26 -0
- package/es/actions/ui/slides.js +9 -0
- package/es/common/index.d.ts +3 -1
- package/es/common/index.js +3 -1
- package/es/fixtures/qcm-slide.d.ts +2 -2
- package/es/fixtures/temp-fixture.d.ts +2 -2
- package/es/index.js +22 -92
- package/es/reducers/data/index.d.ts +2 -2
- package/es/reducers/data/progression.d.ts +3 -16
- package/es/reducers/data/progression.js +3 -22
- package/es/reducers/data/slides.d.ts +5 -6
- package/es/reducers/data/slides.js +9 -108
- package/es/reducers/data/test/progression.test.js +38 -0
- package/es/reducers/data/test/skills.test.js +12 -0
- package/es/reducers/data/test/slides.test.js +20 -0
- package/es/reducers/data/test/token.test.js +11 -0
- package/es/reducers/index.d.ts +3 -4
- package/es/reducers/ui/answers.d.ts +4 -0
- package/es/reducers/ui/{review-status.js → answers.js} +3 -3
- package/es/reducers/ui/current-slide-ref.d.ts +4 -0
- package/es/reducers/ui/current-slide-ref.js +13 -0
- package/es/reducers/ui/index.d.ts +7 -10
- package/es/reducers/ui/index.js +4 -6
- package/es/reducers/ui/test/answers.test.js +11 -0
- package/es/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/es/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/es/reducers/ui/test/navigation.test.d.ts +1 -0
- package/es/reducers/ui/test/navigation.test.js +15 -0
- package/es/services/fetch-slide.js +1 -1
- package/es/services/index.js +3 -1
- package/es/services/post-answer.d.ts +2 -0
- package/es/services/post-answer.js +18 -0
- package/es/services/test/fetch-slide.test.d.ts +1 -0
- package/es/services/test/fetch-slide.test.js +22 -0
- package/es/services/test/post-answer.test.d.ts +1 -0
- package/es/services/test/post-answer.test.js +57 -0
- package/es/services/test/post-progression.test.js +14 -4
- package/es/test/util/services.mock.js +46 -4
- package/es/types/common.d.ts +61 -30
- package/es/types/common.js +0 -5
- package/es/types/slides.d.ts +0 -4
- package/{lib/types/views/skills.d.ts → es/views/skills/index.d.ts} +2 -0
- package/es/views/skills/index.js +25 -0
- package/es/views/slides/index.d.ts +79 -0
- package/es/views/slides/index.js +151 -0
- package/es/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/es/views/slides/map-api-slide-to-ui.js +172 -0
- package/es/views/slides/test/fixtures/free-text.d.ts +3 -0
- package/es/views/slides/test/fixtures/free-text.js +38 -0
- package/es/views/slides/test/fixtures/qcm-drag.d.ts +3 -0
- package/es/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/es/views/slides/test/fixtures/qcm-graphic.d.ts +3 -0
- package/es/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/es/views/slides/test/fixtures/qcm.d.ts +3 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm.js +37 -27
- package/es/views/slides/test/fixtures/select-template.d.ts +3 -0
- package/es/views/slides/test/fixtures/select-template.js +92 -0
- package/es/views/slides/test/fixtures/slider.d.ts +3 -0
- package/es/views/slides/test/fixtures/slider.js +36 -0
- package/es/views/slides/test/fixtures/text-template.d.ts +3 -0
- package/es/{helpers → views/slides}/test/fixtures/text-template.js +21 -11
- package/es/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/es/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/lib/actions/api/fetch-skills.d.ts +4 -6
- package/lib/actions/api/fetch-skills.js +55 -7
- package/lib/actions/api/fetch-slide.d.ts +14 -7
- package/lib/actions/api/fetch-slide.js +75 -7
- package/lib/actions/api/post-progression.d.ts +4 -6
- package/lib/actions/api/post-progression.js +63 -10
- package/lib/actions/api/test/create-test-store.d.ts +5 -0
- package/lib/actions/api/test/create-test-store.js +18 -0
- package/lib/actions/api/test/fetch-skills.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-skills.test.js +113 -0
- package/lib/actions/api/test/fetch-slide.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-slide.test.js +120 -0
- package/lib/actions/api/test/post-progression.test.d.ts +1 -0
- package/lib/actions/api/test/post-progression.test.js +160 -0
- package/lib/actions/index.d.ts +1 -10
- package/lib/actions/ui/answers.d.ts +7 -0
- package/lib/actions/ui/answers.js +9 -0
- package/lib/actions/ui/is-fetching.js +0 -2
- package/lib/actions/ui/slides.d.ts +26 -0
- package/lib/actions/ui/slides.js +9 -0
- package/lib/common/index.d.ts +3 -1
- package/lib/common/index.js +3 -1
- package/lib/fixtures/qcm-slide.d.ts +2 -2
- package/lib/fixtures/temp-fixture.d.ts +2 -2
- package/lib/index.js +33 -94
- package/lib/reducers/data/index.d.ts +2 -2
- package/lib/reducers/data/progression.d.ts +3 -16
- package/lib/reducers/data/progression.js +3 -22
- package/lib/reducers/data/slides.d.ts +5 -6
- package/lib/reducers/data/slides.js +9 -114
- package/lib/reducers/data/test/progression.test.d.ts +1 -0
- package/lib/reducers/data/test/progression.test.js +38 -0
- package/lib/reducers/data/test/skills.test.d.ts +1 -0
- package/lib/reducers/data/test/skills.test.js +12 -0
- package/lib/reducers/data/test/slides.test.d.ts +1 -0
- package/lib/reducers/data/test/slides.test.js +20 -0
- package/lib/reducers/data/test/token.test.d.ts +1 -0
- package/lib/reducers/data/test/token.test.js +11 -0
- package/lib/reducers/index.d.ts +3 -4
- package/lib/reducers/ui/answers.d.ts +4 -0
- package/lib/reducers/ui/{review-status.js → answers.js} +3 -3
- package/lib/reducers/ui/current-slide-ref.d.ts +4 -0
- package/lib/reducers/ui/current-slide-ref.js +14 -0
- package/lib/reducers/ui/index.d.ts +7 -10
- package/lib/reducers/ui/index.js +4 -6
- package/lib/reducers/ui/test/answers.test.d.ts +1 -0
- package/lib/reducers/ui/test/answers.test.js +11 -0
- package/lib/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/lib/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/lib/reducers/ui/test/navigation.test.d.ts +1 -0
- package/lib/reducers/ui/test/navigation.test.js +15 -0
- package/lib/services/fetch-slide.js +1 -1
- package/lib/services/index.js +3 -1
- package/lib/services/post-answer.d.ts +2 -0
- package/lib/services/post-answer.js +62 -0
- package/lib/services/test/fetch-slide.test.d.ts +1 -0
- package/lib/services/test/fetch-slide.test.js +76 -0
- package/lib/services/test/post-answer.test.d.ts +1 -0
- package/lib/services/test/post-answer.test.js +111 -0
- package/lib/services/test/post-progression.test.js +14 -4
- package/lib/test/util/services.mock.js +46 -4
- package/lib/types/common.d.ts +61 -30
- package/lib/types/common.js +0 -5
- package/lib/types/slides.d.ts +0 -4
- package/{es/types/views/skills.d.ts → lib/views/skills/index.d.ts} +2 -0
- package/lib/views/skills/index.js +25 -0
- package/lib/views/slides/index.d.ts +79 -0
- package/lib/views/slides/index.js +155 -0
- package/lib/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/lib/views/slides/map-api-slide-to-ui.js +178 -0
- package/lib/views/slides/test/fixtures/free-text.d.ts +3 -0
- package/lib/views/slides/test/fixtures/free-text.js +38 -0
- package/lib/views/slides/test/fixtures/qcm-drag.d.ts +3 -0
- package/lib/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +3 -0
- package/lib/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/lib/views/slides/test/fixtures/qcm.d.ts +3 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm.js +37 -27
- package/lib/views/slides/test/fixtures/select-template.d.ts +3 -0
- package/lib/views/slides/test/fixtures/select-template.js +92 -0
- package/lib/views/slides/test/fixtures/slider.d.ts +3 -0
- package/lib/views/slides/test/fixtures/slider.js +36 -0
- package/lib/views/slides/test/fixtures/text-template.d.ts +3 -0
- package/lib/{helpers → views/slides}/test/fixtures/text-template.js +21 -11
- package/lib/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/lib/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/package.json +4 -3
- package/src/actions/api/fetch-skills.ts +12 -12
- package/src/actions/api/fetch-slide.ts +38 -13
- package/src/actions/api/post-progression.ts +18 -22
- package/src/actions/api/test/create-test-store.ts +25 -0
- package/src/actions/api/test/fetch-skills.test.ts +70 -0
- package/src/actions/api/test/fetch-slide.test.ts +77 -0
- package/src/actions/api/test/post-progression.test.ts +119 -0
- package/src/actions/index.ts +1 -10
- package/src/actions/ui/answers.ts +16 -0
- package/src/actions/ui/is-fetching.ts +0 -6
- package/src/actions/ui/slides.ts +35 -0
- package/src/common/index.ts +7 -1
- package/src/fixtures/qcm-slide.ts +2 -2
- package/src/fixtures/temp-fixture.ts +2 -2
- package/src/index.tsx +26 -110
- package/src/reducers/data/index.ts +1 -1
- package/src/reducers/data/progression.ts +5 -40
- package/src/reducers/data/slides.ts +17 -125
- package/src/reducers/data/test/progression.test.ts +42 -0
- package/src/reducers/data/test/skills.test.ts +14 -0
- package/src/reducers/data/test/slides.test.ts +26 -0
- package/src/reducers/data/test/token.test.ts +13 -0
- package/src/reducers/ui/answers.ts +19 -0
- package/src/reducers/ui/current-slide-ref.ts +19 -0
- package/src/reducers/ui/index.ts +6 -9
- package/src/reducers/ui/test/answers.test.ts +13 -0
- package/src/reducers/ui/test/current-slide-ref.test.ts +14 -0
- package/src/reducers/ui/test/navigation.test.ts +19 -0
- package/src/services/fetch-slide.ts +1 -1
- package/src/services/index.ts +3 -1
- package/src/services/post-answer.ts +27 -0
- package/src/services/test/fetch-slide.test.ts +30 -0
- package/src/services/test/post-answer.test.ts +68 -0
- package/src/services/test/post-progression.test.ts +14 -4
- package/src/test/util/services.mock.ts +46 -4
- package/src/types/common.ts +77 -40
- package/src/types/slides.ts +0 -5
- package/src/views/skills/index.ts +56 -0
- package/src/views/slides/index.ts +251 -0
- package/src/views/slides/map-api-slide-to-ui.ts +251 -0
- package/src/views/slides/test/fixtures/free-text.ts +43 -0
- package/src/views/slides/test/fixtures/qcm-drag.ts +111 -0
- package/src/views/slides/test/fixtures/qcm-graphic.ts +94 -0
- package/src/{helpers → views/slides}/test/fixtures/qcm.ts +43 -33
- package/src/views/slides/test/fixtures/select-template.ts +98 -0
- package/src/views/slides/test/fixtures/slider.ts +41 -0
- package/src/{helpers → views/slides}/test/fixtures/text-template.ts +23 -14
- package/src/{helpers → views/slides}/test/map-api-slide-to-ui.test.ts +22 -20
- package/es/actions/data/slides.d.ts +0 -37
- package/es/actions/data/slides.js +0 -16
- package/es/actions/ui/finished-slides.d.ts +0 -10
- package/es/actions/ui/finished-slides.js +0 -8
- package/es/actions/ui/review-status.d.ts +0 -7
- package/es/actions/ui/review-status.js +0 -7
- package/es/actions/ui/step-items.d.ts +0 -24
- package/es/actions/ui/step-items.js +0 -11
- package/es/helpers/map-api-slide-to-ui.d.ts +0 -8
- package/es/helpers/map-api-slide-to-ui.js +0 -175
- package/es/helpers/test/fixtures/free-text.d.ts +0 -4
- package/es/helpers/test/fixtures/free-text.js +0 -24
- package/es/helpers/test/fixtures/qcm-drag.d.ts +0 -4
- package/es/helpers/test/fixtures/qcm-drag.js +0 -106
- package/es/helpers/test/fixtures/qcm-graphic.d.ts +0 -4
- package/es/helpers/test/fixtures/qcm-graphic.js +0 -70
- package/es/helpers/test/fixtures/qcm.d.ts +0 -4
- package/es/helpers/test/fixtures/select-template.d.ts +0 -4
- package/es/helpers/test/fixtures/select-template.js +0 -88
- package/es/helpers/test/fixtures/slider.d.ts +0 -4
- package/es/helpers/test/fixtures/slider.js +0 -27
- package/es/helpers/test/fixtures/text-template.d.ts +0 -4
- package/es/reducers/ui/finished-slides.d.ts +0 -7
- package/es/reducers/ui/finished-slides.js +0 -33
- package/es/reducers/ui/review-status.d.ts +0 -4
- package/es/reducers/ui/step-items.d.ts +0 -14
- package/es/reducers/ui/step-items.js +0 -74
- package/es/types/ui-progression.d.ts +0 -10
- package/es/types/views/slides.d.ts +0 -60
- package/lib/actions/data/slides.d.ts +0 -37
- package/lib/actions/data/slides.js +0 -16
- package/lib/actions/ui/finished-slides.d.ts +0 -10
- package/lib/actions/ui/finished-slides.js +0 -8
- package/lib/actions/ui/review-status.d.ts +0 -7
- package/lib/actions/ui/review-status.js +0 -7
- package/lib/actions/ui/step-items.d.ts +0 -24
- package/lib/actions/ui/step-items.js +0 -11
- package/lib/helpers/map-api-slide-to-ui.d.ts +0 -8
- package/lib/helpers/map-api-slide-to-ui.js +0 -181
- package/lib/helpers/test/fixtures/free-text.d.ts +0 -4
- package/lib/helpers/test/fixtures/free-text.js +0 -24
- package/lib/helpers/test/fixtures/qcm-drag.d.ts +0 -4
- package/lib/helpers/test/fixtures/qcm-drag.js +0 -106
- package/lib/helpers/test/fixtures/qcm-graphic.d.ts +0 -4
- package/lib/helpers/test/fixtures/qcm-graphic.js +0 -70
- package/lib/helpers/test/fixtures/qcm.d.ts +0 -4
- package/lib/helpers/test/fixtures/select-template.d.ts +0 -4
- package/lib/helpers/test/fixtures/select-template.js +0 -88
- package/lib/helpers/test/fixtures/slider.d.ts +0 -4
- package/lib/helpers/test/fixtures/slider.js +0 -27
- package/lib/helpers/test/fixtures/text-template.d.ts +0 -4
- package/lib/reducers/ui/finished-slides.d.ts +0 -7
- package/lib/reducers/ui/finished-slides.js +0 -45
- package/lib/reducers/ui/review-status.d.ts +0 -4
- package/lib/reducers/ui/step-items.d.ts +0 -14
- package/lib/reducers/ui/step-items.js +0 -86
- package/lib/types/ui-progression.d.ts +0 -10
- package/lib/types/views/slides.d.ts +0 -60
- package/src/actions/data/slides.ts +0 -65
- package/src/actions/ui/finished-slides.ts +0 -21
- package/src/actions/ui/review-status.ts +0 -19
- package/src/actions/ui/step-items.ts +0 -45
- package/src/helpers/map-api-slide-to-ui.ts +0 -253
- package/src/helpers/test/fixtures/free-text.ts +0 -28
- package/src/helpers/test/fixtures/qcm-drag.ts +0 -110
- package/src/helpers/test/fixtures/qcm-graphic.ts +0 -74
- package/src/helpers/test/fixtures/select-template.ts +0 -92
- package/src/helpers/test/fixtures/slider.ts +0 -31
- package/src/reducers/ui/finished-slides.ts +0 -52
- package/src/reducers/ui/review-status.ts +0 -19
- package/src/reducers/ui/step-items.ts +0 -116
- package/src/types/ui-progression.ts +0 -25
- package/src/types/views/skills.ts +0 -27
- package/src/types/views/slides.ts +0 -65
- /package/es/{helpers/test/map-api-slide-to-ui.test.d.ts → actions/api/test/fetch-skills.test.d.ts} +0 -0
- /package/es/{types/ui-progression.js → actions/api/test/fetch-slide.test.d.ts} +0 -0
- /package/es/{types/views/skills.js → actions/api/test/post-progression.test.d.ts} +0 -0
- /package/es/{types/views/slides.js → reducers/data/test/progression.test.d.ts} +0 -0
- /package/{lib/helpers/test/map-api-slide-to-ui.test.d.ts → es/reducers/data/test/skills.test.d.ts} +0 -0
- /package/{lib/types/ui-progression.js → es/reducers/data/test/slides.test.d.ts} +0 -0
- /package/{lib/types/views/skills.js → es/reducers/data/test/token.test.d.ts} +0 -0
- /package/{lib/types/views/slides.js → es/reducers/ui/test/answers.test.d.ts} +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AnyAction } from 'redux';
|
|
1
|
+
import { Dispatch } from 'redux';
|
|
3
2
|
import type { StoreState } from '../../reducers';
|
|
4
3
|
import { Options, Skill } from '../../types/common';
|
|
5
4
|
export declare const SKILLS_FETCH_REQUEST: "@@skills/FETCH_REQUEST";
|
|
6
5
|
export declare const SKILLS_FETCH_SUCCESS: "@@skills/FETCH_SUCCESS";
|
|
7
6
|
export declare const SKILLS_FETCH_FAILURE: "@@skills/FETCH_FAILURE";
|
|
8
|
-
export
|
|
7
|
+
export declare type ReceivedSkills = {
|
|
9
8
|
type: '@@skills/FETCH_SUCCESS';
|
|
10
9
|
payload: Skill[];
|
|
11
|
-
}
|
|
12
|
-
export declare
|
|
13
|
-
export declare const fetchSkills: (token: string) => FetchSkillsAction;
|
|
10
|
+
};
|
|
11
|
+
export declare const fetchSkills: (token: string) => (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
|
|
@@ -2,7 +2,10 @@ import buildTask from '@coorpacademy/redux-task';
|
|
|
2
2
|
export const SKILLS_FETCH_REQUEST = '@@skills/FETCH_REQUEST';
|
|
3
3
|
export const SKILLS_FETCH_SUCCESS = '@@skills/FETCH_SUCCESS';
|
|
4
4
|
export const SKILLS_FETCH_FAILURE = '@@skills/FETCH_FAILURE';
|
|
5
|
-
export const fetchSkills = (token) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export const fetchSkills = (token) => async (dispatch, getState, { services }) => {
|
|
6
|
+
const action = buildTask({
|
|
7
|
+
types: [SKILLS_FETCH_REQUEST, SKILLS_FETCH_SUCCESS, SKILLS_FETCH_FAILURE],
|
|
8
|
+
task: () => services.fetchSkills(token)
|
|
9
|
+
});
|
|
10
|
+
await dispatch(action);
|
|
11
|
+
};
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ThunkAction } from 'redux-thunk';
|
|
1
|
+
import type { Dispatch } from 'redux';
|
|
3
2
|
import type { StoreState } from '../../reducers';
|
|
4
|
-
import { Options, SlideFromAPI } from '../../types/common';
|
|
3
|
+
import type { Options, SlideFromAPI } from '../../types/common';
|
|
5
4
|
export declare const SLIDE_FETCH_REQUEST: "@@slides/FETCH_REQUEST";
|
|
6
5
|
export declare const SLIDE_FETCH_SUCCESS: "@@slides/FETCH_SUCCESS";
|
|
7
6
|
export declare const SLIDE_FETCH_FAILURE: "@@slides/FETCH_FAILURE";
|
|
8
|
-
export
|
|
7
|
+
export declare type FetchSlide = {
|
|
8
|
+
type: typeof SLIDE_FETCH_REQUEST;
|
|
9
|
+
meta: {
|
|
10
|
+
slideRef: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare type ReceivedSlide = {
|
|
9
14
|
type: typeof SLIDE_FETCH_SUCCESS;
|
|
10
15
|
payload: SlideFromAPI;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
meta: {
|
|
17
|
+
slideRef: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare const fetchSlide: (slideRef: string, token: string) => (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import buildTask from '@coorpacademy/redux-task';
|
|
2
|
+
import get from 'lodash/fp/get';
|
|
3
|
+
import has from 'lodash/fp/has';
|
|
4
|
+
import isEmpty from 'lodash/fp/isEmpty';
|
|
5
|
+
import { setCurrentSlide } from '../ui/slides';
|
|
2
6
|
export const SLIDE_FETCH_REQUEST = '@@slides/FETCH_REQUEST';
|
|
3
7
|
export const SLIDE_FETCH_SUCCESS = '@@slides/FETCH_SUCCESS';
|
|
4
8
|
export const SLIDE_FETCH_FAILURE = '@@slides/FETCH_FAILURE';
|
|
5
|
-
export const fetchSlide = (slideRef, token) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
export const fetchSlide = (slideRef, token) => async (dispatch, getState, { services }) => {
|
|
10
|
+
const action = buildTask({
|
|
11
|
+
types: [SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS, SLIDE_FETCH_FAILURE],
|
|
12
|
+
bailout: (state) => {
|
|
13
|
+
return has(`data.slide.${slideRef}`, state);
|
|
14
|
+
},
|
|
15
|
+
task: () => {
|
|
16
|
+
return services.fetchSlide(slideRef, token);
|
|
17
|
+
},
|
|
18
|
+
meta: { slideRef }
|
|
19
|
+
});
|
|
20
|
+
const response = await dispatch(action);
|
|
21
|
+
if (response.type === SLIDE_FETCH_SUCCESS) {
|
|
22
|
+
const slideFromAPI = response.payload;
|
|
23
|
+
if (!slideFromAPI)
|
|
24
|
+
throw new Error('Slide not found');
|
|
25
|
+
const state = getState();
|
|
26
|
+
const slides = get('data.progression.state.slides', state);
|
|
27
|
+
if (isEmpty(slides)) {
|
|
28
|
+
dispatch(setCurrentSlide(slideFromAPI));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ThunkAction } from 'redux-thunk';
|
|
1
|
+
import type { Dispatch } from 'redux';
|
|
3
2
|
import { Options, ProgressionFromAPI } from '../../types/common';
|
|
4
3
|
import type { StoreState } from '../../reducers';
|
|
5
4
|
export declare const POST_PROGRESSION_REQUEST: "@@progression/POST_REQUEST";
|
|
6
5
|
export declare const POST_PROGRESSION_SUCCESS: "@@progression/POST_SUCCESS";
|
|
7
6
|
export declare const POST_PROGRESSION_FAILURE: "@@progression/POST_FAILURE";
|
|
8
|
-
export
|
|
7
|
+
export declare type ReceiveProgression = {
|
|
9
8
|
type: typeof POST_PROGRESSION_SUCCESS;
|
|
10
9
|
payload: ProgressionFromAPI;
|
|
11
|
-
}
|
|
12
|
-
export declare
|
|
13
|
-
export declare const postProgression: (skillRef: string, token: string) => PostProgressionAction;
|
|
10
|
+
};
|
|
11
|
+
export declare const postProgression: (skillRef: string, token: string) => (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
|
|
@@ -3,13 +3,17 @@ import { fetchSlide } from './fetch-slide';
|
|
|
3
3
|
export const POST_PROGRESSION_REQUEST = '@@progression/POST_REQUEST';
|
|
4
4
|
export const POST_PROGRESSION_SUCCESS = '@@progression/POST_SUCCESS';
|
|
5
5
|
export const POST_PROGRESSION_FAILURE = '@@progression/POST_FAILURE';
|
|
6
|
-
export const postProgression = (skillRef, token) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
export const postProgression = (skillRef, token) => async (dispatch, getState, { services }) => {
|
|
7
|
+
const action = buildTask({
|
|
8
|
+
types: [POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS, POST_PROGRESSION_FAILURE],
|
|
9
|
+
task: () => {
|
|
10
|
+
return services.postProgression(skillRef, token);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
const response = await dispatch(action);
|
|
14
|
+
if (response.type === POST_PROGRESSION_SUCCESS) {
|
|
15
|
+
const progression = response.payload;
|
|
16
|
+
const slideRef = progression.state.nextContent.ref;
|
|
17
|
+
await dispatch(fetchSlide(slideRef, token));
|
|
14
18
|
}
|
|
15
|
-
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExecutionContext } from 'ava';
|
|
2
|
+
import { AnyAction, Store } from 'redux';
|
|
3
|
+
import { StoreState } from '../../../reducers';
|
|
4
|
+
import { Services } from '../../../types/common';
|
|
5
|
+
export declare const createTestStore: (t: ExecutionContext, initialState: StoreState, services: Services, actions: AnyAction[]) => Store;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import constant from 'lodash/fp/constant';
|
|
2
|
+
import { applyMiddleware, compose, createStore } from 'redux';
|
|
3
|
+
import thunk from 'redux-thunk';
|
|
4
|
+
import rootReducer from '../../../reducers';
|
|
5
|
+
const assertActionsMiddleware = (t, ACTIONS) => constant((next) => (action) => {
|
|
6
|
+
const expectedAction = ACTIONS.shift();
|
|
7
|
+
if (!expectedAction)
|
|
8
|
+
throw new Error(`Missing {type: "${action.type}"} action`);
|
|
9
|
+
t.deepEqual(action, expectedAction);
|
|
10
|
+
return next(action);
|
|
11
|
+
});
|
|
12
|
+
export const createTestStore = (t, initialState, services, actions) => {
|
|
13
|
+
const thunkMiddleware = thunk.withExtraArgument({ services });
|
|
14
|
+
const enhancer = compose(applyMiddleware(thunkMiddleware, assertActionsMiddleware(t, actions)));
|
|
15
|
+
return createStore(rootReducer, initialState, enhancer);
|
|
16
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import { fetchSkills, SKILLS_FETCH_FAILURE, SKILLS_FETCH_REQUEST, SKILLS_FETCH_SUCCESS } from '../fetch-skills';
|
|
3
|
+
import { services as mockedServices } from '../../../test/util/services.mock';
|
|
4
|
+
import { createTestStore } from './create-test-store';
|
|
5
|
+
const initialState = {
|
|
6
|
+
data: {
|
|
7
|
+
progression: null,
|
|
8
|
+
slides: {},
|
|
9
|
+
skills: [],
|
|
10
|
+
token: '1234'
|
|
11
|
+
},
|
|
12
|
+
ui: {
|
|
13
|
+
currentSlideRef: '',
|
|
14
|
+
navigation: [],
|
|
15
|
+
answers: []
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
test('should dispatch SKILLS_FETCH_SUCCESS actions when fetchSkills return a list of skills', async (t) => {
|
|
19
|
+
const services = {
|
|
20
|
+
...mockedServices,
|
|
21
|
+
fetchSkills: token => {
|
|
22
|
+
t.is(token, '1234');
|
|
23
|
+
return Promise.resolve([]);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const expectedActions = [
|
|
27
|
+
{ type: SKILLS_FETCH_REQUEST },
|
|
28
|
+
{
|
|
29
|
+
type: SKILLS_FETCH_SUCCESS,
|
|
30
|
+
payload: []
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
34
|
+
await dispatch(fetchSkills('1234'));
|
|
35
|
+
});
|
|
36
|
+
test('should dispatch SKILLS_FETCH_FAILURE action when fetchSkills fails', async (t) => {
|
|
37
|
+
const services = {
|
|
38
|
+
...mockedServices,
|
|
39
|
+
fetchSkills: token => {
|
|
40
|
+
t.is(token, '1234');
|
|
41
|
+
return Promise.reject(new Error('unexpected'));
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const expectedActions = [
|
|
45
|
+
{ type: SKILLS_FETCH_REQUEST },
|
|
46
|
+
{
|
|
47
|
+
type: SKILLS_FETCH_FAILURE,
|
|
48
|
+
payload: new Error('unexpected'),
|
|
49
|
+
error: true
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
53
|
+
await dispatch(fetchSkills('1234'));
|
|
54
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import { fetchSlide, SLIDE_FETCH_FAILURE, SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../fetch-slide';
|
|
3
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
4
|
+
import { services as mockedServices } from '../../../test/util/services.mock';
|
|
5
|
+
import { SET_CURRENT_SLIDE } from '../../ui/slides';
|
|
6
|
+
import { createTestStore } from './create-test-store';
|
|
7
|
+
const initialState = {
|
|
8
|
+
data: {
|
|
9
|
+
progression: null,
|
|
10
|
+
slides: {},
|
|
11
|
+
skills: [],
|
|
12
|
+
token: '1234'
|
|
13
|
+
},
|
|
14
|
+
ui: {
|
|
15
|
+
currentSlideRef: '',
|
|
16
|
+
navigation: [],
|
|
17
|
+
answers: []
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
test('should dispatch FETCH_SUCCESS and SET_CURRENT_SLIDE actions when fetchSlide return a slide', async (t) => {
|
|
21
|
+
const services = {
|
|
22
|
+
...mockedServices,
|
|
23
|
+
fetchSlide: (slideRef, token) => {
|
|
24
|
+
t.is(token, '1234');
|
|
25
|
+
t.is(slideRef, 'sli_VJYjJnJhg');
|
|
26
|
+
return Promise.resolve(freeTextSlide);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const expectedActions = [
|
|
30
|
+
{ type: SLIDE_FETCH_REQUEST, meta: { slideRef: 'sli_VJYjJnJhg' } },
|
|
31
|
+
{
|
|
32
|
+
type: SLIDE_FETCH_SUCCESS,
|
|
33
|
+
meta: { slideRef: 'sli_VJYjJnJhg' },
|
|
34
|
+
payload: freeTextSlide
|
|
35
|
+
},
|
|
36
|
+
{ type: SET_CURRENT_SLIDE, payload: freeTextSlide }
|
|
37
|
+
];
|
|
38
|
+
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
39
|
+
await dispatch(fetchSlide('sli_VJYjJnJhg', '1234'));
|
|
40
|
+
});
|
|
41
|
+
test('should dispatch SLIDE_FETCH_FAILURE action when fetchSlide fails', async (t) => {
|
|
42
|
+
const services = {
|
|
43
|
+
...mockedServices,
|
|
44
|
+
fetchSlide: (slideRef, token) => {
|
|
45
|
+
t.is(token, '1234');
|
|
46
|
+
t.is(slideRef, 'slide_ref');
|
|
47
|
+
return Promise.reject(new Error('error'));
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const expectedActions = [
|
|
51
|
+
{ type: SLIDE_FETCH_REQUEST, meta: { slideRef: 'slide_ref' } },
|
|
52
|
+
{
|
|
53
|
+
type: SLIDE_FETCH_FAILURE,
|
|
54
|
+
meta: { slideRef: 'slide_ref' },
|
|
55
|
+
payload: new Error('error'),
|
|
56
|
+
error: true
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
60
|
+
await dispatch(fetchSlide('slide_ref', '1234'));
|
|
61
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import { postProgression, POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS, POST_PROGRESSION_FAILURE } from '../post-progression';
|
|
3
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
4
|
+
import { services as mockedServices } from '../../../test/util/services.mock';
|
|
5
|
+
import { SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../fetch-slide';
|
|
6
|
+
import { SET_CURRENT_SLIDE } from '../../ui/slides';
|
|
7
|
+
import { createTestStore } from './create-test-store';
|
|
8
|
+
const initialState = {
|
|
9
|
+
data: {
|
|
10
|
+
progression: null,
|
|
11
|
+
slides: {},
|
|
12
|
+
skills: [],
|
|
13
|
+
token: '1234'
|
|
14
|
+
},
|
|
15
|
+
ui: {
|
|
16
|
+
currentSlideRef: '',
|
|
17
|
+
navigation: [],
|
|
18
|
+
answers: []
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
test('should dispatch POST_PROGRESSION_SUCCESS and SLIDE_FETCH_REQUEST actions when postProgression return a progression', async (t) => {
|
|
22
|
+
const progression = {
|
|
23
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
24
|
+
content: {
|
|
25
|
+
ref: '_skill-ref',
|
|
26
|
+
type: 'skill'
|
|
27
|
+
},
|
|
28
|
+
engine: {
|
|
29
|
+
ref: 'review'
|
|
30
|
+
},
|
|
31
|
+
state: {
|
|
32
|
+
allAnswers: [],
|
|
33
|
+
isCorrect: true,
|
|
34
|
+
nextContent: {
|
|
35
|
+
ref: 'sli_VJYjJnJhg',
|
|
36
|
+
type: 'slide'
|
|
37
|
+
},
|
|
38
|
+
pendingSlides: [],
|
|
39
|
+
slides: [],
|
|
40
|
+
step: {
|
|
41
|
+
current: 1
|
|
42
|
+
},
|
|
43
|
+
stars: 0
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const services = {
|
|
47
|
+
...mockedServices,
|
|
48
|
+
postProgression: (skillRef, token) => {
|
|
49
|
+
t.is(token, '1234');
|
|
50
|
+
t.is(skillRef, 'skill_12345');
|
|
51
|
+
return Promise.resolve(progression);
|
|
52
|
+
},
|
|
53
|
+
fetchSlide: (slideRef, token) => {
|
|
54
|
+
t.is(token, '1234');
|
|
55
|
+
t.is(slideRef, 'sli_VJYjJnJhg');
|
|
56
|
+
return Promise.resolve(freeTextSlide);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const expectedActions = [
|
|
60
|
+
{ type: POST_PROGRESSION_REQUEST },
|
|
61
|
+
{
|
|
62
|
+
type: POST_PROGRESSION_SUCCESS,
|
|
63
|
+
payload: progression
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: SLIDE_FETCH_REQUEST,
|
|
67
|
+
meta: {
|
|
68
|
+
slideRef: 'sli_VJYjJnJhg'
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: SLIDE_FETCH_SUCCESS,
|
|
73
|
+
meta: {
|
|
74
|
+
slideRef: 'sli_VJYjJnJhg'
|
|
75
|
+
},
|
|
76
|
+
payload: freeTextSlide
|
|
77
|
+
},
|
|
78
|
+
{ type: SET_CURRENT_SLIDE, payload: freeTextSlide }
|
|
79
|
+
];
|
|
80
|
+
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
81
|
+
await dispatch(postProgression('skill_12345', '1234'));
|
|
82
|
+
});
|
|
83
|
+
test('should dispatch POST_PROGRESSION_FAILURE action when postProgression fails', async (t) => {
|
|
84
|
+
const services = {
|
|
85
|
+
...mockedServices,
|
|
86
|
+
postProgression: (skillRef, token) => {
|
|
87
|
+
t.is(token, '1234');
|
|
88
|
+
t.is(skillRef, 'skill_12345');
|
|
89
|
+
return Promise.reject(new Error('error'));
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const expectedActions = [
|
|
93
|
+
{ type: POST_PROGRESSION_REQUEST },
|
|
94
|
+
{
|
|
95
|
+
type: POST_PROGRESSION_FAILURE,
|
|
96
|
+
payload: new Error('error'),
|
|
97
|
+
error: true
|
|
98
|
+
}
|
|
99
|
+
];
|
|
100
|
+
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
101
|
+
await dispatch(postProgression('skill_12345', '1234'));
|
|
102
|
+
});
|
package/es/actions/index.d.ts
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import { updateSlidesOnValidation, updateSlidesOnNext, validateSlide } from './data/slides';
|
|
2
1
|
import { StoreToken } from './data/token';
|
|
3
|
-
import { updateFinishedSlides } from './ui/finished-slides';
|
|
4
2
|
import { navigateBack, navigateTo, NavigateBack, NavigateTo, StartApp } from './ui/navigation';
|
|
5
|
-
import { updateReviewStatus } from './ui/review-status';
|
|
6
|
-
import { updateStepItemsOnValidation, updateStepItemsOnNext } from './ui/step-items';
|
|
7
3
|
import { ReceivedSlide } from './api/fetch-slide';
|
|
8
4
|
import { ReceiveProgression } from './api/post-progression';
|
|
9
5
|
import { ReceivedSkills } from './api/fetch-skills';
|
|
6
|
+
import { validateSlide } from './ui/slides';
|
|
10
7
|
export declare type Action = NavigateBack | NavigateTo | ReceivedSkills | StartApp | ReceivedSlide | StoreToken | ReceiveProgression;
|
|
11
8
|
export declare type Dispatchers = {
|
|
12
9
|
navigateTo: typeof navigateTo;
|
|
13
10
|
navigateBack: typeof navigateBack;
|
|
14
11
|
validateSlide: typeof validateSlide;
|
|
15
|
-
updateSlidesOnValidation: typeof updateSlidesOnValidation;
|
|
16
|
-
updateSlidesOnNext: typeof updateSlidesOnNext;
|
|
17
|
-
updateReviewStatus: typeof updateReviewStatus;
|
|
18
|
-
updateStepItemsOnValidation: typeof updateStepItemsOnValidation;
|
|
19
|
-
updateStepItemsOnNext: typeof updateStepItemsOnNext;
|
|
20
|
-
updateFinishedSlides: typeof updateFinishedSlides;
|
|
21
12
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Dispatch } from 'redux';
|
|
2
|
+
export declare const EDIT_BASIC: "@@answer/EDIT_BASIC";
|
|
3
|
+
export declare type EditBasicAction = {
|
|
4
|
+
type: typeof EDIT_BASIC;
|
|
5
|
+
payload: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare const editAnswer: (answer: string) => (dispatch: Dispatch) => EditBasicAction;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
// -----------------------------------------------------------------------------
|
|
2
1
|
export const START_FETCHING = '@@ui/START_FETCHING';
|
|
3
2
|
export const STOP_FETCHING = '@@ui/STOP_FETCHING';
|
|
4
|
-
// -----------------------------------------------------------------------------
|
|
5
3
|
export const startFetching = () => ({ type: START_FETCHING });
|
|
6
4
|
export const stopFetching = () => ({ type: STOP_FETCHING });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SlideFromAPI } from '../../types/common';
|
|
2
|
+
import { AnswerUI } from '../../types/slides';
|
|
3
|
+
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
4
|
+
export declare type Slide = {
|
|
5
|
+
questionText?: string;
|
|
6
|
+
answerUI?: AnswerUI;
|
|
7
|
+
hidden?: boolean;
|
|
8
|
+
position: number;
|
|
9
|
+
animationType?: SlideUIAnimations;
|
|
10
|
+
isCorrect?: boolean;
|
|
11
|
+
endReview?: boolean;
|
|
12
|
+
nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
|
|
13
|
+
};
|
|
14
|
+
export declare const SET_CURRENT_SLIDE: "@@slide/SET_CURRENT_SLIDE";
|
|
15
|
+
export declare type SetCurrentSlide = {
|
|
16
|
+
type: typeof SET_CURRENT_SLIDE;
|
|
17
|
+
payload: SlideFromAPI;
|
|
18
|
+
};
|
|
19
|
+
export declare const setCurrentSlide: (payload: SlideFromAPI) => SetCurrentSlide;
|
|
20
|
+
export declare const VALIDATE_SLIDE = "@@slide/VALIDATE";
|
|
21
|
+
export declare type ValidateSlide = {
|
|
22
|
+
type: typeof VALIDATE_SLIDE;
|
|
23
|
+
};
|
|
24
|
+
export declare const validateSlide: () => ValidateSlide;
|
|
25
|
+
export declare type UISlidesAction = SetCurrentSlide;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const SET_CURRENT_SLIDE = '@@slide/SET_CURRENT_SLIDE';
|
|
2
|
+
export const setCurrentSlide = (payload) => ({
|
|
3
|
+
type: SET_CURRENT_SLIDE,
|
|
4
|
+
payload
|
|
5
|
+
});
|
|
6
|
+
export const VALIDATE_SLIDE = '@@slide/VALIDATE';
|
|
7
|
+
export const validateSlide = () => ({
|
|
8
|
+
type: VALIDATE_SLIDE
|
|
9
|
+
});
|
package/es/common/index.d.ts
CHANGED
|
@@ -5,4 +5,6 @@ export declare const VIEWS: {
|
|
|
5
5
|
readonly onboarding: 'onboarding';
|
|
6
6
|
readonly slides: 'slides';
|
|
7
7
|
};
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const slideIndexes: readonly ["0", "1", "2", "3", "4"];
|
|
9
|
+
export declare type SlideIndexes = typeof slideIndexes[number];
|
|
10
|
+
export declare const indexToString: (index: number) => SlideIndexes;
|
package/es/common/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toString from 'lodash/fp/toString';
|
|
1
2
|
export const TOTAL_SLIDES_STACK = 5;
|
|
2
3
|
export const HIGHEST_INDEX = TOTAL_SLIDES_STACK - 1;
|
|
3
4
|
export const VIEWS = {
|
|
@@ -5,4 +6,5 @@ export const VIEWS = {
|
|
|
5
6
|
onboarding: 'onboarding',
|
|
6
7
|
slides: 'slides'
|
|
7
8
|
};
|
|
8
|
-
export const
|
|
9
|
+
export const slideIndexes = ['0', '1', '2', '3', '4'];
|
|
10
|
+
export const indexToString = (index) => _toString(index);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UISlide } from '../types/
|
|
2
|
-
export declare const slide: UISlide
|
|
1
|
+
import { UISlide } from '../types/common';
|
|
2
|
+
export declare const slide: Pick<UISlide, 'questionText' | 'answerUI'>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SlidesViewProps } from '../
|
|
2
|
-
export declare const correctionPopinProps:
|
|
1
|
+
import { SlidesViewProps, CorrectionPopinProps } from '../views/slides';
|
|
2
|
+
export declare const correctionPopinProps: CorrectionPopinProps;
|
|
3
3
|
export declare const congratsProps: SlidesViewProps['congratsProps'];
|