@coorpacademy/app-review 0.5.0 → 0.5.1-alpha.26

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 (51) hide show
  1. package/es/actions/ui/quit-popin.d.ts +8 -0
  2. package/es/actions/ui/quit-popin.js +8 -0
  3. package/es/common/index.js +1 -1
  4. package/es/reducers/index.d.ts +6 -1
  5. package/es/reducers/ui/index.d.ts +8 -1
  6. package/es/reducers/ui/index.js +3 -1
  7. package/es/reducers/ui/quit-popin.d.ts +4 -0
  8. package/es/reducers/ui/quit-popin.js +16 -0
  9. package/es/views/slides/index.d.ts +18 -0
  10. package/es/views/slides/index.js +30 -2
  11. package/lib/actions/ui/quit-popin.d.ts +8 -0
  12. package/lib/actions/ui/quit-popin.js +8 -0
  13. package/lib/common/index.js +1 -1
  14. package/lib/reducers/index.d.ts +6 -1
  15. package/lib/reducers/ui/index.d.ts +8 -1
  16. package/lib/reducers/ui/index.js +3 -1
  17. package/lib/reducers/ui/quit-popin.d.ts +4 -0
  18. package/lib/reducers/ui/quit-popin.js +17 -0
  19. package/lib/views/slides/index.d.ts +18 -0
  20. package/lib/views/slides/index.js +32 -2
  21. package/package.json +9 -10
  22. package/src/actions/api/test/fetch-correction.test.ts +2 -1
  23. package/src/actions/api/test/fetch-rank.test.ts +2 -1
  24. package/src/actions/api/test/fetch-skills.test.ts +2 -1
  25. package/src/actions/api/test/fetch-slide.test.ts +2 -1
  26. package/src/actions/api/test/post-answer.test.ts +4 -2
  27. package/src/actions/api/test/post-progression.test.ts +2 -1
  28. package/src/actions/data/test/token.test.ts +2 -1
  29. package/src/actions/ui/quit-popin.ts +10 -0
  30. package/src/actions/ui/test/answers.test.ts +2 -1
  31. package/src/actions/ui/test/next-slide.test.ts +2 -1
  32. package/src/actions/ui/test/quit-popin.test.ts +38 -0
  33. package/src/actions/ui/test/slides.test.ts +2 -1
  34. package/src/common/index.ts +1 -1
  35. package/src/common/test/get-progression-slide-ref.test.ts +35 -0
  36. package/src/reducers/ui/index.ts +4 -1
  37. package/src/reducers/ui/quit-popin.ts +22 -0
  38. package/src/reducers/ui/test/quit-popin.test.ts +24 -0
  39. package/src/views/skills/test/skills.test.ts +4 -2
  40. package/src/views/slides/index.ts +52 -3
  41. package/src/views/slides/test/header.on-click.test.ts +42 -0
  42. package/src/views/slides/test/index.test.ts +53 -11
  43. package/src/views/slides/test/on-quit-popin.on-click.test.ts +64 -0
  44. package/src/views/slides/test/slide.free-text.on-change.test.ts +2 -1
  45. package/src/views/slides/test/slide.next-slide.on-click.test.ts +2 -1
  46. package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +2 -1
  47. package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +2 -1
  48. package/src/views/slides/test/slide.qcm.on-click.test.ts +2 -1
  49. package/src/views/slides/test/slide.slider.on-change.test.ts +2 -1
  50. package/src/views/slides/test/slide.slider.on-slider-change.test.ts +2 -1
  51. package/src/views/slides/test/slide.template.on-change.test.ts +2 -1
@@ -0,0 +1,8 @@
1
+ export declare const OPEN_POPIN: "@@ui/OPEN_POPIN";
2
+ export declare const CLOSE_POPIN: "@@ui/CLOSE_POPIN";
3
+ export declare const openQuitPopin: {
4
+ type: "@@ui/OPEN_POPIN";
5
+ };
6
+ export declare const closeQuitPopin: {
7
+ type: "@@ui/CLOSE_POPIN";
8
+ };
@@ -0,0 +1,8 @@
1
+ export const OPEN_POPIN = '@@ui/OPEN_POPIN';
2
+ export const CLOSE_POPIN = '@@ui/CLOSE_POPIN';
3
+ export const openQuitPopin = {
4
+ type: OPEN_POPIN
5
+ };
6
+ export const closeQuitPopin = {
7
+ type: CLOSE_POPIN
8
+ };
@@ -7,7 +7,7 @@ export const VIEWS = {
7
7
  };
8
8
  export const slideIndexes = ['0', '1', '2', '3', '4'];
9
9
  export const getProgressionSlidesRefs = (progression) => {
10
- if (progression.state.step.current < 5) {
10
+ if (progression.state.step.current <= 5) {
11
11
  const slideRef = progression.state.nextContent.ref;
12
12
  return concat(progression.state.slides, [slideRef]);
13
13
  }
@@ -19,6 +19,11 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
19
19
  answers: import("./ui/answers").UIAnswerState;
20
20
  slide: import("./ui/slide").UISlideState;
21
21
  positions: import("./ui/positions").UIPositionState;
22
+ showQuitPopin: boolean;
22
23
  }>;
23
- }>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/fetch-rank").RankAction | 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/next-slide").NextSlideAction | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction>;
24
+ }>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/fetch-rank").RankAction | 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/next-slide").NextSlideAction | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction | {
25
+ type: "@@ui/OPEN_POPIN";
26
+ } | {
27
+ type: "@@ui/CLOSE_POPIN";
28
+ }>;
24
29
  export default _default;
@@ -3,12 +3,14 @@ import { NavigationState } from './navigation';
3
3
  import { UIAnswerState } from './answers';
4
4
  import { UIPositionState } from './positions';
5
5
  import { UISlideState } from './slide';
6
+ import { type ShowQuitPopinState } from './quit-popin';
6
7
  export declare type UIState = {
7
8
  currentSlideRef: CurrentSlideRefState;
8
9
  navigation: NavigationState;
9
10
  answers: UIAnswerState;
10
11
  slide: UISlideState;
11
12
  positions: UIPositionState;
13
+ showQuitPopin: ShowQuitPopinState;
12
14
  };
13
15
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
14
16
  currentSlideRef: string;
@@ -16,5 +18,10 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
16
18
  answers: UIAnswerState;
17
19
  slide: UISlideState;
18
20
  positions: UIPositionState;
