@coorpacademy/app-review 0.1.16 → 0.1.18
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 +3 -3
- package/es/actions/api/fetch-skills.js +7 -2
- package/es/actions/api/fetch-slide.d.ts +1 -1
- package/es/actions/api/fetch-slide.js +3 -1
- package/es/actions/api/post-answer.d.ts +14 -0
- package/es/actions/api/post-answer.js +25 -0
- package/es/actions/api/post-progression.d.ts +3 -3
- package/es/actions/api/post-progression.js +5 -2
- package/es/actions/api/test/fetch-skills.test.js +7 -4
- package/es/actions/api/test/fetch-slide.test.js +7 -4
- package/es/actions/api/test/post-answer.test.d.ts +1 -0
- package/es/actions/api/test/post-answer.test.js +82 -0
- package/es/actions/api/test/post-progression.test.js +7 -4
- package/es/actions/data/test/token.test.d.ts +1 -0
- package/es/actions/data/test/token.test.js +25 -0
- package/es/actions/index.d.ts +1 -8
- package/es/actions/{api/test → test}/create-test-store.d.ts +2 -2
- package/es/actions/{api/test → test}/create-test-store.js +1 -1
- package/es/actions/ui/answers.d.ts +17 -3
- package/es/actions/ui/answers.js +41 -3
- package/es/actions/ui/slides.d.ts +0 -5
- package/es/actions/ui/slides.js +0 -4
- package/es/actions/ui/test/answers.test.d.ts +1 -0
- package/es/actions/ui/test/answers.test.js +100 -0
- package/es/actions/ui/test/slides.test.d.ts +1 -0
- package/es/actions/ui/test/slides.test.js +26 -0
- package/es/common/index.d.ts +0 -3
- package/es/common/index.js +0 -4
- package/es/index.js +1 -3
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +3 -3
- package/es/reducers/data/progression.js +2 -5
- package/es/reducers/data/slides.d.ts +2 -3
- package/es/reducers/data/test/progression.test.js +12 -27
- package/es/reducers/index.d.ts +2 -1
- package/es/reducers/ui/answers.d.ts +2 -2
- package/es/reducers/ui/answers.js +4 -8
- package/es/reducers/ui/index.d.ts +4 -1
- package/es/reducers/ui/index.js +3 -1
- package/es/reducers/ui/slide.d.ts +8 -0
- package/es/reducers/ui/slide.js +26 -0
- package/es/reducers/ui/test/answers.test.js +23 -3
- package/es/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/es/reducers/ui/test/navigation.test.js +5 -5
- package/es/reducers/ui/test/slide.test.d.ts +1 -0
- package/es/reducers/ui/test/slide.test.js +12 -0
- package/es/test/util/services.mock.d.ts +3 -1
- package/es/test/util/services.mock.js +89 -72
- package/es/types/common.d.ts +0 -25
- package/es/views/skills/index.d.ts +1 -1
- package/es/views/skills/index.js +0 -3
- package/es/views/skills/test/skills.test.d.ts +1 -0
- package/es/views/skills/test/skills.test.js +94 -0
- package/es/views/slides/index.d.ts +13 -2
- package/es/views/slides/index.js +19 -15
- package/es/views/slides/map-api-slide-to-ui.js +65 -68
- package/es/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/es/views/slides/test/fixtures/slider.d.ts +2 -1
- package/es/views/slides/test/fixtures/template.d.ts +4 -0
- package/{lib/views/slides/test/fixtures/select-template.js → es/views/slides/test/fixtures/template.js} +82 -4
- package/es/views/slides/test/index.test.d.ts +1 -0
- package/es/views/slides/test/index.test.js +473 -0
- package/es/views/slides/test/map-api-slide-to-ui.test.js +4 -10
- package/es/views/slides/test/slide.template.on-change.test.d.ts +1 -0
- package/es/views/slides/test/slide.template.on-change.test.js +79 -0
- package/lib/actions/api/fetch-skills.d.ts +3 -3
- package/lib/actions/api/fetch-skills.js +22 -19
- package/lib/actions/api/fetch-slide.d.ts +1 -1
- package/lib/actions/api/fetch-slide.js +3 -1
- package/lib/actions/api/post-answer.d.ts +14 -0
- package/lib/actions/api/post-answer.js +75 -0
- package/lib/actions/api/post-progression.d.ts +3 -3
- package/lib/actions/api/post-progression.js +6 -3
- package/lib/actions/api/test/fetch-skills.test.js +7 -4
- package/lib/actions/api/test/fetch-slide.test.js +7 -4
- package/lib/actions/api/test/post-answer.test.d.ts +1 -0
- package/lib/actions/api/test/post-answer.test.js +145 -0
- package/lib/actions/api/test/post-progression.test.js +7 -4
- package/lib/actions/data/test/token.test.d.ts +1 -0
- package/lib/actions/data/test/token.test.js +70 -0
- package/lib/actions/index.d.ts +1 -8
- package/lib/actions/{api/test → test}/create-test-store.d.ts +2 -2
- package/lib/actions/{api/test → test}/create-test-store.js +1 -1
- package/lib/actions/ui/answers.d.ts +17 -3
- package/lib/actions/ui/answers.js +50 -3
- package/lib/actions/ui/slides.d.ts +0 -5
- package/lib/actions/ui/slides.js +0 -4
- package/lib/actions/ui/test/answers.test.d.ts +1 -0
- package/lib/actions/ui/test/answers.test.js +190 -0
- package/lib/actions/ui/test/slides.test.d.ts +1 -0
- package/lib/actions/ui/test/slides.test.js +71 -0
- package/lib/common/index.d.ts +0 -3
- package/lib/common/index.js +0 -4
- package/lib/index.js +1 -3
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +3 -3
- package/lib/reducers/data/progression.js +2 -5
- package/lib/reducers/data/slides.d.ts +2 -3
- package/lib/reducers/data/test/progression.test.js +12 -27
- package/lib/reducers/index.d.ts +2 -1
- package/lib/reducers/ui/answers.d.ts +2 -2
- package/lib/reducers/ui/answers.js +4 -8
- package/lib/reducers/ui/index.d.ts +4 -1
- package/lib/reducers/ui/index.js +3 -1
- package/lib/reducers/ui/slide.d.ts +8 -0
- package/lib/reducers/ui/slide.js +27 -0
- package/lib/reducers/ui/test/answers.test.js +23 -3
- package/lib/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/lib/reducers/ui/test/navigation.test.js +5 -5
- package/lib/reducers/ui/test/slide.test.d.ts +1 -0
- package/lib/reducers/ui/test/slide.test.js +12 -0
- package/lib/test/util/services.mock.d.ts +3 -1
- package/lib/test/util/services.mock.js +89 -72
- package/lib/types/common.d.ts +0 -25
- package/lib/views/skills/index.d.ts +1 -1
- package/lib/views/skills/index.js +0 -3
- package/lib/views/skills/test/skills.test.d.ts +1 -0
- package/lib/views/skills/test/skills.test.js +94 -0
- package/lib/views/slides/index.d.ts +13 -2
- package/lib/views/slides/index.js +19 -15
- package/lib/views/slides/map-api-slide-to-ui.js +106 -99
- package/lib/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/lib/views/slides/test/fixtures/slider.d.ts +2 -1
- package/lib/views/slides/test/fixtures/template.d.ts +4 -0
- package/{es/views/slides/test/fixtures/select-template.js → lib/views/slides/test/fixtures/template.js} +82 -4
- package/lib/views/slides/test/index.test.d.ts +1 -0
- package/lib/views/slides/test/index.test.js +473 -0
- package/lib/views/slides/test/map-api-slide-to-ui.test.js +4 -10
- package/lib/views/slides/test/slide.template.on-change.test.d.ts +1 -0
- package/lib/views/slides/test/slide.template.on-change.test.js +82 -0
- package/package.json +6 -5
- package/src/actions/api/fetch-skills.ts +18 -11
- package/src/actions/api/fetch-slide.ts +3 -1
- package/src/actions/api/post-answer.ts +44 -0
- package/src/actions/api/post-progression.ts +7 -4
- package/src/actions/api/test/fetch-skills.test.ts +9 -6
- package/src/actions/api/test/fetch-slide.test.ts +9 -6
- package/src/actions/api/test/post-answer.test.ts +101 -0
- package/src/actions/api/test/post-progression.test.ts +9 -6
- package/src/actions/data/test/token.test.ts +29 -0
- package/src/actions/index.ts +1 -17
- package/src/actions/{api/test → test}/create-test-store.ts +2 -2
- package/src/actions/ui/answers.ts +55 -6
- package/src/actions/ui/slides.ts +1 -8
- package/src/actions/ui/test/answers.test.ts +115 -0
- package/src/actions/ui/test/slides.test.ts +30 -0
- package/src/common/index.ts +0 -7
- package/src/index.tsx +1 -3
- package/src/reducers/data/progression.ts +4 -7
- package/src/reducers/data/slides.ts +2 -3
- package/src/reducers/data/test/progression.test.ts +15 -31
- package/src/reducers/ui/answers.ts +5 -9
- package/src/reducers/ui/index.ts +4 -1
- package/src/reducers/ui/slide.ts +43 -0
- package/src/reducers/ui/test/answers.test.ts +29 -4
- package/src/reducers/ui/test/current-slide-ref.test.ts +1 -1
- package/src/reducers/ui/test/navigation.test.ts +5 -5
- package/src/reducers/ui/test/slide.test.ts +15 -0
- package/src/test/util/services.mock.ts +94 -73
- package/src/types/common.ts +0 -30
- package/src/views/skills/index.ts +1 -5
- package/src/views/skills/test/skills.test.ts +101 -0
- package/src/views/slides/index.ts +38 -23
- package/src/views/slides/map-api-slide-to-ui.ts +146 -113
- package/src/views/slides/test/fixtures/free-text.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-drag.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-graphic.ts +2 -1
- package/src/views/slides/test/fixtures/qcm.ts +2 -1
- package/src/views/slides/test/fixtures/slider.ts +2 -1
- package/src/views/slides/test/fixtures/{select-template.ts → template.ts} +84 -5
- package/src/views/slides/test/index.test.ts +493 -0
- package/src/views/slides/test/map-api-slide-to-ui.test.ts +6 -11
- package/src/views/slides/test/slide.template.on-change.test.ts +92 -0
- package/es/fixtures/qcm-slide.d.ts +0 -2
- package/es/fixtures/qcm-slide.js +0 -33
- package/es/fixtures/temp-fixture.d.ts +0 -3
- package/es/fixtures/temp-fixture.js +0 -84
- package/es/views/slides/test/fixtures/select-template.d.ts +0 -3
- package/es/views/slides/test/fixtures/text-template.d.ts +0 -3
- package/es/views/slides/test/fixtures/text-template.js +0 -58
- package/lib/fixtures/qcm-slide.d.ts +0 -2
- package/lib/fixtures/qcm-slide.js +0 -33
- package/lib/fixtures/temp-fixture.d.ts +0 -3
- package/lib/fixtures/temp-fixture.js +0 -84
- package/lib/views/slides/test/fixtures/select-template.d.ts +0 -3
- package/lib/views/slides/test/fixtures/text-template.d.ts +0 -3
- package/lib/views/slides/test/fixtures/text-template.js +0 -58
- package/src/fixtures/qcm-slide.ts +0 -35
- package/src/fixtures/temp-fixture.ts +0 -94
- package/src/views/slides/test/fixtures/text-template.ts +0 -61
package/es/common/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import _toString from 'lodash/fp/toString';
|
|
2
|
-
export const TOTAL_SLIDES_STACK = 5;
|
|
3
|
-
export const HIGHEST_INDEX = TOTAL_SLIDES_STACK - 1;
|
|
4
1
|
export const VIEWS = {
|
|
5
2
|
skills: 'skills',
|
|
6
3
|
onboarding: 'onboarding',
|
|
7
4
|
slides: 'slides'
|
|
8
5
|
};
|
|
9
6
|
export const slideIndexes = ['0', '1', '2', '3', '4'];
|
|
10
|
-
export const indexToString = (index) => _toString(index);
|
package/es/index.js
CHANGED
|
@@ -51,9 +51,7 @@ const AppReview = ({ options }) => {
|
|
|
51
51
|
const skillRef = get('skillRef', options);
|
|
52
52
|
/* ThunkAction is not assignable to parameter of type 'AnyAction'
|
|
53
53
|
ts problem is described here = https://github.com/reduxjs/redux-thunk/issues/333 */
|
|
54
|
-
skillRef
|
|
55
|
-
? store.dispatch(postProgression(skillRef, token))
|
|
56
|
-
: store.dispatch(fetchSkills(token));
|
|
54
|
+
skillRef ? store.dispatch(postProgression(skillRef)) : store.dispatch(fetchSkills);
|
|
57
55
|
}, [options, store]);
|
|
58
56
|
useEffect(() => {
|
|
59
57
|
if (store === null)
|
|
@@ -14,5 +14,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
14
14
|
skills: SkillsState;
|
|
15
15
|
slides: SlidesState;
|
|
16
16
|
token: TokenState;
|
|
17
|
-
}>, import("../../actions/api/post-progression").
|
|
17
|
+
}>, import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
|
|
18
18
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { PostAnswerSuccessAction } from '../../actions/api/post-answer';
|
|
2
|
+
import { ReceivedProgression } from '../../actions/api/post-progression';
|
|
3
3
|
import { ProgressionFromAPI } from '../../types/common';
|
|
4
4
|
export declare type ProgressionState = ProgressionFromAPI | null;
|
|
5
|
-
declare const reducer: (state: ProgressionState | undefined, action:
|
|
5
|
+
declare const reducer: (state: ProgressionState | undefined, action: ReceivedProgression | PostAnswerSuccessAction) => ProgressionState;
|
|
6
6
|
export default reducer;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { POST_ANSWER_SUCCESS } from '../../actions/api/post-answer';
|
|
2
2
|
import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
3
3
|
const reducer = (
|
|
4
4
|
// eslint-disable-next-line default-param-last
|
|
5
5
|
state = null, action) => {
|
|
6
6
|
switch (action.type) {
|
|
7
|
-
case
|
|
8
|
-
// TODO: fix on VALIDATE ticket -> launch a POST PROGRESSION
|
|
9
|
-
return state;
|
|
10
|
-
}
|
|
7
|
+
case POST_ANSWER_SUCCESS:
|
|
11
8
|
case POST_PROGRESSION_SUCCESS: {
|
|
12
9
|
const progression = action.payload;
|
|
13
10
|
return progression;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ValidateSlide } from '../../actions/ui/slides';
|
|
2
1
|
import { ReceivedSlide, FetchSlide } from '../../actions/api/fetch-slide';
|
|
3
2
|
import { SlideFromAPI } from '../../types/common';
|
|
4
|
-
export declare type SlidesAction = FetchSlide | ReceivedSlide
|
|
5
|
-
export declare type SlidesState = Record<string, SlideFromAPI>;
|
|
3
|
+
export declare type SlidesAction = FetchSlide | ReceivedSlide;
|
|
4
|
+
export declare type SlidesState = Record<string, SlideFromAPI | null>;
|
|
6
5
|
export declare const initialState: SlidesState;
|
|
7
6
|
declare const reducer: (state: SlidesState | undefined, action: SlidesAction) => SlidesState;
|
|
8
7
|
export default reducer;
|
|
@@ -1,38 +1,23 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import reducer from '../progression';
|
|
3
3
|
import { POST_PROGRESSION_SUCCESS } from '../../../actions/api/post-progression';
|
|
4
|
-
|
|
4
|
+
import { POST_ANSWER_SUCCESS } from '../../../actions/api/post-answer';
|
|
5
|
+
import { postAnswerResponse, postProgressionResponse } from '../../../test/util/services.mock';
|
|
6
|
+
test('should have initial value', t => {
|
|
5
7
|
const state = reducer(undefined, {});
|
|
6
8
|
t.is(state, null);
|
|
7
9
|
});
|
|
8
10
|
test('should set the value of POST_PROGRESSION_SUCCESS action', t => {
|
|
9
|
-
const progression = {
|
|
10
|
-
_id: '62b1d1087aa12f00253f40ee',
|
|
11
|
-
content: {
|
|
12
|
-
ref: '_skill-ref',
|
|
13
|
-
type: 'skill'
|
|
14
|
-
},
|
|
15
|
-
engine: {
|
|
16
|
-
ref: 'review'
|
|
17
|
-
},
|
|
18
|
-
state: {
|
|
19
|
-
allAnswers: [],
|
|
20
|
-
isCorrect: true,
|
|
21
|
-
nextContent: {
|
|
22
|
-
ref: 'sli_N1XACJobn',
|
|
23
|
-
type: 'slide'
|
|
24
|
-
},
|
|
25
|
-
pendingSlides: [],
|
|
26
|
-
slides: [],
|
|
27
|
-
step: {
|
|
28
|
-
current: 1
|
|
29
|
-
},
|
|
30
|
-
stars: 0
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
11
|
const state = reducer(null, {
|
|
34
12
|
type: POST_PROGRESSION_SUCCESS,
|
|
35
|
-
payload:
|
|
13
|
+
payload: postProgressionResponse
|
|
36
14
|
});
|
|
37
|
-
t.deepEqual(state,
|
|
15
|
+
t.deepEqual(state, postProgressionResponse);
|
|
16
|
+
});
|
|
17
|
+
test('should set the value of POST_ANSWER_SUCCESS action', t => {
|
|
18
|
+
const state = reducer(null, {
|
|
19
|
+
type: POST_ANSWER_SUCCESS,
|
|
20
|
+
payload: postAnswerResponse
|
|
21
|
+
});
|
|
22
|
+
t.deepEqual(state, postAnswerResponse);
|
|
38
23
|
});
|
package/es/reducers/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
15
15
|
currentSlideRef: string;
|
|
16
16
|
navigation: import("./ui/navigation").NavigationState;
|
|
17
17
|
answers: import("./ui/answers").AnswerState;
|
|
18
|
+
slide: import("./ui/slide").UISlideState;
|
|
18
19
|
}>;
|
|
19
|
-
}>, import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-progression").
|
|
20
|
+
}>, import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction>;
|
|
20
21
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EditAnswerAction } from '../../actions/ui/answers';
|
|
2
2
|
export declare type AnswerState = string[];
|
|
3
|
-
declare const reducer: (state: AnswerState | undefined, action:
|
|
3
|
+
declare const reducer: (state: AnswerState | undefined, action: EditAnswerAction) => AnswerState;
|
|
4
4
|
export default reducer;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { includes, values } from 'lodash/fp';
|
|
2
|
+
import { ANSWER_EDIT } from '../../actions/ui/answers';
|
|
3
|
+
const ANSWER_EDIT_ACTIONS = values(ANSWER_EDIT);
|
|
2
4
|
const reducer = (
|
|
3
5
|
// eslint-disable-next-line default-param-last
|
|
4
6
|
state = [], action) => {
|
|
5
|
-
|
|
6
|
-
case EDIT_BASIC: {
|
|
7
|
-
return action.payload;
|
|
8
|
-
}
|
|
9
|
-
default:
|
|
10
|
-
return state;
|
|
11
|
-
}
|
|
7
|
+
return includes(action.type, ANSWER_EDIT_ACTIONS) ? action.payload : state;
|
|
12
8
|
};
|
|
13
9
|
export default reducer;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { CurrentSlideRefState } from './current-slide-ref';
|
|
2
2
|
import { NavigationState } from './navigation';
|
|
3
3
|
import { AnswerState } from './answers';
|
|
4
|
+
import { UISlideState } from './slide';
|
|
4
5
|
export declare type UIState = {
|
|
5
6
|
currentSlideRef: CurrentSlideRefState;
|
|
6
7
|
navigation: NavigationState;
|
|
7
8
|
answers: AnswerState;
|
|
9
|
+
slide: UISlideState;
|
|
8
10
|
};
|
|
9
11
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
10
12
|
currentSlideRef: string;
|
|
11
13
|
navigation: NavigationState;
|
|
12
14
|
answers: AnswerState;
|
|
13
|
-
|
|
15
|
+
slide: UISlideState;
|
|
16
|
+
}>, import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction>;
|
|
14
17
|
export default _default;
|
package/es/reducers/ui/index.js
CHANGED
|
@@ -2,8 +2,10 @@ import { combineReducers } from 'redux';
|
|
|
2
2
|
import currentSlideRef from './current-slide-ref';
|
|
3
3
|
import navigation from './navigation';
|
|
4
4
|
import answers from './answers';
|
|
5
|
+
import slide from './slide';
|
|
5
6
|
export default combineReducers({
|
|
6
7
|
currentSlideRef,
|
|
7
8
|
navigation,
|
|
8
|
-
answers
|
|
9
|
+
answers,
|
|
10
|
+
slide
|
|
9
11
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EditAnswerAction } from '../../actions/ui/answers';
|
|
2
|
+
import { PostAnswerRequestAction } from '../../actions/api/post-answer';
|
|
3
|
+
export declare type UISlideState = {
|
|
4
|
+
validateButton: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const initialState: UISlideState;
|
|
7
|
+
declare const reducer: (state: UISlideState | undefined, action: PostAnswerRequestAction | EditAnswerAction) => UISlideState;
|
|
8
|
+
export default reducer;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import compact from 'lodash/fp/compact';
|
|
2
|
+
import isEmpty from 'lodash/fp/isEmpty';
|
|
3
|
+
import pipe from 'lodash/fp/pipe';
|
|
4
|
+
import { EDIT_BASIC, EDIT_QCM, EDIT_QCM_DRAG, EDIT_QCM_GRAPHIC, EDIT_SLIDER, EDIT_TEMPLATE } from '../../actions/ui/answers';
|
|
5
|
+
import { POST_ANSWER_REQUEST } from '../../actions/api/post-answer';
|
|
6
|
+
export const initialState = { validateButton: false };
|
|
7
|
+
const reducer = (
|
|
8
|
+
// eslint-disable-next-line default-param-last
|
|
9
|
+
state = initialState, action) => {
|
|
10
|
+
switch (action.type) {
|
|
11
|
+
case EDIT_QCM:
|
|
12
|
+
case EDIT_QCM_GRAPHIC:
|
|
13
|
+
case EDIT_QCM_DRAG:
|
|
14
|
+
case EDIT_TEMPLATE:
|
|
15
|
+
case EDIT_BASIC:
|
|
16
|
+
case EDIT_SLIDER: {
|
|
17
|
+
return pipe(compact, isEmpty)(action.payload) ? initialState : { validateButton: true };
|
|
18
|
+
}
|
|
19
|
+
case POST_ANSWER_REQUEST: {
|
|
20
|
+
return initialState;
|
|
21
|
+
}
|
|
22
|
+
default:
|
|
23
|
+
return state;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export default reducer;
|
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import reducer from '../answers';
|
|
3
|
-
import {
|
|
4
|
-
test('should have
|
|
3
|
+
import { ANSWER_EDIT } from '../../../actions/ui/answers';
|
|
4
|
+
test('should have initial value', t => {
|
|
5
5
|
const state = reducer(undefined, {});
|
|
6
6
|
t.deepEqual(state, []);
|
|
7
7
|
});
|
|
8
8
|
test('should set the value of EDIT_BASIC action', t => {
|
|
9
|
-
const state = reducer([], { type:
|
|
9
|
+
const state = reducer([], { type: ANSWER_EDIT.basic, payload: ['value'] });
|
|
10
10
|
t.deepEqual(state, ['value']);
|
|
11
11
|
});
|
|
12
|
+
test('should set the value of EDIT_QCM action', t => {
|
|
13
|
+
const state = reducer([], { type: ANSWER_EDIT.qcm, payload: ['value1', 'value2'] });
|
|
14
|
+
t.deepEqual(state, ['value1', 'value2']);
|
|
15
|
+
});
|
|
16
|
+
test('should set the value of EDIT_QCM_GRAPHIC action', t => {
|
|
17
|
+
const state = reducer([], { type: ANSWER_EDIT.qcmGraphic, payload: ['True', 'False'] });
|
|
18
|
+
t.deepEqual(state, ['True', 'False']);
|
|
19
|
+
});
|
|
20
|
+
test('should set the value of EDIT_QCM_DRAG action', t => {
|
|
21
|
+
const state = reducer([], { type: ANSWER_EDIT.qcmDrag, payload: ['value1', 'value2'] });
|
|
22
|
+
t.deepEqual(state, ['value1', 'value2']);
|
|
23
|
+
});
|
|
24
|
+
test('should set the value of EDIT_SLIDER action', t => {
|
|
25
|
+
const state = reducer([], { type: ANSWER_EDIT.slider, payload: ['5'] });
|
|
26
|
+
t.deepEqual(state, ['5']);
|
|
27
|
+
});
|
|
28
|
+
test('should set the value of EDIT_TEMPLATE action', t => {
|
|
29
|
+
const state = reducer([], { type: ANSWER_EDIT.template, payload: ['value1', 'value2'] });
|
|
30
|
+
t.deepEqual(state, ['value1', 'value2']);
|
|
31
|
+
});
|
|
@@ -2,7 +2,7 @@ import test from 'ava';
|
|
|
2
2
|
import reducer from '../current-slide-ref';
|
|
3
3
|
import { SET_CURRENT_SLIDE } from '../../../actions/ui/slides';
|
|
4
4
|
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
5
|
-
test('should have
|
|
5
|
+
test('should have initial value', t => {
|
|
6
6
|
const state = reducer(undefined, {});
|
|
7
7
|
t.is(state, '');
|
|
8
8
|
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import reducer from '../navigation';
|
|
3
|
-
import {
|
|
4
|
-
test('should have
|
|
3
|
+
import { navigateBack, navigateTo } from '../../../actions/ui/navigation';
|
|
4
|
+
test('should have initial value', t => {
|
|
5
5
|
const state = reducer(undefined, {});
|
|
6
6
|
t.deepEqual(state, []);
|
|
7
7
|
});
|
|
8
8
|
test('should set the value of NAVIGATE_TO and NAVIGATE_BACK action', t => {
|
|
9
|
-
const state = reducer([],
|
|
9
|
+
const state = reducer([], navigateTo('loader'));
|
|
10
10
|
t.deepEqual(state, ['loader']);
|
|
11
|
-
const updatedState = reducer(state,
|
|
11
|
+
const updatedState = reducer(state, navigateTo('skills'));
|
|
12
12
|
t.deepEqual(updatedState, ['loader', 'skills']);
|
|
13
|
-
const _updatedState = reducer(updatedState,
|
|
13
|
+
const _updatedState = reducer(updatedState, navigateBack());
|
|
14
14
|
t.deepEqual(_updatedState, ['loader']);
|
|
15
15
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer, { initialState } from '../slide';
|
|
3
|
+
import { EDIT_BASIC } from '../../../actions/ui/answers';
|
|
4
|
+
test('should use initial state if no answers are found when an EditAnswerAction is received', t => {
|
|
5
|
+
const state = reducer(undefined, { type: EDIT_BASIC, payload: [''] });
|
|
6
|
+
t.truthy(state);
|
|
7
|
+
t.false(state.validateButton);
|
|
8
|
+
});
|
|
9
|
+
test('should return state directly when there is no corresponding action handler + have an initial state', t => {
|
|
10
|
+
const state = reducer(undefined, { type: 'NOPE' });
|
|
11
|
+
t.deepEqual(state, initialState);
|
|
12
|
+
});
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import { Services } from '../../types/common';
|
|
1
|
+
import { ProgressionFromAPI, Services } from '../../types/common';
|
|
2
|
+
export declare const postProgressionResponse: ProgressionFromAPI;
|
|
3
|
+
export declare const postAnswerResponse: ProgressionFromAPI;
|
|
2
4
|
export declare const services: Services;
|
|
@@ -1,80 +1,97 @@
|
|
|
1
|
+
import { qcmSlide } from '../../views/slides/test/fixtures/qcm';
|
|
2
|
+
import { qcmGraphicSlide } from '../../views/slides/test/fixtures/qcm-graphic';
|
|
1
3
|
import { freeTextSlide } from '../../views/slides/test/fixtures/free-text';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
import { sliderSlide } from '../../views/slides/test/fixtures/slider';
|
|
5
|
+
import { templateSlide } from '../../views/slides/test/fixtures/template';
|
|
6
|
+
const getSlideFixture = (ref) => {
|
|
7
|
+
switch (ref) {
|
|
8
|
+
case qcmSlide.universalRef:
|
|
9
|
+
return qcmSlide;
|
|
10
|
+
case qcmGraphicSlide.universalRef:
|
|
11
|
+
return qcmGraphicSlide;
|
|
12
|
+
case freeTextSlide.universalRef:
|
|
13
|
+
return freeTextSlide;
|
|
14
|
+
case templateSlide.universalRef:
|
|
15
|
+
return templateSlide;
|
|
16
|
+
default:
|
|
17
|
+
return sliderSlide;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const fetchSkillsResponse = [
|
|
21
|
+
{
|
|
22
|
+
skillRef: '_skill-ref',
|
|
23
|
+
slidesToReview: 2,
|
|
24
|
+
name: 'skill-test',
|
|
25
|
+
custom: false
|
|
18
26
|
},
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
{
|
|
28
|
+
skillRef: '_skill-ref-2',
|
|
29
|
+
slidesToReview: 2,
|
|
30
|
+
name: 'skill-test-2',
|
|
31
|
+
custom: true
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
export const postProgressionResponse = {
|
|
35
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
36
|
+
content: {
|
|
37
|
+
ref: '_skill-ref',
|
|
38
|
+
type: 'skill'
|
|
21
39
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
});
|
|
40
|
+
engine: {
|
|
41
|
+
ref: 'review'
|
|
42
|
+
},
|
|
43
|
+
state: {
|
|
44
|
+
allAnswers: [],
|
|
45
|
+
isCorrect: true,
|
|
46
|
+
nextContent: {
|
|
47
|
+
ref: 'sli_VJYjJnJhg',
|
|
48
|
+
type: 'slide'
|
|
49
|
+
},
|
|
50
|
+
pendingSlides: [],
|
|
51
|
+
slides: [],
|
|
52
|
+
step: {
|
|
53
|
+
current: 1
|
|
54
|
+
},
|
|
55
|
+
stars: 0
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
export const postAnswerResponse = {
|
|
59
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
60
|
+
content: {
|
|
61
|
+
ref: '_skill-ref',
|
|
62
|
+
type: 'skill'
|
|
47
63
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
engine: {
|
|
56
|
-
ref: 'review'
|
|
57
|
-
},
|
|
58
|
-
state: {
|
|
59
|
-
allAnswers: [
|
|
60
|
-
{
|
|
61
|
-
slideRef: 'sli_N1XACJobn',
|
|
62
|
-
isCorrect: true,
|
|
63
|
-
answer: ['Le créateur peut fixer un pourcentage pour chaque transaction future']
|
|
64
|
-
}
|
|
65
|
-
],
|
|
64
|
+
engine: {
|
|
65
|
+
ref: 'review'
|
|
66
|
+
},
|
|
67
|
+
state: {
|
|
68
|
+
allAnswers: [
|
|
69
|
+
{
|
|
70
|
+
slideRef: 'sli_VJYjJnJhg',
|
|
66
71
|
isCorrect: true,
|
|
67
|
-
|
|
68
|
-
ref: 'sli_VkSQroQnx',
|
|
69
|
-
type: 'slide'
|
|
70
|
-
},
|
|
71
|
-
pendingSlides: [],
|
|
72
|
-
slides: ['sli_N1XACJobn'],
|
|
73
|
-
step: {
|
|
74
|
-
current: 2
|
|
75
|
-
},
|
|
76
|
-
stars: 4
|
|
72
|
+
answer: ['Benchmark']
|
|
77
73
|
}
|
|
78
|
-
|
|
74
|
+
],
|
|
75
|
+
isCorrect: true,
|
|
76
|
+
nextContent: {
|
|
77
|
+
ref: 'sli_VkSQroQnx',
|
|
78
|
+
type: 'slide'
|
|
79
|
+
},
|
|
80
|
+
content: {
|
|
81
|
+
ref: 'sli_VJYjJnJhg',
|
|
82
|
+
type: 'slide'
|
|
83
|
+
},
|
|
84
|
+
pendingSlides: [],
|
|
85
|
+
slides: ['sli_VJYjJnJhg'],
|
|
86
|
+
step: {
|
|
87
|
+
current: 2
|
|
88
|
+
},
|
|
89
|
+
stars: 4
|
|
79
90
|
}
|
|
80
91
|
};
|
|
92
|
+
export const services = {
|
|
93
|
+
fetchSkills: () => Promise.resolve(fetchSkillsResponse),
|
|
94
|
+
fetchSlide: ref => Promise.resolve({ ...getSlideFixture(ref), universalRef: ref, id: ref }),
|
|
95
|
+
postProgression: () => Promise.resolve(postProgressionResponse),
|
|
96
|
+
postAnswer: () => Promise.resolve(postAnswerResponse)
|
|
97
|
+
};
|
package/es/types/common.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { SlideIndexes } from '../common';
|
|
2
|
-
import { AnswerUI } from './slides';
|
|
3
1
|
declare type TemplateContextValues = {
|
|
4
2
|
brandTheme?: unknown;
|
|
5
3
|
theme?: unknown;
|
|
@@ -142,29 +140,6 @@ export declare type JWT = {
|
|
|
142
140
|
usage: string;
|
|
143
141
|
host: string;
|
|
144
142
|
};
|
|
145
|
-
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
146
|
-
export declare type NextUISlide = {
|
|
147
|
-
questionText?: string;
|
|
148
|
-
answerUI?: AnswerUI;
|
|
149
|
-
hidden?: boolean;
|
|
150
|
-
position?: number;
|
|
151
|
-
animationType?: SlideUIAnimations;
|
|
152
|
-
isCorrect?: boolean;
|
|
153
|
-
endReview?: boolean;
|
|
154
|
-
};
|
|
155
|
-
export declare type UISlide = {
|
|
156
|
-
questionText?: string;
|
|
157
|
-
answerUI?: AnswerUI;
|
|
158
|
-
hidden?: boolean;
|
|
159
|
-
position: number;
|
|
160
|
-
animationType?: SlideUIAnimations;
|
|
161
|
-
isCorrect?: boolean;
|
|
162
|
-
endReview?: boolean;
|
|
163
|
-
nextContent?: NextUISlide;
|
|
164
|
-
};
|
|
165
|
-
export declare type FinishedSlides = {
|
|
166
|
-
[key in SlideIndexes]?: true;
|
|
167
|
-
};
|
|
168
143
|
export declare type WithRequired<T, K extends keyof T> = T & {
|
|
169
144
|
[P in K]-?: T[P];
|
|
170
145
|
};
|
|
@@ -23,4 +23,4 @@ declare type SkillsProps = NoSkillsProps & {
|
|
|
23
23
|
listSkills: SkillCard[];
|
|
24
24
|
};
|
|
25
25
|
export { SkillsProps };
|
|
26
|
-
export declare const mapStateToSkillsProps: (state: StoreState) => SkillsProps
|
|
26
|
+
export declare const mapStateToSkillsProps: (state: StoreState) => SkillsProps;
|
package/es/views/skills/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import map from 'lodash/fp/map';
|
|
3
|
+
import omit from 'lodash/fp/omit';
|
|
4
|
+
import { mapStateToSkillsProps } from '..';
|
|
5
|
+
test('should create initial props when there are no skills on the state', t => {
|
|
6
|
+
const state = {
|
|
7
|
+
data: {
|
|
8
|
+
progression: null,
|
|
9
|
+
skills: [],
|
|
10
|
+
slides: {},
|
|
11
|
+
token: '1234'
|
|
12
|
+
},
|
|
13
|
+
ui: {
|
|
14
|
+
currentSlideRef: '',
|
|
15
|
+
navigation: ['loader', 'skills'],
|
|
16
|
+
answers: [],
|
|
17
|
+
slide: {
|
|
18
|
+
validateButton: false
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const props = mapStateToSkillsProps(state);
|
|
23
|
+
t.deepEqual(props, {
|
|
24
|
+
title: '@todo title',
|
|
25
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
26
|
+
textNoSkills: '@todo textNoSkills',
|
|
27
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
28
|
+
isLoading: false,
|
|
29
|
+
isLoadingAriaLabel: '@todo loading',
|
|
30
|
+
listSkills: []
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
test('should create initial props when skills on the state', t => {
|
|
34
|
+
const state = {
|
|
35
|
+
data: {
|
|
36
|
+
progression: null,
|
|
37
|
+
skills: [
|
|
38
|
+
{
|
|
39
|
+
skillRef: '_skill-ref',
|
|
40
|
+
slidesToReview: 2,
|
|
41
|
+
name: 'skill-test',
|
|
42
|
+
custom: false
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
skillRef: '_skill-ref-2',
|
|
46
|
+
slidesToReview: 5,
|
|
47
|
+
name: 'skill-test-2',
|
|
48
|
+
custom: true
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
slides: {},
|
|
52
|
+
token: '1234'
|
|
53
|
+
},
|
|
54
|
+
ui: {
|
|
55
|
+
currentSlideRef: '',
|
|
56
|
+
navigation: ['loader', 'skills'],
|
|
57
|
+
answers: [],
|
|
58
|
+
slide: {
|
|
59
|
+
validateButton: false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const props = mapStateToSkillsProps(state);
|
|
64
|
+
t.deepEqual(omit('listSkills', props), {
|
|
65
|
+
title: '@todo title',
|
|
66
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
67
|
+
textNoSkills: '@todo textNoSkills',
|
|
68
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
69
|
+
isLoading: false,
|
|
70
|
+
isLoadingAriaLabel: '@todo loading'
|
|
71
|
+
});
|
|
72
|
+
t.deepEqual(map(omit('onClick'), props.listSkills), [
|
|
73
|
+
{
|
|
74
|
+
'aria-label': '',
|
|
75
|
+
isCustom: false,
|
|
76
|
+
skillTitle: 'skill-test',
|
|
77
|
+
skillAriaLabel: '@todo skill aria label',
|
|
78
|
+
buttonLabel: '@todo button',
|
|
79
|
+
buttonAriaLabel: '@todo button aria label',
|
|
80
|
+
reviseLabel: '@todo revise',
|
|
81
|
+
reviseAriaLabel: '@todo revise aria label'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
'aria-label': '',
|
|
85
|
+
isCustom: true,
|
|
86
|
+
skillTitle: 'skill-test-2',
|
|
87
|
+
skillAriaLabel: '@todo skill aria label',
|
|
88
|
+
buttonLabel: '@todo button',
|
|
89
|
+
buttonAriaLabel: '@todo button aria label',
|
|
90
|
+
reviseLabel: '@todo revise',
|
|
91
|
+
reviseAriaLabel: '@todo revise aria label'
|
|
92
|
+
}
|
|
93
|
+
]);
|
|
94
|
+
});
|