@coorpacademy/app-review 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coorpacademy/app-review",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=16.15.0"
@@ -42,7 +42,7 @@
42
42
  "./package.json": "./package.json"
43
43
  },
44
44
  "dependencies": {
45
- "@coorpacademy/components": "10.23.2",
45
+ "@coorpacademy/components": "10.23.4",
46
46
  "@coorpacademy/redux-task": "^1.1.5",
47
47
  "cross-fetch": "^3.1.5",
48
48
  "jwt-decode": "^3.1.2",
@@ -77,5 +77,5 @@
77
77
  "webpack-cli": "^3.3.11",
78
78
  "webpack-dev-server": "^3.11.0"
79
79
  },
80
- "gitHead": "e61dd34ad35298d25b20f60966d679a7f1f5657d"
80
+ "gitHead": "700c771b8e6b4fe3016654d938e0e28527fabc9e"
81
81
  }
@@ -98,4 +98,5 @@ test('should create initial props when skills on the state', t => {
98
98
  reviseAriaLabel: '@todo revise aria label'
99
99
  }
100
100
  ]);
101
+ t.notThrows(() => props.listSkills[0].onClick());
101
102
  });
@@ -1,15 +1,26 @@
1
1
  import test from 'ava';
2
2
  import omit from 'lodash/fp/omit';
3
- import get from 'lodash/fp/get';
4
3
  import identity from 'lodash/fp/identity';
4
+ import {POST_ANSWER_REQUEST, POST_ANSWER_SUCCESS} from '../../../actions/api/post-answer';
5
+ import {SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS} from '../../../actions/api/fetch-slide';
6
+ import {
7
+ CORRECTION_FETCH_REQUEST,
8
+ CORRECTION_FETCH_SUCCESS
9
+ } from '../../../actions/api/fetch-correction';
10
+ import {RANK_FETCH_START_REQUEST, RANK_FETCH_START_SUCCESS} from '../../../actions/api/fetch-rank';
5
11
  import {mapStateToSlidesProps} from '..';
6
12
  import {ProgressionFromAPI} from '../../../types/common';
7
- import {services} from '../../../test/util/services.mock';
13
+ import {
14
+ getChoicesCorrection,
15
+ postAnswerResponses,
16
+ services
17
+ } from '../../../test/util/services.mock';
8
18
  import {createTestStore} from '../../../actions/test/create-test-store';
9
19
  import {StoreState} from '../../../reducers';
10
20
  import {EDIT_BASIC} from '../../../actions/ui/answers';
11
21
  import {FreeText} from '../../../types/slides';
12
22
  import {freeTextSlide} from './fixtures/free-text';
23
+ import {qcmGraphicSlide} from './fixtures/qcm-graphic';
13
24
 
14
25
  const progression: ProgressionFromAPI = {
15
26
  _id: '123456789123',
@@ -58,15 +69,30 @@ const initialState: StoreState = {
58
69
  }
59
70
  };
60
71
 