19
- }>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlideAction | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/ui/next-slide").NextSlideAction | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction>;
21
+ showQuitPopin: boolean;
22
+ }>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlideAction | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/ui/next-slide").NextSlideAction | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction | {
23
+ type: "@@ui/OPEN_POPIN";
24
+ } | {
25
+ type: "@@ui/CLOSE_POPIN";
26
+ }>;
20
27
  export default _default;
@@ -4,10 +4,12 @@ import navigation from './navigation';
4
4
  import answers from './answers';
5
5
  import positions from './positions';
6
6
  import slide from './slide';
7
+ import showQuitPopin from './quit-popin';
7
8
  export default combineReducers({
8
9
  currentSlideRef,
9
10
  navigation,
10
11
  answers,
11
12
  slide,
12
- positions
13
+ positions,
14
+ showQuitPopin
13
15
  });
@@ -0,0 +1,4 @@
1
+ import { closeQuitPopin, openQuitPopin } from '../../actions/ui/quit-popin';
2
+ export declare type ShowQuitPopinState = boolean;
3
+ declare const reducer: (state: boolean | undefined, action: typeof openQuitPopin | typeof closeQuitPopin) => ShowQuitPopinState;
4
+ export default reducer;
@@ -0,0 +1,16 @@
1
+ import { CLOSE_POPIN, OPEN_POPIN } from '../../actions/ui/quit-popin';
2
+ const reducer = (
3
+ // eslint-disable-next-line default-param-last
4
+ state = false, action) => {
5
+ switch (action.type) {
6
+ case OPEN_POPIN: {
7
+ return true;
8
+ }
9
+ case CLOSE_POPIN: {
10
+ return false;
11
+ }
12
+ default:
13
+ return state;
14
+ }
15
+ };
16
+ export default reducer;
@@ -40,6 +40,15 @@ declare type CorrectionPopinNext = {
40
40
  ariaLabel: string;
41
41
  onClick: Function;
42
42
  };
43
+ declare type QuitPopinButton = {
44
+ label: string;
45
+ type: string;
46
+ customStyle?: {
47
+ color: string;
48
+ };
49
+ handleOnclick: Function;
50
+ ariaLabel: string;
51
+ };
43
52
  export declare type CorrectionPopinProps = {
44
53
  klf?: CorrectionPopinKlf;
45
54
  information: CorrectionPopinInformation;
@@ -47,6 +56,14 @@ export declare type CorrectionPopinProps = {
47
56
  resultLabel: string;
48
57
  type: 'right' | 'wrong';
49
58
  };
59
+ export declare type QuitPopinProps = {
60
+ content: string;
61
+ icon: string;
62
+ mode: string;
63
+ descriptionText: string;
64
+ firstButton: QuitPopinButton;
65
+ secondButton: QuitPopinButton;
66
+ };
50
67
  export declare type SlidesViewProps = {
51
68
  header: {
52
69
  mode: string;
@@ -87,6 +104,7 @@ export declare type SlidesViewProps = {
87
104
  type: string;
88
105
  };
89
106
  };
107
+ quitPopin?: QuitPopinProps;
90
108
  };
91
109
  export declare const initialState: SlidesStack;
92
110
  export declare const buildStepItems: (state: StoreState) => StepItem[];
@@ -6,6 +6,7 @@ import reduce from 'lodash/fp/reduce';
6
6
  import set from 'lodash/fp/set';
7
7
  import toInteger from 'lodash/fp/toInteger';
8
8
  import join from 'lodash/fp/join';
9
+ import { closeQuitPopin, openQuitPopin } from '../../actions/ui/quit-popin';
9
10
  import { getProgressionSlidesRefs } from '../../common';
10
11
  import { postAnswer } from '../../actions/api/post-answer';
11
12
  import { nextSlide } from '../../actions/ui/next-slide';
@@ -168,16 +169,42 @@ const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf) =>
168
169
  type: isCorrect ? 'right' : 'wrong'
169
170
  };
170
171
  };
172
+ const buildQuitPopinProps = (dispatch) => (onQuitClick) => {
173
+ return {
174
+ content: `Tu t'en vas déjà ?`,
175
+ icon: `MoonRocket`,
176
+ mode: 'alert',
177
+ descriptionText: `Tu vas t'en sortir ! Si tu arrêtes maintenant, tu vas perdre ta progression.`,
178
+ firstButton: {
179
+ label: 'Arrêter ma session',
180
+ type: 'tertiary',
181
+ customStyle: {
182
+ color: '#ED3436'
183
+ },
184
+ handleOnclick: onQuitClick,
185
+ ariaLabel: 'Stop session'
186
+ },
187
+ secondButton: {
188
+ label: `Continuer d'apprendre`,
189
+ type: 'primary',
190
+ handleOnclick: () => {
191
+ dispatch(closeQuitPopin);
192
+ },
193
+ ariaLabel: 'Continue review'
194
+ }
195
+ };
196
+ };
171
197
  export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
172
198
  const currentSlideRef = get(['ui', 'currentSlideRef'], state);
173
199
  const correction = get(['data', 'corrections', currentSlideRef], state);
174
200
  const isCorrect = get(['data', 'progression', 'state', 'isCorrect'], state);
175
201
  const klf = getOr('', ['data', 'slides', currentSlideRef, 'klf'], state);
202
+ const showQuitPopin = get(['ui', 'showQuitPopin'], state);
176
203
  return {
177
204
  header: {
178
205
  mode: '__revision_mode',
179
206
  skillName: '__agility',
180
- onQuitClick,
207
+ onQuitClick: () => dispatch(openQuitPopin),
181
208
  'aria-label': 'aria-header-wrapper',
182
209
  closeButtonAriaLabel: 'aria-close-button',
183
210
  steps: buildStepItems(state)
@@ -194,6 +221,7 @@ export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
194
221
  correctionPopinProps: correction && getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf),
195
222
  endReview: false
196
223
  },
197
- congrats: undefined
224
+ congrats: undefined,
225
+ quitPopin: showQuitPopin === true ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
198
226
  };
199
227
  };
