@coorpacademy/app-review 0.2.10-alpha.5 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/es/actions/ui/next-slide.d.ts +14 -0
  2. package/es/actions/ui/next-slide.js +15 -0
  3. package/es/actions/ui/test/next-slide.test.d.ts +1 -0
  4. package/es/actions/ui/test/next-slide.test.js +63 -0
  5. package/es/index.js +3 -6
  6. package/es/test/index.test.js +1 -8
  7. package/es/types/common.d.ts +0 -9
  8. package/es/types/slides.d.ts +2 -1
  9. package/es/views/slides/index.d.ts +1 -1
  10. package/es/views/slides/index.js +3 -2
  11. package/es/views/slides/map-api-slide-to-ui.js +5 -0
  12. package/es/views/slides/test/fixtures/slider.js +2 -1
  13. package/es/views/slides/test/index.test.js +11 -11
  14. package/es/views/slides/test/slide.free-text.on-change.test.js +1 -2
  15. package/es/views/slides/test/slide.qcm-drag.on-click.test.js +1 -2
  16. package/es/views/slides/test/slide.qcm-graphic.on-click.test.js +1 -2
  17. package/es/views/slides/test/slide.qcm.on-click.test.js +1 -2
  18. package/es/views/slides/test/slide.slider.on-change.test.js +1 -2
  19. package/es/views/slides/test/slide.slider.on-slider-change.test.d.ts +1 -0
  20. package/es/views/slides/test/slide.slider.on-slider-change.test.js +63 -0
  21. package/es/views/slides/test/slide.template.on-change.test.js +2 -3
  22. package/lib/actions/ui/next-slide.d.ts +14 -0
  23. package/lib/actions/ui/next-slide.js +16 -0
  24. package/lib/actions/ui/test/next-slide.test.d.ts +1 -0
  25. package/lib/actions/ui/test/next-slide.test.js +64 -0
  26. package/lib/index.js +3 -7
  27. package/lib/test/index.test.js +1 -8
  28. package/lib/types/common.d.ts +0 -9
  29. package/lib/types/slides.d.ts +2 -1
  30. package/lib/views/slides/index.d.ts +1 -1
  31. package/lib/views/slides/index.js +3 -2
  32. package/lib/views/slides/map-api-slide-to-ui.js +5 -0
  33. package/lib/views/slides/test/fixtures/slider.js +2 -1
  34. package/lib/views/slides/test/index.test.js +11 -11
  35. package/lib/views/slides/test/slide.free-text.on-change.test.js +1 -2
  36. package/lib/views/slides/test/slide.qcm-drag.on-click.test.js +1 -2
  37. package/lib/views/slides/test/slide.qcm-graphic.on-click.test.js +1 -2
  38. package/lib/views/slides/test/slide.qcm.on-click.test.js +1 -2
  39. package/lib/views/slides/test/slide.slider.on-change.test.js +1 -2
  40. package/lib/views/slides/test/slide.slider.on-slider-change.test.d.ts +1 -0
  41. package/lib/views/slides/test/slide.slider.on-slider-change.test.js +65 -0
  42. package/lib/views/slides/test/slide.template.on-change.test.js +2 -3
  43. package/package.json +4 -4
  44. package/src/actions/ui/next-slide.ts +31 -0
  45. package/src/actions/ui/test/next-slide.test.ts +75 -0
  46. package/src/index.tsx +4 -7
  47. package/src/test/index.test.tsx +1 -8
  48. package/src/types/common.ts +0 -11
  49. package/src/types/slides.ts +2 -1
  50. package/src/views/slides/index.ts +3 -6
  51. package/src/views/slides/map-api-slide-to-ui.ts +5 -0
  52. package/src/views/slides/test/fixtures/slider.ts +2 -1
  53. package/src/views/slides/test/index.test.ts +11 -11
  54. package/src/views/slides/test/slide.free-text.on-change.test.ts +1 -2
  55. package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +1 -2
  56. package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +1 -2
  57. package/src/views/slides/test/slide.qcm.on-click.test.ts +1 -2
  58. package/src/views/slides/test/slide.slider.on-change.test.ts +1 -2
  59. package/src/views/slides/test/slide.slider.on-slider-change.test.ts +71 -0
  60. package/src/views/slides/test/slide.template.on-change.test.ts +2 -3