61
- test('should dispatch EDIT_BASIC action via the property onChange of a Free Text slide', t => {
62
- t.plan(2);
63
-
72
+ test('should dispatch EDIT_BASIC action via the property onChange of a Free Text slide, and all actions after click on validate the slide', async t => {
73
+ t.plan(3);
64
74
  const expectedActions = [
65
75
  {
66
76
  type: EDIT_BASIC,
67
77
  meta: {slideRef: freeTextSlide._id},
68
78
  payload: ['My Answer']
69
- }
79
+ },
80
+ {type: POST_ANSWER_REQUEST, meta: {slideRef: freeTextSlide._id}},
81
+ {
82
+ type: POST_ANSWER_SUCCESS,
83
+ meta: {slideRef: freeTextSlide._id},
84
+ payload: postAnswerResponses[freeTextSlide._id]
85
+ },
86
+ {type: SLIDE_FETCH_REQUEST, meta: {slideRef: qcmGraphicSlide._id}},
87
+ {type: SLIDE_FETCH_SUCCESS, meta: {slideRef: qcmGraphicSlide._id}, payload: qcmGraphicSlide},
88
+ {type: CORRECTION_FETCH_REQUEST, meta: {slideRef: freeTextSlide._id}},
89
+ {
90
+ type: CORRECTION_FETCH_SUCCESS,
91
+ meta: {slideRef: freeTextSlide._id},
92
+ payload: getChoicesCorrection(freeTextSlide._id)
93
+ },
94
+ {type: RANK_FETCH_START_REQUEST},
95
+ {type: RANK_FETCH_START_SUCCESS, payload: {rank: 93}}
70
96
  ];
71
97
  const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
72
98
 
@@ -83,7 +109,7 @@ test('should dispatch EDIT_BASIC action via the property onChange of a Free Text
83
109
  'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
84
110
  });
85
111
 
86
- const SlideProps = props.stack.slides['0'].answerUI?.model as FreeText;
87
- const onChange = get('onChange', SlideProps);
88
- onChange('My Answer');
112
+ const slideProps = props.stack.slides['0'].answerUI?.model as FreeText;
113
+ await slideProps.onChange('My Answer');
114
+ await props.stack.validateButton.onClick();
89
115
  });
@@ -0,0 +1,64 @@
1
+ import test from 'ava';
2
+ import identity from 'lodash/fp/identity';
3
+ import type {StoreState} from '../../../reducers';
4
+ import {
5
+ getChoicesCorrection,
6
+ incorrectFreeTextPostAnswerResponse,
7
+ services
8
+ } from '../../../test/util/services.mock';
9
+ import {CorrectionPopinProps, mapStateToSlidesProps} from '..';
10
+ import {createTestStore} from '../../../actions/test/create-test-store';
11
+ import {NEXT_SLIDE} from '../../../actions/ui/next-slide';
12
+ import {freeTextSlide} from './fixtures/free-text';
13
+ import {qcmGraphicSlide} from './fixtures/qcm-graphic';
14
+
15
+ test('correction popin actions after click', async t => {
16
+ const state: StoreState = {
17
+ data: {
18
+ progression: incorrectFreeTextPostAnswerResponse,
19
+ skills: [],
20
+ slides: {
21
+ sli_VJYjJnJhg: freeTextSlide,
22
+ sli_VkSQroQnx: qcmGraphicSlide
23
+ },
24
+ token: '1234',
25
+ corrections: {
26
+ [freeTextSlide._id]: getChoicesCorrection(freeTextSlide._id, true)
27
+ },
28
+ rank: {}
29
+ },
30
+ ui: {
31
+ currentSlideRef: 'sli_VJYjJnJhg',
32
+ navigation: ['loader', 'slides'],
33
+ answers: {sli_VJYjJnJhg: ['My value']},
34
+ slide: {
35
+ sli_VJYjJnJhg: {
36
+ validateButton: false,
37
+ animateCorrectionPopin: true,
38
+ showCorrectionPopin: true
39
+ },
40
+ sli_VkSQroQnx: {
41
+ validateButton: false,
42
+ animateCorrectionPopin: false,
43
+ showCorrectionPopin: false
44
+ }
45
+ }
46
+ }
47
+ };
48
+
49
+ const expectedActions = [
50
+ {
51
+ type: NEXT_SLIDE,
52
+ payload: {
53
+ animationType: 'restack',
54
+ currentSlideRef: freeTextSlide._id,
55
+ nextSlideRef: qcmGraphicSlide._id
56
+ }
57
+ }
58
+ ];
59
+ const {dispatch, getState} = createTestStore(t, state, services, expectedActions);
60
+ const props = mapStateToSlidesProps(getState(), dispatch, identity);
61
+ const correctionPopin = props.stack.correctionPopinProps as CorrectionPopinProps;
62
+ await correctionPopin.next.onClick();
63
+ t.pass();
64
+ });
@@ -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 set from 'lodash/fp/set';
4
5
  import identity from 'lodash/fp/identity';