@@ -0,0 +1,8 @@
1
+ export declare const OPEN_POPIN: "@@ui/OPEN_POPIN";
2
+ export declare const CLOSE_POPIN: "@@ui/CLOSE_POPIN";
3
+ export declare const openQuitPopin: {
4
+ type: "@@ui/OPEN_POPIN";
5
+ };
6
+ export declare const closeQuitPopin: {
7
+ type: "@@ui/CLOSE_POPIN";
8
+ };
@@ -0,0 +1,8 @@
1
+ export var OPEN_POPIN = '@@ui/OPEN_POPIN';
2
+ export var CLOSE_POPIN = '@@ui/CLOSE_POPIN';
3
+ export var openQuitPopin = {
4
+ type: OPEN_POPIN
5
+ };
6
+ export var closeQuitPopin = {
7
+ type: CLOSE_POPIN
8
+ };
@@ -7,7 +7,7 @@ export var VIEWS = {
7
7
  };
8
8
  export var slideIndexes = ['0', '1', '2', '3', '4'];
9
9
  export var getProgressionSlidesRefs = function (progression) {
10
- if (progression.state.step.current < 5) {
10
+ if (progression.state.step.current <= 5) {
11
11
  var slideRef = progression.state.nextContent.ref;
12
12
  return concat(progression.state.slides, [slideRef]);
13
13
  }
@@ -19,6 +19,11 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
19
19
  answers: import("./ui/answers").UIAnswerState;
20
20
  slide: import("./ui/slide").UISlideState;
21
21
  positions: import("./ui/positions").UIPositionState;
22
+ showQuitPopin: boolean;
22
23
  }>;
23
- }>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/fetch-rank").RankAction | 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/next-slide").NextSlideAction | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction>;
24
+ }>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/fetch-rank").RankAction | 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/next-slide").NextSlideAction | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction | {
25
+ type: "@@ui/OPEN_POPIN";
26
+ } | {
27
+ type: "@@ui/CLOSE_POPIN";
28
+ }>;
24
29
  export default _default;
@@ -3,12 +3,14 @@ import { NavigationState } from './navigation';
3
3
  import { UIAnswerState } from './answers';
4
4
  import { UIPositionState } from './positions';
5
5
  import { UISlideState } from './slide';
6
+ import { type ShowQuitPopinState } from './quit-popin';
6
7
  export declare type UIState = {
7
8
  currentSlideRef: CurrentSlideRefState;
8
9
  navigation: NavigationState;
9
10
  answers: UIAnswerState;
10
11
  slide: UISlideState;
11
12
  positions: UIPositionState;
13
+ showQuitPopin: ShowQuitPopinState;
12
14
  };
13
15
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
14
16
  currentSlideRef: string;
@@ -16,5 +18,10 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
16
18
  answers: UIAnswerState;
17
19
  slide: UISlideState;
18
20
  positions: UIPositionState;
19
- }>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlideAction | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/ui/next-slide").NextSlideAction | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction>;
21
+ showQuitPopin: boolean;
22
+ }>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlideAction | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/ui/next-slide").NextSlideAction | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction | {
23
+ type: "@@ui/OPEN_POPIN";
24
+ } | {
25
+ type: "@@ui/CLOSE_POPIN";
26
+ }>;
20
27
  export default _default;
@@ -4,10 +4,12 @@ import navigation from './navigation';
4
4
  import answers from './answers';
5
5
  import positions from './positions';
6
6
  import slide from './slide';
7
+ import showQuitPopin from './quit-popin';
7
8
  export default combineReducers({
8
9
  currentSlideRef: currentSlideRef,
9
10
  navigation: navigation,
10
11
  answers: answers,
11
12
  slide: slide,
12
- positions: positions
13
+ positions: positions,
14
+ showQuitPopin: showQuitPopin
13
15
  });
@@ -0,0 +1,4 @@
1
+ import { closeQuitPopin, openQuitPopin } from '../../actions/ui/quit-popin';
2
+ export declare type ShowQuitPopinState = boolean;
3
+ declare const reducer: (state: boolean | undefined, action: typeof openQuitPopin | typeof closeQuitPopin) => ShowQuitPopinState;
4
+ export default reducer;
@@ -0,0 +1,17 @@
1
+ import { CLOSE_POPIN, OPEN_POPIN } from '../../actions/ui/quit-popin';
2
+ var reducer = function (
3
+ // eslint-disable-next-line default-param-last
4
+ state, action) {
5
+ if (state === void 0) { state = false; }
6
+ switch (action.type) {
7
+ case OPEN_POPIN: {
8
+ return true;
9
+ }
10
+ case CLOSE_POPIN: {
11
+ return false;
12
+ }
13
+ default:
14
+ return state;
15
+ }
16
+ };
17
+ export default reducer;
@@ -40,6 +40,15 @@ declare type CorrectionPopinNext = {
40
40
  ariaLabel: string;
41
41
  onClick: Function;
42
42
  };
43
+ declare type QuitPopinButton = {
44
+ label: string;
45
+ type: string;
46
+ customStyle?: {
47
+ color: string;
48
+ };
49
+ handleOnclick: Function;
50
+ ariaLabel: string;
51
+ };
43
52
  export declare type CorrectionPopinProps = {
44
53
  klf?: CorrectionPopinKlf;
45
54
  information: CorrectionPopinInformation;
@@ -47,6 +56,14 @@ export declare type CorrectionPopinProps = {
47
56
  resultLabel: string;
48
57
  type: 'right' | 'wrong';
49
58
  };
59
+ export declare type QuitPopinProps = {
60
+ content: string;
61
+ icon: string;
62
+ mode: string;
63
+ descriptionText: string;
64
+ firstButton: QuitPopinButton;
65
+ secondButton: QuitPopinButton;
66
+ };
50
67
  export declare type SlidesViewProps = {
51
68
  header: {
52
69
  mode: string;
@@ -87,6 +104,7 @@ export declare type SlidesViewProps = {
87
104
  type: string;
88
105
  };
89
106
  };
107
+ quitPopin?: QuitPopinProps;
90
108
  };
91
109
  export declare const initialState: SlidesStack;
92
110
  export declare const buildStepItems: (state: StoreState) => StepItem[];
@@ -17,6 +17,7 @@ import reduce from 'lodash/fp/reduce';
17
17
  import set from 'lodash/fp/set';
18
18
  import toInteger from 'lodash/fp/toInteger';
19
19
  import join from 'lodash/fp/join';
20
+ import { closeQuitPopin, openQuitPopin } from '../../actions/ui/quit-popin';
20
21
  import { getProgressionSlidesRefs } from '../../common';
21
22
  import { postAnswer } from '../../actions/api/post-answer';
22
23
  import { nextSlide } from '../../actions/ui/next-slide';
@@ -164,16 +165,44 @@ var getCorrectionPopinProps = function (dispatch) {
164
165
  };
165
166
  };