@@ -36,7 +36,8 @@ export const sliderUISlide: Partial<UISlide> = {
36
36
  maxLabel: '15 an(s)',
37
37
  title: '1 an(s)',
38
38
  value: 0,
39
- onChange: noop
39
+ onChange: noop,
40
+ onSliderChange: noop
40
41
  }
41
42
  }
42
43
  };
@@ -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, identity);
73
+ const props = mapStateToSlidesProps(state, 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, identity);
164
+ const props = mapStateToSlidesProps(state, 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, identity);
269
+ const props = mapStateToSlidesProps(state, 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, identity);
375
+ const props = mapStateToSlidesProps(state, 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, identity);
485
+ const props = mapStateToSlidesProps(state, 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, identity);
550
+ const props = mapStateToSlidesProps(state, 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, identity);
664
+ const props = mapStateToSlidesProps(state, 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, identity);
776
+ const props = mapStateToSlidesProps(state, 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, identity);
848
+ const props = mapStateToSlidesProps(state, 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, identity);
920
+ const props = mapStateToSlidesProps(state, 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, identity);
989
+ const props = mapStateToSlidesProps(state, identity);
990
990
  t.deepEqual(omit(['onQuitClick'], props.header), {
991
991
  'aria-label': 'aria-header-wrapper',
992
992
  closeButtonAriaLabel: 'aria-close-button',
@@ -1,7 +1,6 @@
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';
5
4
  import {mapStateToSlidesProps} from '..';
6
5
  import {ProgressionFromAPI} from '../../../types/common';
7
6
  import {services} from '../../../test/util/services.mock';
@@ -65,7 +64,7 @@ test('should dispatch EDIT_BASIC action via the property onChange of a Free Text
65
64
  ];
66
65
  const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
67
66
 
68
- const props = mapStateToSlidesProps(getState(), dispatch, identity);
67
+ const props = mapStateToSlidesProps(getState(), dispatch);
69
68
  t.deepEqual(omit('answerUI', props.stack.slides['0']), {
70
69
  animateCorrectionPopin: false,
71
70
  showCorrectionPopin: false,
@@ -1,7 +1,6 @@
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';
5
4
  import {mapStateToSlidesProps} from '..';
6
5
  import {ProgressionFromAPI} from '../../../types/common';
7
6
  import {services} from '../../../test/util/services.mock';
@@ -65,7 +64,7 @@ test('should dispatch EDIT_QCM_DRAG action via the property onClick of a QCM Dra
65
64
  ];
66
65
  const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
67
66
 
68
- const props = mapStateToSlidesProps(getState(), dispatch, identity);
67
+ const props = mapStateToSlidesProps(getState(), dispatch);
69
68
  t.deepEqual(omit('answerUI', props.stack.slides['0']), {
70
69
  animateCorrectionPopin: false,
71
70
  showCorrectionPopin: false,
@@ -1,7 +1,6 @@
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';
5
4
  import {mapStateToSlidesProps} from '..';
6
5
  import {ProgressionFromAPI} from '../../../types/common';
7
6
  import {services} from '../../../test/util/services.mock';
@@ -65,7 +64,7 @@ test('should dispatch EDIT_QCM_GRAPHIC action via the property onClick of a QCM
65
64
  ];
66
65
  const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
67
66
 
68
- const props = mapStateToSlidesProps(getState(), dispatch, identity);
67
+ const props = mapStateToSlidesProps(getState(), dispatch);
69
68
  t.deepEqual(omit('answerUI', props.stack.slides['0']), {
70
69
  animateCorrectionPopin: false,
71
70
  showCorrectionPopin: false,
@@ -1,7 +1,6 @@
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';
5
4
  import {mapStateToSlidesProps} from '..';
6
5
  import {ProgressionFromAPI} from '../../../types/common';
7
6
  import {services} from '../../../test/util/services.mock';
@@ -67,7 +66,7 @@ test('should dispatch EDIT_QCM action via the property onClick of a QCM slide',
67
66
  ];
68
67
  const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
69
68
 
70
- const props = mapStateToSlidesProps(getState(), dispatch, identity);
69
+ const props = mapStateToSlidesProps(getState(), dispatch);
71
70
  t.deepEqual(omit('answerUI', props.stack.slides['0']), {
72
71
  animateCorrectionPopin: false,
73
72
  showCorrectionPopin: false,
@@ -1,7 +1,6 @@
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';
5
4
  import {mapStateToSlidesProps} from '..';
6
5
  import {ProgressionFromAPI} from '../../../types/common';
7
6
  import {services} from '../../../test/util/services.mock';
@@ -65,7 +64,7 @@ test('should dispatch EDIT_SLIDER action via the property onChange of a Slider s
65
64
  ];
66
65
  const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
67
66
 
68
- const props = mapStateToSlidesProps(getState(), dispatch, identity);
67
+ const props = mapStateToSlidesProps(getState(), dispatch);
69
68
  t.deepEqual(omit('answerUI', props.stack.slides['0']), {
70
69
  animateCorrectionPopin: false,
71
70
  showCorrectionPopin: false,
@@ -0,0 +1,71 @@
1
+ import test from 'ava';
2
+ import get from 'lodash/fp/get';
3
+ import {ProgressionFromAPI} from '../../../types/common';
4
+ import {StoreState} from '../../../reducers';
5
+ import {mapStateToSlidesProps} from '..';
6
+ import {services} from '../../../test/util/services.mock';
7
+ import {createTestStore} from '../../../actions/test/create-test-store';
8
+ import {EDIT_SLIDER} from '../../../actions/ui/answers';
9
+ import {QuestionRange} from '../../../types/slides';
10
+ import {sliderSlide} from './fixtures/slider';
11
+
12
+ const progression: ProgressionFromAPI = {
13
+ _id: '123456789123',
14
+ content: {type: 'skill', ref: '_skill-ref'},
15
+ engine: {
16
+ ref: 'review'
17
+ },
18
+ state: {
19
+ allAnswers: [],
20
+ isCorrect: true,
21
+ nextContent: {
22
+ ref: sliderSlide._id,
23
+ type: 'slide'
24
+ },
25
+ pendingSlides: [],
26
+ slides: [],
27
+ step: {
28
+ current: 1
29
+ },
30
+ stars: 0
31
+ }
32
+ };
33
+
34
+ const initialState: StoreState = {
35
+ data: {
36
+ progression,
37
+ slides: {
38
+ [sliderSlide._id]: sliderSlide
39
+ },
40
+ skills: [],
41
+ token: '1234',
42
+ corrections: {},
43
+ rank: {}
44
+ },
45
+ ui: {
46
+ currentSlideRef: sliderSlide._id,
47
+ navigation: ['skills', 'slides'],
48
+ answers: [],
49
+ slide: {
50
+ validateButton: false
51
+ }
52
+ }
53
+ };
54
+
55
+ test('should dispatch EDIT_SLIDER action via the property onSliderChange of a Slider slide', t => {
56
+ t.plan(1);
57
+
58
+ const expectedActions = [
59
+ {
60
+ type: EDIT_SLIDER,
61
+ payload: ['111']
62
+ }
63
+ ];
64
+ const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
65
+ const props = mapStateToSlidesProps(getState(), dispatch);
66
+
67
+ const SlideProps = props.stack.slides['0'].answerUI?.model as QuestionRange;
68
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
69
+ const onSliderChange = get('onSliderChange', SlideProps)!;
70
+ onSliderChange(111);
71
+ });
@@ -1,7 +1,6 @@
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';
5
4
  import {mapStateToSlidesProps} from '..';
6
5
  import {ProgressionFromAPI} from '../../../types/common';
7
6
  import {services} from '../../../test/util/services.mock';
@@ -60,7 +59,7 @@ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Templa
60
59
  const expectedActions = [{type: EDIT_TEMPLATE, payload: ['', 'test', '']}];
61
60
  const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
62
61
 
63
- const props = mapStateToSlidesProps(getState(), dispatch, identity);
62
+ const props = mapStateToSlidesProps(getState(), dispatch);
64
63
  t.deepEqual(omit('answerUI', props.stack.slides['0']), {
65
64
  animateCorrectionPopin: false,
66
65
  showCorrectionPopin: false,
@@ -82,7 +81,7 @@ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Templa
82
81
  const expectedActions = [{type: EDIT_TEMPLATE, payload: ['Catalogue', '', '']}];
83
82
  const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
84
83
 
85
- const props = mapStateToSlidesProps(getState(), dispatch, identity);
84
+ const props = mapStateToSlidesProps(getState(), dispatch);
86
85
  t.deepEqual(omit('answerUI', props.stack.slides['0']), {
87
86
  animateCorrectionPopin: false,
88
87
  showCorrectionPopin: false,