@coorpacademy/app-review 0.2.10-alpha.16 → 0.2.10-alpha.5
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/index.js +6 -3
- package/es/test/index.test.js +8 -1
- package/es/types/common.d.ts +9 -0
- package/es/types/slides.d.ts +1 -2
- package/es/views/slides/index.d.ts +1 -1
- package/es/views/slides/index.js +2 -3
- package/es/views/slides/map-api-slide-to-ui.js +0 -5
- package/es/views/slides/test/fixtures/slider.js +1 -2
- package/es/views/slides/test/index.test.js +11 -11
- package/es/views/slides/test/slide.free-text.on-change.test.js +2 -1
- package/es/views/slides/test/slide.qcm-drag.on-click.test.js +2 -1
- package/es/views/slides/test/slide.qcm-graphic.on-click.test.js +2 -1
- package/es/views/slides/test/slide.qcm.on-click.test.js +2 -1
- package/es/views/slides/test/slide.slider.on-change.test.js +2 -1
- package/es/views/slides/test/slide.template.on-change.test.js +3 -2
- package/lib/index.js +7 -3
- package/lib/test/index.test.js +8 -1
- package/lib/types/common.d.ts +9 -0
- package/lib/types/slides.d.ts +1 -2
- package/lib/views/slides/index.d.ts +1 -1
- package/lib/views/slides/index.js +2 -3
- package/lib/views/slides/map-api-slide-to-ui.js +0 -5
- package/lib/views/slides/test/fixtures/slider.js +1 -2
- package/lib/views/slides/test/index.test.js +11 -11
- package/lib/views/slides/test/slide.free-text.on-change.test.js +2 -1
- package/lib/views/slides/test/slide.qcm-drag.on-click.test.js +2 -1
- package/lib/views/slides/test/slide.qcm-graphic.on-click.test.js +2 -1
- package/lib/views/slides/test/slide.qcm.on-click.test.js +2 -1
- package/lib/views/slides/test/slide.slider.on-change.test.js +2 -1
- package/lib/views/slides/test/slide.template.on-change.test.js +3 -2
- package/package.json +3 -3
- package/src/index.tsx +7 -4
- package/src/test/index.test.tsx +8 -1
- package/src/types/common.ts +11 -0
- package/src/types/slides.ts +1 -2
- package/src/views/slides/index.ts +6 -3
- package/src/views/slides/map-api-slide-to-ui.ts +0 -5
- package/src/views/slides/test/fixtures/slider.ts +1 -2
- package/src/views/slides/test/index.test.ts +11 -11
- package/src/views/slides/test/slide.free-text.on-change.test.ts +2 -1
- package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +2 -1
- package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +2 -1
- package/src/views/slides/test/slide.qcm.on-click.test.ts +2 -1
- package/src/views/slides/test/slide.slider.on-change.test.ts +2 -1
- package/src/views/slides/test/slide.template.on-change.test.ts +3 -2
- package/es/actions/ui/next-slide.d.ts +0 -14
- package/es/actions/ui/next-slide.js +0 -15
- package/es/actions/ui/test/next-slide.test.d.ts +0 -1
- package/es/actions/ui/test/next-slide.test.js +0 -63
- package/es/views/slides/test/slide.slider.on-slider-change.test.d.ts +0 -1
- package/es/views/slides/test/slide.slider.on-slider-change.test.js +0 -63
- package/lib/actions/ui/next-slide.d.ts +0 -14
- package/lib/actions/ui/next-slide.js +0 -16
- package/lib/actions/ui/test/next-slide.test.d.ts +0 -1
- package/lib/actions/ui/test/next-slide.test.js +0 -64
- package/lib/views/slides/test/slide.slider.on-slider-change.test.d.ts +0 -1
- package/lib/views/slides/test/slide.slider.on-slider-change.test.js +0 -65
- package/src/actions/ui/next-slide.ts +0 -31
- package/src/actions/ui/test/next-slide.test.ts +0 -75
- package/src/views/slides/test/slide.slider.on-slider-change.test.ts +0 -71
|
@@ -2,6 +2,7 @@ var _a;
|
|
|
2
2
|
import test from 'ava';
|
|
3
3
|
import omit from 'lodash/fp/omit';
|
|
4
4
|
import get from 'lodash/fp/get';
|
|
5
|
+
import identity from 'lodash/fp/identity';
|
|
5
6
|
import { mapStateToSlidesProps } from '..';
|
|
6
7
|
import { services } from '../../../test/util/services.mock';
|
|
7
8
|
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
@@ -60,7 +61,7 @@ test('should dispatch EDIT_QCM action via the property onClick of a QCM slide',
|
|
|
60
61
|
}
|
|
61
62
|
];
|
|
62
63
|
var _b = createTestStore(t, initialState, services, expectedActions), dispatch = _b.dispatch, getState = _b.getState;
|
|
63
|
-
var props = mapStateToSlidesProps(getState(), dispatch);
|
|
64
|
+
var props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
64
65
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
65
66
|
animateCorrectionPopin: false,
|
|
66
67
|
showCorrectionPopin: false,
|
|
@@ -2,6 +2,7 @@ var _a;
|
|
|
2
2
|
import test from 'ava';
|
|
3
3
|
import omit from 'lodash/fp/omit';
|
|
4
4
|
import get from 'lodash/fp/get';
|
|
5
|
+
import identity from 'lodash/fp/identity';
|
|
5
6
|
import { mapStateToSlidesProps } from '..';
|
|
6
7
|
import { services } from '../../../test/util/services.mock';
|
|
7
8
|
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
@@ -58,7 +59,7 @@ test('should dispatch EDIT_SLIDER action via the property onChange of a Slider s
|
|
|
58
59
|
}
|
|
59
60
|
];
|
|
60
61
|
var _b = createTestStore(t, initialState, services, expectedActions), dispatch = _b.dispatch, getState = _b.getState;
|
|
61
|
-
var props = mapStateToSlidesProps(getState(), dispatch);
|
|
62
|
+
var props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
62
63
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
63
64
|
animateCorrectionPopin: false,
|
|
64
65
|
showCorrectionPopin: false,
|
|
@@ -2,6 +2,7 @@ var _a;
|
|
|
2
2
|
import test from 'ava';
|
|
3
3
|
import omit from 'lodash/fp/omit';
|
|
4
4
|
import get from 'lodash/fp/get';
|
|
5
|
+
import identity from 'lodash/fp/identity';
|
|
5
6
|
import { mapStateToSlidesProps } from '..';
|
|
6
7
|
import { services } from '../../../test/util/services.mock';
|
|
7
8
|
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
@@ -53,7 +54,7 @@ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Templa
|
|
|
53
54
|
t.plan(2);
|
|
54
55
|
var expectedActions = [{ type: EDIT_TEMPLATE, payload: ['', 'test', ''] }];
|
|
55
56
|
var _b = createTestStore(t, initialState, services, expectedActions), dispatch = _b.dispatch, getState = _b.getState;
|
|
56
|
-
var props = mapStateToSlidesProps(getState(), dispatch);
|
|
57
|
+
var props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
57
58
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
58
59
|
animateCorrectionPopin: false,
|
|
59
60
|
showCorrectionPopin: false,
|
|
@@ -72,7 +73,7 @@ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Templa
|
|
|
72
73
|
t.plan(2);
|
|
73
74
|
var expectedActions = [{ type: EDIT_TEMPLATE, payload: ['Catalogue', '', ''] }];
|
|
74
75
|
var _b = createTestStore(t, initialState, services, expectedActions), dispatch = _b.dispatch, getState = _b.getState;
|
|
75
|
-
var props = mapStateToSlidesProps(getState(), dispatch);
|
|
76
|
+
var props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
76
77
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
77
78
|
animateCorrectionPopin: false,
|
|
78
79
|
showCorrectionPopin: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/app-review",
|
|
3
|
-
"version": "0.2.10-alpha.
|
|
3
|
+
"version": "0.2.10-alpha.5+b5f45c65b",
|
|
4
4
|
"description": "",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.15.0"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"./package.json": "./package.json"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@coorpacademy/components": "10.22.
|
|
44
|
+
"@coorpacademy/components": "10.22.24",
|
|
45
45
|
"@coorpacademy/redux-task": "1.1.5",
|
|
46
46
|
"cross-fetch": "^3.1.5",
|
|
47
47
|
"jwt-decode": "^3.1.2",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"ts-node": "^10.9.1",
|
|
79
79
|
"typescript": "^4.7.4"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "b5f45c65ba35d615bc2a74df5c9ff7afe25a35bb"
|
|
82
82
|
}
|
package/src/index.tsx
CHANGED
|
@@ -19,17 +19,18 @@ import {VIEWS} from './common';
|
|
|
19
19
|
import {mapStateToSlidesProps} from './views/slides';
|
|
20
20
|
import {mapStateToSkillsProps} from './views/skills';
|
|
21
21
|
|
|
22
|
-
const ConnectedApp = (): JSX.Element => {
|
|
22
|
+
const ConnectedApp = ({onQuitClick}: {onQuitClick: Function}): JSX.Element => {
|
|
23
23
|
const dispatch = useDispatch();
|
|
24
24
|
|
|
25
25
|
const props = {
|
|
26
26
|
viewName: useSelector(
|
|
27
27
|
(state: StoreState) => state.ui.navigation[state.ui.navigation.length - 1]
|
|
28
28
|
),
|
|
29
|
-
slides: useSelector((state: StoreState) => mapStateToSlidesProps(state, dispatch)),
|
|
29
|
+
slides: useSelector((state: StoreState) => mapStateToSlidesProps(state, dispatch, onQuitClick)),
|
|
30
30
|
skills: useSelector((state: StoreState) => mapStateToSkillsProps(state))
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
// eslint-disable-next-line no-console
|
|
33
|
+
console.log(props);
|
|
33
34
|
return <AppReviewTemplate {...props} />;
|
|
34
35
|
};
|
|
35
36
|
|
|
@@ -37,6 +38,8 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
|
|
|
37
38
|
const [store, setStore] = useState<Store<StoreState, AnyAction> | null>(null);
|
|
38
39
|
const [isProgressionCreated, setIsProgressionCreated] = useState(false);
|
|
39
40
|
|
|
41
|
+
const onQuitClick = get('onQuitClick', options);
|
|
42
|
+
|
|
40
43
|
useEffect(() => {
|
|
41
44
|
if (store) return;
|
|
42
45
|
|
|
@@ -88,7 +91,7 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
|
|
|
88
91
|
|
|
89
92
|
return (
|
|
90
93
|
<Provider store={store}>
|
|
91
|
-
<ConnectedApp />
|
|
94
|
+
<ConnectedApp onQuitClick={onQuitClick} />
|
|
92
95
|
</Provider>
|
|
93
96
|
);
|
|
94
97
|
};
|
package/src/test/index.test.tsx
CHANGED
|
@@ -58,8 +58,15 @@ const clickAllSlides = async (
|
|
|
58
58
|
|
|
59
59
|
const appOptions: AppOptions = {
|
|
60
60
|
token: process.env.API_TEST_TOKEN || '',
|
|
61
|
+
templateContext: {
|
|
62
|
+
theme: {color: {primary: '#123'}}
|
|
63
|
+
},
|
|
61
64
|
skillRef: 'skill_NJC0jFKoH',
|
|
62
|
-
services
|
|
65
|
+
services,
|
|
66
|
+
onQuitClick: (): void => {
|
|
67
|
+
// eslint-disable-next-line no-console
|
|
68
|
+
console.log('onQuitClick - options');
|
|
69
|
+
}
|
|
63
70
|
};
|
|
64
71
|
|
|
65
72
|
test('should show the loader while the app is fetching the data', async t => {
|
package/src/types/common.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
// TODO use type from components
|
|
2
|
+
type TemplateContextValues = {
|
|
3
|
+
brandTheme?: unknown;
|
|
4
|
+
theme?: unknown; // TODO type Theme
|
|
5
|
+
translations?: unknown; // TODO type Translations
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
// TODO: EDIT_CHOICES -> specify typing
|
|
2
9
|
export type ChoiceFromAPI = {
|
|
3
10
|
_id: string;
|
|
@@ -169,8 +176,12 @@ export type Options = {
|
|
|
169
176
|
|
|
170
177
|
export type AppOptions = {
|
|
171
178
|
token: string;
|
|
179
|
+
theme?: unknown;
|
|
180
|
+
translations?: unknown;
|
|
181
|
+
templateContext?: TemplateContextValues;
|
|
172
182
|
skillRef?: string;
|
|
173
183
|
services: Services;
|
|
184
|
+
onQuitClick: Function;
|
|
174
185
|
};
|
|
175
186
|
|
|
176
187
|
export type JWT = {
|
package/src/types/slides.ts
CHANGED
|
@@ -59,9 +59,8 @@ export type DropDown = {
|
|
|
59
59
|
export type QuestionRange = {
|
|
60
60
|
type: 'slider';
|
|
61
61
|
placeholder?: string;
|
|
62
|
-
onChange?:
|
|
62
|
+
onChange?: Function;
|
|
63
63
|
onChangeEnd?: Function;
|
|
64
|
-
onSliderChange?: (value: number) => void;
|
|
65
64
|
multi?: boolean;
|
|
66
65
|
value: number | number[];
|
|
67
66
|
title: string;
|
|
@@ -298,7 +298,11 @@ const getCorrectionPopinProps = (
|
|
|
298
298
|
type: isCorrect ? 'right' : 'wrong'
|
|
299
299
|
});
|
|
300
300
|
|
|
301
|
-
export const mapStateToSlidesProps = (
|
|
301
|
+
export const mapStateToSlidesProps = (
|
|
302
|
+
state: StoreState,
|
|
303
|
+
dispatch: Dispatch,
|
|
304
|
+
onQuitClick: Function
|
|
305
|
+
): SlidesViewProps => {
|
|
302
306
|
const currentSlideRef = get(['ui', 'currentSlideRef'], state);
|
|
303
307
|
const correction = get(['data', 'corrections', currentSlideRef], state);
|
|
304
308
|
const isCorrect = get(['data', 'progression', 'state', 'isCorrect'], state);
|
|
@@ -309,8 +313,7 @@ export const mapStateToSlidesProps = (state: StoreState, dispatch: Dispatch): Sl
|
|
|
309
313
|
mode: '__revision_mode',
|
|
310
314
|
skillName: '__agility',
|
|
311
315
|
onQuitClick: (): void => {
|
|
312
|
-
|
|
313
|
-
console.log('onQuitClick');
|
|
316
|
+
onQuitClick();
|
|
314
317
|
},
|
|
315
318
|
'aria-label': 'aria-header-wrapper',
|
|
316
319
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -225,7 +225,6 @@ const sliderProps =
|
|
|
225
225
|
title: `${currentValue} ${question.content.unitLabel}`,
|
|
226
226
|
value: sliderPosition,
|
|
227
227
|
onChange: (position: number): void => {
|
|
228
|
-
// atom/range handler
|
|
229
228
|
const newValue: string = pipe(
|
|
230
229
|
multiply(maxValue),
|
|
231
230
|
round,
|
|
@@ -233,10 +232,6 @@ const sliderProps =
|
|
|
233
232
|
_toString
|
|
234
233
|
)(position);
|
|
235
234
|
dispatch(editAnswer([newValue]));
|
|
236
|
-
},
|
|
237
|
-
onSliderChange: (newValue: number): void => {
|
|
238
|
-
// mobile/slider handler
|
|
239
|
-
dispatch(editAnswer([`${newValue}`]));
|
|
240
235
|
}
|
|
241
236
|
};
|
|
242
237
|
};
|
|
@@ -70,7 +70,7 @@ test('should create initial props when fetched slide is not still received', t =
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
73
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
74
74
|
t.is(props.congratsProps, undefined);
|
|
75
75
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
76
76
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -161,7 +161,7 @@ test('should create props when first slide is on the state', t => {
|
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
164
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
165
165
|
t.is(props.congratsProps, undefined);
|
|
166
166
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
167
167
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -266,7 +266,7 @@ test('should create props when slide is on the state and user has selected answe
|
|
|
266
266
|
}
|
|
267
267
|
};
|
|
268
268
|
|
|
269
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
269
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
270
270
|
t.is(props.congratsProps, undefined);
|
|
271
271
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
272
272
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -372,7 +372,7 @@ test('should verify props when first slide was answered correctly and next slide
|
|
|
372
372
|
}
|
|
373
373
|
};
|
|
374
374
|
|
|
375
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
375
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
376
376
|
t.is(props.congratsProps, undefined);
|
|
377
377
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
378
378
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -482,7 +482,7 @@ test('should verify props when first slide was answered with error and next slid
|
|
|
482
482
|
}
|
|
483
483
|
};
|
|
484
484
|
|
|
485
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
485
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
486
486
|
t.is(props.congratsProps, undefined);
|
|
487
487
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
488
488
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -547,7 +547,7 @@ test('should verify props when first slide was answered, next slide is fetched &
|
|
|
547
547
|
}
|
|
548
548
|
};
|
|
549
549
|
|
|
550
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
550
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
551
551
|
t.is(props.congratsProps, undefined);
|
|
552
552
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
553
553
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -661,7 +661,7 @@ test('should verify props when first slide was answered incorrectly, next slide
|
|
|
661
661
|
}
|
|
662
662
|
};
|
|
663
663
|
|
|
664
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
664
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
665
665
|
t.is(props.congratsProps, undefined);
|
|
666
666
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
667
667
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -773,7 +773,7 @@ test('should verify props when currentSlideRef has changed to nextContent of pro
|
|
|
773
773
|
}
|
|
774
774
|
};
|
|
775
775
|
|
|
776
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
776
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
777
777
|
t.is(props.congratsProps, undefined);
|
|
778
778
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
779
779
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -845,7 +845,7 @@ test('should verify props when progression is in success', t => {
|
|
|
845
845
|
}
|
|
846
846
|
};
|
|
847
847
|
|
|
848
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
848
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
849
849
|
t.is(props.congratsProps, undefined);
|
|
850
850
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
851
851
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -917,7 +917,7 @@ test('should verify props when progression has answered a current pendingSlide',
|
|
|
917
917
|
}
|
|
918
918
|
};
|
|
919
919
|
|
|
920
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
920
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
921
921
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
922
922
|
'aria-label': 'aria-header-wrapper',
|
|
923
923
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -986,7 +986,7 @@ test('should verify props when progression still has a pendingSlide', t => {
|
|
|
986
986
|
}
|
|
987
987
|
};
|
|
988
988
|
|
|
989
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
989
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
990
990
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
991
991
|
'aria-label': 'aria-header-wrapper',
|
|
992
992
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import omit from 'lodash/fp/omit';
|
|
3
3
|
import get from 'lodash/fp/get';
|
|
4
|
+
import identity from 'lodash/fp/identity';
|
|
4
5
|
import {mapStateToSlidesProps} from '..';
|
|
5
6
|
import {ProgressionFromAPI} from '../../../types/common';
|
|
6
7
|
import {services} from '../../../test/util/services.mock';
|
|
@@ -64,7 +65,7 @@ test('should dispatch EDIT_BASIC action via the property onChange of a Free Text
|
|
|
64
65
|
];
|
|
65
66
|
const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
|
|
66
67
|
|
|
67
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
68
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
68
69
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
69
70
|
animateCorrectionPopin: false,
|
|
70
71
|
showCorrectionPopin: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import omit from 'lodash/fp/omit';
|
|
3
3
|
import get from 'lodash/fp/get';
|
|
4
|
+
import identity from 'lodash/fp/identity';
|
|
4
5
|
import {mapStateToSlidesProps} from '..';
|
|
5
6
|
import {ProgressionFromAPI} from '../../../types/common';
|
|
6
7
|
import {services} from '../../../test/util/services.mock';
|
|
@@ -64,7 +65,7 @@ test('should dispatch EDIT_QCM_DRAG action via the property onClick of a QCM Dra
|
|
|
64
65
|
];
|
|
65
66
|
const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
|
|
66
67
|
|
|
67
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
68
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
68
69
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
69
70
|
animateCorrectionPopin: false,
|
|
70
71
|
showCorrectionPopin: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import omit from 'lodash/fp/omit';
|
|
3
3
|
import get from 'lodash/fp/get';
|
|
4
|
+
import identity from 'lodash/fp/identity';
|
|
4
5
|
import {mapStateToSlidesProps} from '..';
|
|
5
6
|
import {ProgressionFromAPI} from '../../../types/common';
|
|
6
7
|
import {services} from '../../../test/util/services.mock';
|
|
@@ -64,7 +65,7 @@ test('should dispatch EDIT_QCM_GRAPHIC action via the property onClick of a QCM
|
|
|
64
65
|
];
|
|
65
66
|
const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
|
|
66
67
|
|
|
67
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
68
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
68
69
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
69
70
|
animateCorrectionPopin: false,
|
|
70
71
|
showCorrectionPopin: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import omit from 'lodash/fp/omit';
|
|
3
3
|
import get from 'lodash/fp/get';
|
|
4
|
+
import identity from 'lodash/fp/identity';
|
|
4
5
|
import {mapStateToSlidesProps} from '..';
|
|
5
6
|
import {ProgressionFromAPI} from '../../../types/common';
|
|
6
7
|
import {services} from '../../../test/util/services.mock';
|
|
@@ -66,7 +67,7 @@ test('should dispatch EDIT_QCM action via the property onClick of a QCM slide',
|
|
|
66
67
|
];
|
|
67
68
|
const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
|
|
68
69
|
|
|
69
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
70
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
70
71
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
71
72
|
animateCorrectionPopin: false,
|
|
72
73
|
showCorrectionPopin: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import omit from 'lodash/fp/omit';
|
|
3
3
|
import get from 'lodash/fp/get';
|
|
4
|
+
import identity from 'lodash/fp/identity';
|
|
4
5
|
import {mapStateToSlidesProps} from '..';
|
|
5
6
|
import {ProgressionFromAPI} from '../../../types/common';
|
|
6
7
|
import {services} from '../../../test/util/services.mock';
|
|
@@ -64,7 +65,7 @@ test('should dispatch EDIT_SLIDER action via the property onChange of a Slider s
|
|
|
64
65
|
];
|
|
65
66
|
const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
|
|
66
67
|
|
|
67
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
68
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
68
69
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
69
70
|
animateCorrectionPopin: false,
|
|
70
71
|
showCorrectionPopin: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import omit from 'lodash/fp/omit';
|
|
3
3
|
import get from 'lodash/fp/get';
|
|
4
|
+
import identity from 'lodash/fp/identity';
|
|
4
5
|
import {mapStateToSlidesProps} from '..';
|
|
5
6
|
import {ProgressionFromAPI} from '../../../types/common';
|
|
6
7
|
import {services} from '../../../test/util/services.mock';
|
|
@@ -59,7 +60,7 @@ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Templa
|
|
|
59
60
|
const expectedActions = [{type: EDIT_TEMPLATE, payload: ['', 'test', '']}];
|
|
60
61
|
const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
|
|
61
62
|
|
|
62
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
63
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
63
64
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
64
65
|
animateCorrectionPopin: false,
|
|
65
66
|
showCorrectionPopin: false,
|
|
@@ -81,7 +82,7 @@ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Templa
|
|
|
81
82
|
const expectedActions = [{type: EDIT_TEMPLATE, payload: ['Catalogue', '', '']}];
|
|
82
83
|
const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
|
|
83
84
|
|
|
84
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
85
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
85
86
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
86
87
|
animateCorrectionPopin: false,
|
|
87
88
|
showCorrectionPopin: false,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { StoreState } from '../../reducers';
|
|
3
|
-
export declare const NEXT_SLIDE: "@@slide/NEXT_SLIDE";
|
|
4
|
-
declare type NextSlidePayload = {
|
|
5
|
-
currentSlideRef: string;
|
|
6
|
-
nextSlideRef: string;
|
|
7
|
-
animationType: string;
|
|
8
|
-
};
|
|
9
|
-
export declare type NextSlide = {
|
|
10
|
-
type: typeof NEXT_SLIDE;
|
|
11
|
-
payload: NextSlidePayload;
|
|
12
|
-
};
|
|
13
|
-
export declare const nextSlide: (dispatch: Dispatch, getState: () => StoreState) => NextSlide;
|
|
14
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import get from 'lodash/fp/get';
|
|
2
|
-
export const NEXT_SLIDE = '@@slide/NEXT_SLIDE';
|
|
3
|
-
export const nextSlide = (dispatch, getState) => {
|
|
4
|
-
const state = getState();
|
|
5
|
-
const payload = {
|
|
6
|
-
currentSlideRef: get(['ui', 'currentSlideRef'], state),
|
|
7
|
-
nextSlideRef: get(['data', 'progression', 'state', 'nextContent', 'ref'], state),
|
|
8
|
-
animationType: state.data.progression?.state.isCorrect ? 'unstack' : 'restack'
|
|
9
|
-
};
|
|
10
|
-
const action = {
|
|
11
|
-
type: NEXT_SLIDE,
|
|
12
|
-
payload
|
|
13
|
-
};
|
|
14
|
-
return dispatch(action);
|
|
15
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import test from 'ava';
|
|
2
|
-
import pipe from 'lodash/fp/pipe';
|
|
3
|
-
import set from 'lodash/fp/set';
|
|
4
|
-
import { nextSlide, NEXT_SLIDE } from '../next-slide';
|
|
5
|
-
import { createTestStore } from '../../test/create-test-store';
|
|
6
|
-
import { getChoicesCorrection, postAnswerResponses, services } from '../../../test/util/services.mock';
|
|
7
|
-
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
8
|
-
import { qcmGraphicSlide } from '../../../views/slides/test/fixtures/qcm-graphic';
|
|
9
|
-
const progression = postAnswerResponses[freeTextSlide.universalRef];
|
|
10
|
-
const skillRef = '_skill-ref';
|
|
11
|
-
const answer = ['Vous isoler dans un lieu calme'];
|
|
12
|
-
const state = {
|
|
13
|
-
data: {
|
|
14
|
-
progression,
|
|
15
|
-
slides: {
|
|
16
|
-
[freeTextSlide.universalRef]: freeTextSlide,
|
|
17
|
-
[qcmGraphicSlide.universalRef]: qcmGraphicSlide
|
|
18
|
-
},
|
|
19
|
-
skills: [{ skillRef, custom: false, name: skillRef, slidesToReview: 5 }],
|
|
20
|
-
token: '1234',
|
|
21
|
-
corrections: { [freeTextSlide.universalRef]: getChoicesCorrection(freeTextSlide.universalRef) },
|
|
22
|
-
rank: { start: 93 }
|
|
23
|
-
},
|
|
24
|
-
ui: {
|
|
25
|
-
currentSlideRef: freeTextSlide._id,
|
|
26
|
-
navigation: ['loader', 'slides'],
|
|
27
|
-
answers: answer,
|
|
28
|
-
slide: {
|
|
29
|
-
validateButton: false,
|
|
30
|
-
animateCorrectionPopin: true,
|
|
31
|
-
showCorrectionPopin: true
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
test('should dispatch NEXT_SLIDE action when nextSlide is called and the progression state is correct', t => {
|
|
36
|
-
const expectedActions = [
|
|
37
|
-
{
|
|
38
|
-
type: NEXT_SLIDE,
|
|
39
|
-
payload: {
|
|
40
|
-
currentSlideRef: freeTextSlide.universalRef,
|
|
41
|
-
nextSlideRef: qcmGraphicSlide.universalRef,
|
|
42
|
-
animationType: 'unstack'
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
];
|
|
46
|
-
const { dispatch } = createTestStore(t, state, services, expectedActions);
|
|
47
|
-
dispatch(nextSlide);
|
|
48
|
-
});
|
|
49
|
-
test('should dispatch NEXT_SLIDE action when nextSlide is called and the progression state is not correct', t => {
|
|
50
|
-
const stateWithWrongAnswer = pipe(set(['data', 'progression', 'state', 'isCorrect'], false), set(['data', 'progression', 'state', 'allAnswers', 0, 'isCorrect'], false))(state);
|
|
51
|
-
const expectedActions = [
|
|
52
|
-
{
|
|
53
|
-
type: NEXT_SLIDE,
|
|
54
|
-
payload: {
|
|
55
|
-
currentSlideRef: freeTextSlide.universalRef,
|
|
56
|
-
nextSlideRef: qcmGraphicSlide.universalRef,
|
|
57
|
-
animationType: 'restack'
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
];
|
|
61
|
-
const { dispatch } = createTestStore(t, stateWithWrongAnswer, services, expectedActions);
|
|
62
|
-
dispatch(nextSlide);
|
|
63
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import test from 'ava';
|
|
2
|
-
import get from 'lodash/fp/get';
|
|
3
|
-
import { mapStateToSlidesProps } from '..';
|
|
4
|
-
import { services } from '../../../test/util/services.mock';
|
|
5
|
-
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
6
|
-
import { EDIT_SLIDER } from '../../../actions/ui/answers';
|
|
7
|
-
import { sliderSlide } from './fixtures/slider';
|
|
8
|
-
const progression = {
|
|
9
|
-
_id: '123456789123',
|
|
10
|
-
content: { type: 'skill', ref: '_skill-ref' },
|
|
11
|
-
engine: {
|
|
12
|
-
ref: 'review'
|
|
13
|
-
},
|
|
14
|
-
state: {
|
|
15
|
-
allAnswers: [],
|
|
16
|
-
isCorrect: true,
|
|
17
|
-
nextContent: {
|
|
18
|
-
ref: sliderSlide._id,
|
|
19
|
-
type: 'slide'
|
|
20
|
-
},
|
|
21
|
-
pendingSlides: [],
|
|
22
|
-
slides: [],
|
|
23
|
-
step: {
|
|
24
|
-
current: 1
|
|
25
|
-
},
|
|
26
|
-
stars: 0
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const initialState = {
|
|
30
|
-
data: {
|
|
31
|
-
progression,
|
|
32
|
-
slides: {
|
|
33
|
-
[sliderSlide._id]: sliderSlide
|
|
34
|
-
},
|
|
35
|
-
skills: [],
|
|
36
|
-
token: '1234',
|
|
37
|
-
corrections: {},
|
|
38
|
-
rank: {}
|
|
39
|
-
},
|
|
40
|
-
ui: {
|
|
41
|
-
currentSlideRef: sliderSlide._id,
|
|
42
|
-
navigation: ['skills', 'slides'],
|
|
43
|
-
answers: [],
|
|
44
|
-
slide: {
|
|
45
|
-
validateButton: false
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
test('should dispatch EDIT_SLIDER action via the property onSliderChange of a Slider slide', t => {
|
|
50
|
-
t.plan(1);
|
|
51
|
-
const expectedActions = [
|
|
52
|
-
{
|
|
53
|
-
type: EDIT_SLIDER,
|
|
54
|
-
payload: ['111']
|
|
55
|
-
}
|
|
56
|
-
];
|
|
57
|
-
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
58
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
59
|
-
const SlideProps = props.stack.slides['0'].answerUI?.model;
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
61
|
-
const onSliderChange = get('onSliderChange', SlideProps);
|
|
62
|
-
onSliderChange(111);
|
|
63
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Dispatch } from 'redux';
|
|
2
|
-
import type { StoreState } from '../../reducers';
|
|
3
|
-
export declare const NEXT_SLIDE: "@@slide/NEXT_SLIDE";
|
|
4
|
-
declare type NextSlidePayload = {
|
|
5
|
-
currentSlideRef: string;
|
|
6
|
-
nextSlideRef: string;
|
|
7
|
-
animationType: string;
|
|
8
|
-
};
|
|
9
|
-
export declare type NextSlide = {
|
|
10
|
-
type: typeof NEXT_SLIDE;
|
|
11
|
-
payload: NextSlidePayload;
|
|
12
|
-
};
|
|
13
|
-
export declare const nextSlide: (dispatch: Dispatch, getState: () => StoreState) => NextSlide;
|
|
14
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import get from 'lodash/fp/get';
|
|
2
|
-
export var NEXT_SLIDE = '@@slide/NEXT_SLIDE';
|
|
3
|
-
export var nextSlide = function (dispatch, getState) {
|
|
4
|
-
var _a;
|
|
5
|
-
var state = getState();
|
|
6
|
-
var payload = {
|
|
7
|
-
currentSlideRef: get(['ui', 'currentSlideRef'], state),
|
|
8
|
-
nextSlideRef: get(['data', 'progression', 'state', 'nextContent', 'ref'], state),
|
|
9
|
-
animationType: ((_a = state.data.progression) === null || _a === void 0 ? void 0 : _a.state.isCorrect) ? 'unstack' : 'restack'
|
|
10
|
-
};
|
|
11
|
-
var action = {
|
|
12
|
-
type: NEXT_SLIDE,
|
|
13
|
-
payload: payload
|
|
14
|
-
};
|
|
15
|
-
return dispatch(action);
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|