166
167
  };
168
+ var buildQuitPopinProps = function (dispatch) {
169
+ return function (onQuitClick) {
170
+ return {
171
+ content: "Tu t'en vas d\u00E9j\u00E0 ?",
172
+ icon: "MoonRocket",
173
+ mode: 'alert',
174
+ descriptionText: "Tu vas t'en sortir ! Si tu arr\u00EAtes maintenant, tu vas perdre ta progression.",
175
+ firstButton: {
176
+ label: 'Arrêter ma session',
177
+ type: 'tertiary',
178
+ customStyle: {
179
+ color: '#ED3436'
180
+ },
181
+ handleOnclick: onQuitClick,
182
+ ariaLabel: 'Stop session'
183
+ },
184
+ secondButton: {
185
+ label: "Continuer d'apprendre",
186
+ type: 'primary',
187
+ handleOnclick: function () {
188
+ dispatch(closeQuitPopin);
189
+ },
190
+ ariaLabel: 'Continue review'
191
+ }
192
+ };
193
+ };
194
+ };
167
195
  export var mapStateToSlidesProps = function (state, dispatch, onQuitClick) {
168
196
  var currentSlideRef = get(['ui', 'currentSlideRef'], state);
169
197
  var correction = get(['data', 'corrections', currentSlideRef], state);
170
198
  var isCorrect = get(['data', 'progression', 'state', 'isCorrect'], state);
171
199
  var klf = getOr('', ['data', 'slides', currentSlideRef, 'klf'], state);
200
+ var showQuitPopin = get(['ui', 'showQuitPopin'], state);
172
201
  return {
173
202
  header: {
174
203
  mode: '__revision_mode',
175
204
  skillName: '__agility',
176
- onQuitClick: onQuitClick,
205
+ onQuitClick: function () { return dispatch(openQuitPopin); },
177
206
  'aria-label': 'aria-header-wrapper',
178
207
  closeButtonAriaLabel: 'aria-close-button',
179
208
  steps: buildStepItems(state)
@@ -190,6 +219,7 @@ export var mapStateToSlidesProps = function (state, dispatch, onQuitClick) {
190
219
  correctionPopinProps: correction && getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf),
191
220
  endReview: false
192
221
  },
193
- congrats: undefined
222
+ congrats: undefined,
223
+ quitPopin: showQuitPopin === true ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
194
224
  };
195
225
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coorpacademy/app-review",
3
- "version": "0.5.0",
3
+ "version": "0.5.1-alpha.26+f825a15a6",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=16.15.0"
@@ -9,7 +9,7 @@
9
9
  "scripts": {
10
10
  "static": "webpack --progress --output-path static/dist",
11
11
  "poststatic": "cp sandbox/index.html static/index.html",
12
- "start": "cross-env BABEL_ENV=es webpack-dev-server --content-base sandbox --host 0.0.0.0 --history-api-fallback true --hot true",
12
+ "start": "cross-env BABEL_ENV=es webpack-dev-server",
13
13
  "prepare": "npm run clean && npm run build --production",
14
14
  "build:commonjs": "tsc -p tsconfig.lib.json",
15
15
  "build:es": "tsc -p tsconfig.es.json",
@@ -44,10 +44,10 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@coorpacademy/components": "10.23.8",
47
- "@coorpacademy/redux-task": "^1.1.5",
47
+ "@coorpacademy/redux-task": "1.1.5",
48
48
  "cross-fetch": "^3.1.5",
49
49
  "jwt-decode": "^3.1.2",
50
- "react-redux": "7.2.8",
50
+ "react-redux": "^7.2.9",
51
51
  "redux": "^4.2.0",
52
52
  "redux-thunk": "^2.4.1"
53
53
  },
@@ -66,17 +66,16 @@
66
66
  "ava": "^4.3.0",
67
67
  "browser-env": "^3.3.0",
68
68
  "concurrently": "^5.2.0",
69
- "dotenv": "^16.0.1",
70
69
  "eslint": "^8.18.0",
71
70
  "eslint-plugin-react-hooks": "^4.6.0",
72
71
  "nock": "^13.2.9",
73
72
  "react-dom": "^17.0.2",
74
- "ts-loader": "^8.2.0",
73
+ "ts-loader": "^9.4.1",
75
74
  "ts-node": "^10.9.1",
76
75
  "typescript": "^4.7.4",
77
- "webpack": "^4.43.0",
78
- "webpack-cli": "^3.3.11",
79
- "webpack-dev-server": "^3.11.0"
76
+ "webpack": "^5.74.0",
77
+ "webpack-cli": "^4.10.0",
78
+ "webpack-dev-server": "^4.11.1"
80
79
  },
81
- "gitHead": "ef2f2340a0169672d5880e8fb9900cd7c7ebf12c"
80
+ "gitHead": "f825a15a6a6ff42539c9f4848db71ea526cad455"
82
81
  }
@@ -43,7 +43,8 @@ const initialState: StoreState = {
43
43
  animateCorrectionPopin: false,
44
44
  showCorrectionPopin: false
45
45
  }
46
- }
46
+ },
47
+ showQuitPopin: false
47
48
  }
48
49
  };
49
50
 
@@ -28,7 +28,8 @@ const initialState: StoreState = {
28
28
  currentSlideRef: '',
29
29
  navigation: [],
30
30
  answers: {},
31
- slide: {}
31
+ slide: {},
32
+ showQuitPopin: false
32
33
  }
33
34
  };
34
35
 
@@ -24,7 +24,8 @@ const initialState: StoreState = {
24
24
  currentSlideRef: '',
25
25
  navigation: [],
26
26
  answers: {},
27
- slide: {}
27
+ slide: {},
28
+ showQuitPopin: false
28
29
  }
29
30
  };
30
31
 
@@ -26,7 +26,8 @@ const initialState: StoreState = {
26
26
  currentSlideRef: '',
27
27
  navigation: [],
28
28
  answers: {},
29
- slide: {}
29
+ slide: {},
30
+ showQuitPopin: false
30
31
  }
31
32
  };
32
33
 
@@ -75,7 +75,8 @@ const initialState: StoreState = {
75
75
  animateCorrectionPopin: false,
76
76
  showCorrectionPopin: false
77
77
  }
78
- }
78
+ },
79
+ showQuitPopin: false
79
80
  }