5
6
  import {mapStateToSlidesProps} from '..';
6
7
  import {ProgressionFromAPI} from '../../../types/common';
@@ -8,7 +9,7 @@ import {services} from '../../../test/util/services.mock';
8
9
  import {createTestStore} from '../../../actions/test/create-test-store';
9
10
  import {StoreState} from '../../../reducers';
10
11
  import {EDIT_TEMPLATE} from '../../../actions/ui/answers';
11
- import {Template} from '../../../types/slides';
12
+ import {Template, TextTemplate} from '../../../types/slides';
12
13
  import {templateSlide} from './fixtures/template';
13
14
 
14
15
  const progression: ProgressionFromAPI = {
@@ -58,11 +59,12 @@ const initialState: StoreState = {
58
59
  }
59
60
  };
60
61
 
61
- test('should dispatch EDIT_TEMPLATE action via the property onChange of a Template Text slide', t => {
62
- t.plan(2);
62
+ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Template Text and Select slide', t => {
63
+ t.plan(3);
63
64
 
64
65
  const expectedActions = [
65
- {type: EDIT_TEMPLATE, meta: {slideRef: templateSlide._id}, payload: ['', 'test', '']}
66
+ {type: EDIT_TEMPLATE, meta: {slideRef: templateSlide._id}, payload: ['', 'test', '']},
67
+ {type: EDIT_TEMPLATE, meta: {slideRef: templateSlide._id}, payload: ['Catalogue', '', '']}
66
68
  ];
67
69
  const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
68
70
 
@@ -79,17 +81,24 @@ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Templa
79
81
  });
80
82
 
81
83
  const SlideProps = props.stack.slides['0'].answerUI?.model as Template;
82
- const onChange = get(['1', 'onChange'], SlideProps.answers);
83
- onChange('test');
84
+ const onChangeText = get(['1', 'onChange'], SlideProps.answers);
85
+ onChangeText('test');
86
+ const onChangeSelect = get(['0', 'onChange'], SlideProps.answers);
87
+ onChangeSelect('Catalogue');
84
88
  });
85
89
 
86
- test('should dispatch EDIT_TEMPLATE action via the property onChange of a Template Select slide', t => {
87
- t.plan(2);
90
+ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Template Text with previous answer', t => {
91
+ t.plan(4);
88
92
 
89
93
  const expectedActions = [
90
- {type: EDIT_TEMPLATE, meta: {slideRef: templateSlide._id}, payload: ['Catalogue', '', '']}
94
+ {type: EDIT_TEMPLATE, meta: {slideRef: templateSlide._id}, payload: ['', '', '']}
91
95
  ];
92
- const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
96
+ const {dispatch, getState} = createTestStore(
97
+ t,
98
+ set(['ui', 'answers', templateSlide._id], ['', 'Test', ''], initialState),
99
+ services,
100
+ expectedActions
101
+ );
93
102
 
94
103
  const props = mapStateToSlidesProps(getState(), dispatch, identity);
95
104
  t.deepEqual(omit('answerUI', props.stack.slides['0']), {
@@ -104,6 +113,13 @@ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Templa
104
113
  });
105
114
 
106
115
  const SlideProps = props.stack.slides['0'].answerUI?.model as Template;
107
- const onChange = get(['0', 'onChange'], SlideProps.answers);
108
- onChange('Catalogue');
116
+ const textAnswerProps = SlideProps.answers[1] as TextTemplate;
117
+ t.is(textAnswerProps.value, 'Test');
118
+ const onChangeText = get(['1', 'onChange'], SlideProps.answers);
119
+ onChangeText('');
120
+
121
+ const newProps = mapStateToSlidesProps(getState(), dispatch, identity);
122
+ const SlidePropsAfterOnChange = newProps.stack.slides['0'].answerUI?.model as Template;
123
+ const textAnswerPropsAfterOnChange = SlidePropsAfterOnChange.answers[1] as TextTemplate;
124
+ t.is(textAnswerPropsAfterOnChange.value, '');
109
125
  });