80
81
  };
81
82
 
@@ -177,7 +178,8 @@ test('should dispatch post-answer, fetch-correction and fetch-end-rank actions w
177
178
  animateCorrectionPopin: false,
178
179
  showCorrectionPopin: false
179
180
  }
180
- }
181
+ },
182
+ showQuitPopin: false
181
183
  }
182
184
  };
183
185
 
@@ -27,7 +27,8 @@ const initialState: StoreState = {
27
27
  currentSlideRef: '',
28
28
  navigation: [],
29
29
  answers: {},
30
- slide: {}
30
+ slide: {},
31
+ showQuitPopin: false
31
32
  }
32
33
  };
33
34
 
@@ -18,7 +18,8 @@ const initialState: StoreState = {
18
18
  currentSlideRef: '',
19
19
  navigation: [],
20
20
  answers: {},
21
- slide: {}
21
+ slide: {},
22
+ showQuitPopin: false
22
23
  }
23
24
  };
24
25
 
@@ -0,0 +1,10 @@
1
+ export const OPEN_POPIN = '@@ui/OPEN_POPIN' as const;
2
+ export const CLOSE_POPIN = '@@ui/CLOSE_POPIN' as const;
3
+
4
+ export const openQuitPopin = {
5
+ type: OPEN_POPIN
6
+ };
7
+
8
+ export const closeQuitPopin = {
9
+ type: CLOSE_POPIN
10
+ };
@@ -53,7 +53,8 @@ const initialState: StoreState = {
53
53
  currentSlideRef: '',
54
54
  navigation: [],
55
55
  answers: {},
56
- slide: {}
56
+ slide: {},
57
+ showQuitPopin: false
57
58
  }
58
59
  };
59
60
 
@@ -41,7 +41,8 @@ const state: StoreState = {
41
41
  animateCorrectionPopin: true,
42
42
  showCorrectionPopin: true
43
43
  }
44
- }
44
+ },
45
+ showQuitPopin: false
45
46
  }
46
47
  };
47
48
  test('should dispatch NEXT_SLIDE action when nextSlide is called and the progression state is correct', t => {
@@ -0,0 +1,38 @@
1
+ import test from 'ava';
2
+ import {createTestStore} from '../../test/create-test-store';
3
+ import type {StoreState} from '../../../reducers';
4
+ import {closeQuitPopin, CLOSE_POPIN, openQuitPopin, OPEN_POPIN} from '../quit-popin';
5
+ import {services} from '../../../test/util/services.mock';
6
+
7
+ const initialState: StoreState = {
8
+ data: {
9
+ progression: null,
10
+ slides: {},
11
+ skills: [],
12
+ token: '1234',
13
+ corrections: {},
14
+ rank: {}
15
+ },
16
+ ui: {
17
+ currentSlideRef: '',
18
+ navigation: [],
19
+ answers: {},
20
+ slide: {},
21
+ positions: [],
22
+ showQuitPopin: false
23
+ }
24
+ };
25
+
26
+ test('should dispatch OPEN_POPIN when openQuitPopin action is called', async t => {
27
+ const expectedAction = [{type: OPEN_POPIN}];
28
+
29
+ const {dispatch} = createTestStore(t, initialState, services, expectedAction);
30
+ await dispatch(openQuitPopin);
31
+ });
32
+
33
+ test('should dispatch CLOSE_POPIN when closeQuitPopin action is called', async t => {
34
+ const expectedAction = [{type: CLOSE_POPIN}];
35
+
36
+ const {dispatch} = createTestStore(t, initialState, services, expectedAction);
37
+ await dispatch(closeQuitPopin);
38
+ });
@@ -19,7 +19,8 @@ const initialState: StoreState = {
19
19
  navigation: [],
20
20
  positions: [0, 1, 2, 3, 4],
21
21
  answers: {},
22
- slide: {}
22
+ slide: {},
23
+ showQuitPopin: false
23
24
  }
24
25
  };
25
26
 
@@ -17,7 +17,7 @@ export const slideIndexes = ['0', '1', '2', '3', '4'] as const;
17
17
  export type SlideIndexes = typeof slideIndexes[number];
18
18
 
19
19
  export const getProgressionSlidesRefs = (progression: ProgressionFromAPI): string[] => {
20
- if (progression.state.step.current < 5) {
20
+ if (progression.state.step.current <= 5) {
21
21
  const slideRef = progression.state.nextContent.ref;
22
22
  return concat(progression.state.slides, [slideRef]);
23
23
  }
@@ -0,0 +1,35 @@
1
+ import test from 'ava';
2
+ import {
3
+ postAnswerResponses,
4
+ postProgressionResponse,
5
+ progressionSlideWithPendingSlide
6
+ } from '../../test/util/services.mock';
7
+ import {templateSlide} from '../../views/slides/test/fixtures/template';
8
+ import {getProgressionSlidesRefs} from '..';
9
+
10
+ test('should return first slide for a created slide', t => {
11
+ const slides = getProgressionSlidesRefs(postProgressionResponse);
12
+ t.deepEqual(slides, ['sli_VJYjJnJhg']);
13
+ });
14
+
15
+ test('should return all 5 slides when user is going to answer the 5th slide', t => {
16
+ const slides = getProgressionSlidesRefs(postAnswerResponses[templateSlide._id]);
17
+ t.deepEqual(slides, [
18
+ 'sli_VJYjJnJhg',
19
+ 'sli_VkSQroQnx',
20
+ 'sli_N1XACJobn',
21
+ 'sli_VkAzsCLKb',
22
+ 'sli_N13-hG3kX'
23
+ ]);
24
+ });
25
+
26
+ test('should return all 5 slides when progression has a nextContent ref that is a pending slide', t => {
27
+ const slides = getProgressionSlidesRefs(progressionSlideWithPendingSlide);
28
+ t.deepEqual(slides, [
29
+ 'sli_VJYjJnJhg',
30
+ 'sli_VkSQroQnx',
31
+ 'sli_N1XACJobn',
32
+ 'sli_VkAzsCLKb',
33
+ 'sli_N13-hG3kX'
34
+ ]);
35
+ });
@@ -5,6 +5,7 @@ import navigation, {NavigationState} from './navigation';
5
5
  import answers, {UIAnswerState} from './answers';
6
6
  import positions, {UIPositionState} from './positions';
7
7
  import slide, {UISlideState} from './slide';
8
+ import showQuitPopin, {type ShowQuitPopinState} from './quit-popin';
8
9
 
9
10
  export type UIState = {
10
11
  currentSlideRef: CurrentSlideRefState;
@@ -12,6 +13,7 @@ export type UIState = {
12
13
  answers: UIAnswerState;
13
14
  slide: UISlideState;
14
15
  positions: UIPositionState;
16
+ showQuitPopin: ShowQuitPopinState;
15
17
  };
16
18
 
17
19
  export default combineReducers({
@@ -19,5 +21,6 @@ export default combineReducers({
19
21
  navigation,
20
22
  answers,
21
23
  slide,
22
- positions
24
+ positions,
25
+ showQuitPopin
23
26
  });
@@ -0,0 +1,22 @@
1
+ import {closeQuitPopin, CLOSE_POPIN, openQuitPopin, OPEN_POPIN} from '../../actions/ui/quit-popin';
2
+
3
+ export type ShowQuitPopinState = boolean;
4
+
5
+ const reducer = (
6
+ // eslint-disable-next-line default-param-last
7
+ state: ShowQuitPopinState = false,
8
+ action: typeof openQuitPopin | typeof closeQuitPopin
9
+ ): ShowQuitPopinState => {
10
+ switch (action.type) {
11
+ case OPEN_POPIN: {
12
+ return true;
13
+ }
14
+ case CLOSE_POPIN: {
15
+ return false;
16
+ }
17
+ default:
18
+ return state;
19
+ }
20
+ };
21
+
22
+ export default reducer;
@@ -0,0 +1,24 @@
1
+ import test from 'ava';
2
+ import {CLOSE_POPIN, OPEN_POPIN} from '../../../actions/ui/quit-popin';
3
+ import reducer from '../quit-popin';
4
+
5
+ test('should have showQuitPopin intial value to false', t => {
6
+ const state = reducer(undefined, {
7
+ type: '@@ui/CLOSE_POPIN'
8
+ });
9
+ t.is(state, false);
10
+ });
11
+
12
+ test('should set showQuitPopin to true if OPEN_POPIN is received', t => {
13
+ const state = reducer(false, {
14
+ type: OPEN_POPIN
15
+ });
16
+ t.is(state, true);
17
+ });
18
+
19
+ test('should set showQuitPopin to false if CLOSE_POPIN is received', t => {
20
+ const state = reducer(true, {
21
+ type: CLOSE_POPIN
22
+ });
23
+ t.is(state, false);
24
+ });
@@ -19,7 +19,8 @@ test('should create initial props when there are no skills on the state', t => {
19
19
  positions: [0, 1, 2, 3, 4],
20
20
  navigation: ['loader', 'skills'],
21
21
  answers: {},
22
- slide: {}
22
+ slide: {},
23
+ showQuitPopin: false
23
24
  }
24
25
  };
25
26
 
@@ -64,7 +65,8 @@ test('should create initial props when skills on the state', t => {
64
65
  positions: [0, 1, 2, 3, 4],
65
66
  navigation: ['loader', 'skills'],
66
67
  answers: {},
67
- slide: {}
68
+ slide: {},
69
+ showQuitPopin: false
68
70
  }
69
71
  };
70
72
 
@@ -7,6 +7,7 @@ import set from 'lodash/fp/set';
7
7
  import toInteger from 'lodash/fp/toInteger';
8
8
  import type {Dispatch} from 'redux';
9
9
  import join from 'lodash/fp/join';
10
+ import {closeQuitPopin, openQuitPopin} from '../../actions/ui/quit-popin';
10
11
  import type {ProgressionAnswerItem} from '../../types/common';
11
12
  import {getProgressionSlidesRefs, type SlideIndexes} from '../../common';
12
13
  import type {StoreState} from '../../reducers';
@@ -62,6 +63,16 @@ type CorrectionPopinNext = {
62
63
  onClick: Function;
63
64
  };
64
65
 
66
+ type QuitPopinButton = {
67
+ label: string;
68
+ type: string;
69
+ customStyle?: {
70
+ color: string;
71
+ };
72
+ handleOnclick: Function;
73
+ ariaLabel: string;
74
+ };
75
+
65
76
  export type CorrectionPopinProps = {
66
77
  klf?: CorrectionPopinKlf;
67
78
  information: CorrectionPopinInformation;
@@ -70,6 +81,15 @@ export type CorrectionPopinProps = {
70
81
  type: 'right' | 'wrong';
71
82
  };
72
83
 
84
+ export type QuitPopinProps = {
85
+ content: string;
86
+ icon: string;
87
+ mode: string;
88
+ descriptionText: string;
89
+ firstButton: QuitPopinButton;
90
+ secondButton: QuitPopinButton;
91
+ };
92
+
73
93
  export type SlidesViewProps = {
74
94
  header: {
75
95
  mode: string;
@@ -110,6 +130,7 @@ export type SlidesViewProps = {
110
130
  type: string;
111
131
  };
112
132
  };
133
+ quitPopin?: QuitPopinProps;
113
134
  };
114
135
 
115
136
  // TODO replace this, position no more needed
@@ -293,6 +314,33 @@ const getCorrectionPopinProps =
293
314
  };
294
315
  };
295
316
 
317
+ const buildQuitPopinProps =
318
+ (dispatch: Dispatch) =>
319
+ (onQuitClick: Function): QuitPopinProps => {
320
+ return {
321
+ content: `Tu t'en vas déjà ?`,
322
+ icon: `MoonRocket`,
323
+ mode: 'alert',
324
+ descriptionText: `Tu vas t'en sortir ! Si tu arrêtes maintenant, tu vas perdre ta progression.`,
325
+ firstButton: {
326
+ label: 'Arrêter ma session',
327
+ type: 'tertiary',
328
+ customStyle: {
329
+ color: '#ED3436'
330
+ },
331
+ handleOnclick: onQuitClick,
332
+ ariaLabel: 'Stop session'
333
+ },
334
+ secondButton: {
335
+ label: `Continuer d'apprendre`,
336
+ type: 'primary',
337
+ handleOnclick: (): void => {
338
+ dispatch(closeQuitPopin);
339
+ },
340
+ ariaLabel: 'Continue review'
341
+ }
342
+ };
343
+ };
296
344
  export const mapStateToSlidesProps = (
297
345
  state: StoreState,
298
346
  dispatch: Dispatch,
@@ -302,12 +350,12 @@ export const mapStateToSlidesProps = (
302
350
  const correction = get(['data', 'corrections', currentSlideRef], state);
303
351
  const isCorrect = get(['data', 'progression', 'state', 'isCorrect'], state);
304
352
  const klf = getOr('', ['data', 'slides', currentSlideRef, 'klf'], state);
305
-
353
+ const showQuitPopin = get(['ui', 'showQuitPopin'], state);
306
354
  return {
307
355
  header: {
308
356
  mode: '__revision_mode',
309
357
  skillName: '__agility',
310
- onQuitClick,
358
+ onQuitClick: () => dispatch(openQuitPopin),
311
359
  'aria-label': 'aria-header-wrapper',
312
360
  closeButtonAriaLabel: 'aria-close-button',
313
361
  steps: buildStepItems(state)
@@ -325,6 +373,7 @@ export const mapStateToSlidesProps = (
325
373
  correction && getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf),
326
374
  endReview: false
327
375
  },
328
- congrats: undefined
376
+ congrats: undefined,
377
+ quitPopin: showQuitPopin === true ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
329
378
  };
330
379
  };
@@ -0,0 +1,42 @@
1
+ import test from 'ava';
2
+ import identity from 'lodash/fp/identity';
3
+ import {createTestStore} from '../../../actions/test/create-test-store';
4
+ import {incorrectFreeTextPostAnswerResponse, services} from '../../../test/util/services.mock';
5
+ import {StoreState} from '../../../reducers';
6
+ import {OPEN_POPIN} from '../../../actions/ui/quit-popin';
7
+ import {mapStateToSlidesProps} from '..';
8
+
9
+ const state: StoreState = {
10
+ data: {
11
+ progression: incorrectFreeTextPostAnswerResponse,
12
+ skills: [],
13
+ slides: {
14
+ sli_N1XACJobn: null
15
+ },
16
+ token: '1234',
17
+ corrections: {},
18
+ rank: {}
19
+ },
20
+ ui: {
21
+ currentSlideRef: '',
22
+ navigation: ['loader', 'slides'],
23
+ answers: {},
24
+ positions: [0, 1, 2, 3, 4],
25
+ slide: {
26
+ sli_N1XACJobn: {
27
+ validateButton: false,
28
+ animateCorrectionPopin: false,
29
+ showCorrectionPopin: false
30
+ }
31
+ },
32
+ showQuitPopin: false
33
+ }
34
+ };
35
+
36
+ test('should dispatch OPEN_POPIN action after a click on close button in header', async t => {
37
+ const expectedAction = [{type: OPEN_POPIN}];
38
+ const {dispatch, getState} = createTestStore(t, state, services, expectedAction);
39
+ const props = mapStateToSlidesProps(getState(), dispatch, identity);
40
+ await props.header.onQuitClick();
41
+ t.pass();
42
+ });
@@ -42,7 +42,8 @@ test('should create initial props when fetched slide is not still received', t =
42
42
  animateCorrectionPopin: false,
43
43
  showCorrectionPopin: false
44
44
  }
45
- }
45
+ },
46
+ showQuitPopin: false
46
47
  }
47
48
  };
48
49
 
@@ -133,7 +134,8 @@ test('should create props when first slide is on the state', t => {
133
134
  animateCorrectionPopin: false,
134
135
  showCorrectionPopin: false
135
136
  }
136
- }
137
+ },
138
+ showQuitPopin: false
137
139
  }
138
140
  };
139
141
 
@@ -239,7 +241,8 @@ test('should create props when slide is on the state and user has selected answe
239
241
  animateCorrectionPopin: false,
240
242
  showCorrectionPopin: false
241
243
  }
242
- }
244
+ },
245
+ showQuitPopin: false
243
246
  }
244
247
  };
245
248
 
@@ -351,7 +354,8 @@ test('should verify props when first slide was answered correctly and next slide
351
354
  animateCorrectionPopin: false,
352
355
  showCorrectionPopin: false
353
356
  }
354
- }
357
+ },
358
+ showQuitPopin: false
355
359
  }
356
360
  };
357
361
 
@@ -467,7 +471,8 @@ test('should verify props when first slide was answered with error and next slid
467
471
  animateCorrectionPopin: false,
468
472
  showCorrectionPopin: false
469
473
  }
470
- }
474
+ },
475
+ showQuitPopin: false
471
476
  }
472
477
  };
473
478
 
@@ -540,7 +545,8 @@ test('should verify props when first slide was answered, next slide is fetched &
540
545
  animateCorrectionPopin: false,
541
546
  showCorrectionPopin: false
542
547
  }
543
- }
548
+ },
549
+ showQuitPopin: false
544
550
  }
545
551
  };
546
552
 
@@ -670,7 +676,8 @@ test('should verify props when first slide was answered incorrectly, next slide
670
676
  animateCorrectionPopin: false,
671
677
  showCorrectionPopin: false
672
678
  }
673
- }
679
+ },
680
+ showQuitPopin: false
674
681
  }
675
682
  };
676
683
 
@@ -807,7 +814,8 @@ test('should verify props when currentSlideRef has changed to nextContent of pro
807
814
  animateCorrectionPopin: false,
808
815
  showCorrectionPopin: false
809
816
  }
810
- }
817
+ },
818
+ showQuitPopin: false
811
819
  }
812
820
  };
813
821
 
@@ -938,7 +946,8 @@ test('should verify props when progression is in success', t => {
938
946
  animateCorrectionPopin: true,
939
947
  showCorrectionPopin: true
940
948
  }
941
- }
949
+ },
950
+ showQuitPopin: false
942
951
  }
943
952
  };
944
953
 
@@ -1045,7 +1054,8 @@ test('should verify props when progression has answered a current pendingSlide',
1045
1054
  showCorrectionPopin: false,
1046
1055
  animationType: 'unstack'
1047
1056
  }
1048
- }
1057
+ },
1058
+ showQuitPopin: false
1049
1059
  }
1050
1060
  };
1051
1061
 
@@ -1149,7 +1159,8 @@ test('should verify props when progression still has a pendingSlide', t => {
1149
1159
  showCorrectionPopin: false,
1150
1160
  animationType: 'unstack'
1151
1161
  }
1152
- }
1162
+ },
1163
+ showQuitPopin: false
1153
1164
  }
1154
1165
  };
1155
1166
 
@@ -1188,3 +1199,34 @@ test('should verify props when progression still has a pendingSlide', t => {
1188
1199
  ]
1189
1200
  });
1190
1201
  });
1202
+
1203
+ test('should verify that props quitPopin is not undefined when popin is displayed', t => {
1204
+ const state: StoreState = {
1205
+ data: {
1206
+ progression: createdProgression,
1207
+ skills: [],
1208
+ slides: {
1209
+ sli_N1XACJobn: null
1210
+ },
1211
+ token: '1234',
1212
+ corrections: {},
1213
+ rank: {}
1214
+ },
1215
+ ui: {
1216
+ currentSlideRef: '',
1217
+ navigation: ['loader', 'slides'],
1218
+ answers: {},
1219
+ positions: [0, 1, 2, 3, 4],
1220
+ slide: {
1221
+ sli_N1XACJobn: {
1222
+ validateButton: false,
1223
+ animateCorrectionPopin: false,
1224
+ showCorrectionPopin: false
1225
+ }
1226
+ },
1227
+ showQuitPopin: true
1228
+ }
1229
+ };
1230
+ const props = mapStateToSlidesProps(state, identity, identity);
1231
+ t.not(props.quitPopin, undefined);
1232
+ });
@@ -0,0 +1,64 @@
1
+ import test from 'ava';
2
+ import identity from 'lodash/fp/identity';
3
+ import {createTestStore} from '../../../actions/test/create-test-store';
4
+ import {CLOSE_POPIN} from '../../../actions/ui/quit-popin';
5
+ import {incorrectFreeTextPostAnswerResponse, services} from '../../../test/util/services.mock';
6
+ import {StoreState} from '../../../reducers';
7
+ import {mapStateToSlidesProps, QuitPopinProps} from '..';
8
+ import {freeTextSlide} from './fixtures/free-text';
9
+ import {qcmGraphicSlide} from './fixtures/qcm-graphic';
10
+
11
+ const state: StoreState = {
12
+ data: {
13
+ progression: incorrectFreeTextPostAnswerResponse,
14
+ skills: [],
15
+ slides: {
16
+ sli_VJYjJnJhg: freeTextSlide,
17
+ sli_VkSQroQnx: qcmGraphicSlide
18
+ },
19
+ token: '1234',
20
+ corrections: {},
21
+ rank: {}
22
+ },
23
+ ui: {
24
+ currentSlideRef: 'sli_VJYjJnJhg',
25
+ navigation: ['loader', 'slides'],
26
+ answers: {sli_VJYjJnJhg: ['My value']},
27
+ positions: [0, 1, 2, 3, 4],
28
+ slide: {
29
+ sli_VJYjJnJhg: {
30
+ validateButton: false,
31
+ animateCorrectionPopin: true,
32
+ showCorrectionPopin: true
33
+ },
34
+ sli_VkSQroQnx: {
35
+ validateButton: false,
36
+ animateCorrectionPopin: false,
37
+ showCorrectionPopin: false
38
+ }
39
+ },
40
+ showQuitPopin: true
41
+ }
42
+ };
43
+
44
+ test('should dispatch CLOSE_POPIN action via the property handleOnclick of secondButton when popin is open', async t => {
45
+ const expectedAction = [{type: CLOSE_POPIN}];
46
+ const {dispatch, getState} = createTestStore(t, state, services, expectedAction);
47
+ const props = mapStateToSlidesProps(getState(), dispatch, identity);
48
+ const quitPopin = props.quitPopin as QuitPopinProps;
49
+ await quitPopin.secondButton.handleOnclick();
50
+ const updatedState = getState();
51
+ t.is(updatedState.ui.showQuitPopin, false);
52
+ t.pass();
53
+ });
54
+
55
+ test('should dispatch onQuitClick function via the property handleOnclick of firstButton when popin is open', async t => {
56
+ t.plan(2);
57
+
58
+ const expectedAction = [{type: CLOSE_POPIN}];
59
+ const {dispatch, getState} = createTestStore(t, state, services, expectedAction);
60
+ const props = mapStateToSlidesProps(getState(), dispatch, () => t.pass());
61
+ const quitPopin = props.quitPopin as QuitPopinProps;
62
+ await quitPopin.firstButton.handleOnclick();
63
+ t.pass();
64
+ });
@@ -66,7 +66,8 @@ const initialState: StoreState = {
66
66
  animateCorrectionPopin: false,
67
67
  showCorrectionPopin: false
68
68
  }
69
- }
69
+ },
70
+ showQuitPopin: false
70
71
  }
71
72
  };
72
73
 
@@ -43,7 +43,8 @@ test('correction popin actions after click', async t => {
43
43
  animateCorrectionPopin: false,
44
44
  showCorrectionPopin: false
45
45
  }
46
- }
46
+ },
47
+ showQuitPopin: false
47
48
  }
48
49
  };
49
50
 
@@ -55,7 +55,8 @@ const initialState: StoreState = {
55
55
  animateCorrectionPopin: false,
56
56
  showCorrectionPopin: false
57
57
  }
58
- }
58
+ },
59
+ showQuitPopin: false
59
60
  }
60
61
  };
61
62
 
@@ -55,7 +55,8 @@ const initialState: StoreState = {
55
55
  animateCorrectionPopin: false,
56
56
  showCorrectionPopin: false
57
57
  }
58
- }
58
+ },
59
+ showQuitPopin: false
59
60
  }
60
61
  };
61
62
 
@@ -55,7 +55,8 @@ const initialState: StoreState = {
55
55
  animateCorrectionPopin: false,
56
56
  showCorrectionPopin: false
57
57
  }
58
- }
58
+ },
59
+ showQuitPopin: false
59
60
  }
60
61
  };
61
62
 
@@ -55,7 +55,8 @@ const initialState: StoreState = {
55
55
  animateCorrectionPopin: false,
56
56
  showCorrectionPopin: false
57
57
  }
58
- }
58
+ },
59
+ showQuitPopin: false
59
60
  }
60
61
  };
61
62
 
@@ -55,7 +55,8 @@ const initialState: StoreState = {
55
55
  animateCorrectionPopin: false,
56
56
  showCorrectionPopin: false
57
57
  }
58
- }
58
+ },
59
+ showQuitPopin: false
59
60
  }
60
61
  };
61
62
 
@@ -56,7 +56,8 @@ const initialState: StoreState = {
56
56
  animateCorrectionPopin: false,
57
57
  showCorrectionPopin: false
58
58
  }
59
- }
59
+ },
60
+ showQuitPopin: false
60
61
  }
61
62
  };
62
63