@coorpacademy/app-review 0.5.1-alpha.26 → 0.5.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/es/reducers/index.d.ts +1 -6
- package/es/reducers/ui/index.d.ts +1 -8
- package/es/reducers/ui/index.js +1 -3
- package/es/test/index.test.js +1 -1
- package/es/views/slides/index.d.ts +0 -18
- package/es/views/slides/index.js +2 -30
- package/lib/reducers/index.d.ts +1 -6
- package/lib/reducers/ui/index.d.ts +1 -8
- package/lib/reducers/ui/index.js +1 -3
- package/lib/test/index.test.js +1 -2
- package/lib/views/slides/index.d.ts +0 -18
- package/lib/views/slides/index.js +2 -32
- package/package.json +7 -7
- package/src/actions/api/test/fetch-correction.test.ts +1 -2
- package/src/actions/api/test/fetch-rank.test.ts +1 -2
- package/src/actions/api/test/fetch-skills.test.ts +1 -2
- package/src/actions/api/test/fetch-slide.test.ts +1 -2
- package/src/actions/api/test/post-answer.test.ts +2 -4
- package/src/actions/api/test/post-progression.test.ts +1 -2
- package/src/actions/data/test/token.test.ts +1 -2
- package/src/actions/ui/test/answers.test.ts +1 -2
- package/src/actions/ui/test/next-slide.test.ts +1 -2
- package/src/actions/ui/test/slides.test.ts +1 -2
- package/src/reducers/ui/index.ts +1 -4
- package/src/test/index.test.tsx +1 -1
- package/src/views/skills/test/skills.test.ts +2 -4
- package/src/views/slides/index.ts +3 -52
- package/src/views/slides/test/index.test.ts +11 -53
- package/src/views/slides/test/slide.free-text.on-change.test.ts +1 -2
- package/src/views/slides/test/slide.next-slide.on-click.test.ts +1 -2
- package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +1 -2
- package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +1 -2
- package/src/views/slides/test/slide.qcm.on-click.test.ts +1 -2
- package/src/views/slides/test/slide.slider.on-change.test.ts +1 -2
- package/src/views/slides/test/slide.slider.on-slider-change.test.ts +1 -2
- package/src/views/slides/test/slide.template.on-change.test.ts +1 -2
- package/es/actions/ui/quit-popin.d.ts +0 -8
- package/es/actions/ui/quit-popin.js +0 -8
- package/es/reducers/ui/quit-popin.d.ts +0 -4
- package/es/reducers/ui/quit-popin.js +0 -16
- package/lib/actions/ui/quit-popin.d.ts +0 -8
- package/lib/actions/ui/quit-popin.js +0 -8
- package/lib/reducers/ui/quit-popin.d.ts +0 -4
- package/lib/reducers/ui/quit-popin.js +0 -17
- package/src/actions/ui/quit-popin.ts +0 -10
- package/src/actions/ui/test/quit-popin.test.ts +0 -38
- package/src/reducers/ui/quit-popin.ts +0 -22
- package/src/reducers/ui/test/quit-popin.test.ts +0 -24
- package/src/views/slides/test/header.on-click.test.ts +0 -42
- package/src/views/slides/test/on-quit-popin.on-click.test.ts +0 -64
package/es/reducers/index.d.ts
CHANGED
|
@@ -19,11 +19,6 @@ 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;
|
|
23
22
|
}>;
|
|
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
|
-
}>;
|
|
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>;
|
|
29
24
|
export default _default;
|
|
@@ -3,14 +3,12 @@ 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';
|
|
7
6
|
export declare type UIState = {
|
|
8
7
|
currentSlideRef: CurrentSlideRefState;
|
|
9
8
|
navigation: NavigationState;
|
|
10
9
|
answers: UIAnswerState;
|
|
11
10
|
slide: UISlideState;
|
|
12
11
|
positions: UIPositionState;
|
|
13
|
-
showQuitPopin: ShowQuitPopinState;
|
|
14
12
|
};
|
|
15
13
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
16
14
|
currentSlideRef: string;
|
|
@@ -18,10 +16,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
18
16
|
answers: UIAnswerState;
|
|
19
17
|
slide: UISlideState;
|
|
20
18
|
positions: UIPositionState;
|
|
21
|
-
|
|
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
|
-
}>;
|
|
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>;
|
|
27
20
|
export default _default;
|
package/es/reducers/ui/index.js
CHANGED
|
@@ -4,12 +4,10 @@ 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';
|
|
8
7
|
export default combineReducers({
|
|
9
8
|
currentSlideRef,
|
|
10
9
|
navigation,
|
|
11
10
|
answers,
|
|
12
11
|
slide,
|
|
13
|
-
positions
|
|
14
|
-
showQuitPopin
|
|
12
|
+
positions
|
|
15
13
|
});
|
package/es/test/index.test.js
CHANGED
|
@@ -14,6 +14,7 @@ const waitForChanges = async (msToWait = 3000) => {
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
const LIMIT = 5;
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
18
|
const clickAllSlides = async (t, container, accumulator = 0) => {
|
|
18
19
|
if (accumulator === LIMIT)
|
|
19
20
|
return;
|
|
@@ -32,7 +33,6 @@ const clickAllSlides = async (t, container, accumulator = 0) => {
|
|
|
32
33
|
await act(async () => {
|
|
33
34
|
await fireEvent.click(nextButton[0]);
|
|
34
35
|
});
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
36
36
|
await clickAllSlides(t, container, accumulator + 1);
|
|
37
37
|
};
|
|
38
38
|
const appOptions = {
|
|
@@ -40,15 +40,6 @@ 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
|
-
};
|
|
52
43
|
export declare type CorrectionPopinProps = {
|
|
53
44
|
klf?: CorrectionPopinKlf;
|
|
54
45
|
information: CorrectionPopinInformation;
|
|
@@ -56,14 +47,6 @@ export declare type CorrectionPopinProps = {
|
|
|
56
47
|
resultLabel: string;
|
|
57
48
|
type: 'right' | 'wrong';
|
|
58
49
|
};
|
|
59
|
-
export declare type QuitPopinProps = {
|
|
60
|
-
content: string;
|
|
61
|
-
icon: string;
|
|
62
|
-
mode: string;
|
|
63
|
-
descriptionText: string;
|
|
64
|
-
firstButton: QuitPopinButton;
|
|
65
|
-
secondButton: QuitPopinButton;
|
|
66
|
-
};
|
|
67
50
|
export declare type SlidesViewProps = {
|
|
68
51
|
header: {
|
|
69
52
|
mode: string;
|
|
@@ -104,7 +87,6 @@ export declare type SlidesViewProps = {
|
|
|
104
87
|
type: string;
|
|
105
88
|
};
|
|
106
89
|
};
|
|
107
|
-
quitPopin?: QuitPopinProps;
|
|
108
90
|
};
|
|
109
91
|
export declare const initialState: SlidesStack;
|
|
110
92
|
export declare const buildStepItems: (state: StoreState) => StepItem[];
|
package/es/views/slides/index.js
CHANGED
|
@@ -6,7 +6,6 @@ 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';
|
|
10
9
|
import { getProgressionSlidesRefs } from '../../common';
|
|
11
10
|
import { postAnswer } from '../../actions/api/post-answer';
|
|
12
11
|
import { nextSlide } from '../../actions/ui/next-slide';
|
|
@@ -169,42 +168,16 @@ const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf) =>
|
|
|
169
168
|
type: isCorrect ? 'right' : 'wrong'
|
|
170
169
|
};
|
|
171
170
|
};
|
|
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
|
-
};
|
|
197
171
|
export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
|
|
198
172
|
const currentSlideRef = get(['ui', 'currentSlideRef'], state);
|
|
199
173
|
const correction = get(['data', 'corrections', currentSlideRef], state);
|
|
200
174
|
const isCorrect = get(['data', 'progression', 'state', 'isCorrect'], state);
|
|
201
175
|
const klf = getOr('', ['data', 'slides', currentSlideRef, 'klf'], state);
|
|
202
|
-
const showQuitPopin = get(['ui', 'showQuitPopin'], state);
|
|
203
176
|
return {
|
|
204
177
|
header: {
|
|
205
178
|
mode: '__revision_mode',
|
|
206
179
|
skillName: '__agility',
|
|
207
|
-
onQuitClick
|
|
180
|
+
onQuitClick,
|
|
208
181
|
'aria-label': 'aria-header-wrapper',
|
|
209
182
|
closeButtonAriaLabel: 'aria-close-button',
|
|
210
183
|
steps: buildStepItems(state)
|
|
@@ -221,7 +194,6 @@ export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
|
|
|
221
194
|
correctionPopinProps: correction && getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf),
|
|
222
195
|
endReview: false
|
|
223
196
|
},
|
|
224
|
-
congrats: undefined
|
|
225
|
-
quitPopin: showQuitPopin === true ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
|
|
197
|
+
congrats: undefined
|
|
226
198
|
};
|
|
227
199
|
};
|
package/lib/reducers/index.d.ts
CHANGED
|
@@ -19,11 +19,6 @@ 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;
|
|
23
22
|
}>;
|
|
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
|
-
}>;
|
|
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>;
|
|
29
24
|
export default _default;
|
|
@@ -3,14 +3,12 @@ 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';
|
|
7
6
|
export declare type UIState = {
|
|
8
7
|
currentSlideRef: CurrentSlideRefState;
|
|
9
8
|
navigation: NavigationState;
|
|
10
9
|
answers: UIAnswerState;
|
|
11
10
|
slide: UISlideState;
|
|
12
11
|
positions: UIPositionState;
|
|
13
|
-
showQuitPopin: ShowQuitPopinState;
|
|
14
12
|
};
|
|
15
13
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
16
14
|
currentSlideRef: string;
|
|
@@ -18,10 +16,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
18
16
|
answers: UIAnswerState;
|
|
19
17
|
slide: UISlideState;
|
|
20
18
|
positions: UIPositionState;
|
|
21
|
-
|
|
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
|
-
}>;
|
|
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>;
|
|
27
20
|
export default _default;
|
package/lib/reducers/ui/index.js
CHANGED
|
@@ -4,12 +4,10 @@ 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';
|
|
8
7
|
export default combineReducers({
|
|
9
8
|
currentSlideRef: currentSlideRef,
|
|
10
9
|
navigation: navigation,
|
|
11
10
|
answers: answers,
|
|
12
11
|
slide: slide,
|
|
13
|
-
positions: positions
|
|
14
|
-
showQuitPopin: showQuitPopin
|
|
12
|
+
positions: positions
|
|
15
13
|
});
|
package/lib/test/index.test.js
CHANGED
|
@@ -69,6 +69,7 @@ var waitForChanges = function (msToWait) {
|
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
71
|
var LIMIT = 5;
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
72
73
|
var clickAllSlides = function (t, container, accumulator) {
|
|
73
74
|
if (accumulator === void 0) { accumulator = 0; }
|
|
74
75
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -121,10 +122,8 @@ var clickAllSlides = function (t, container, accumulator) {
|
|
|
121
122
|
}); })];
|
|
122
123
|
case 4:
|
|
123
124
|
_a.sent();
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
125
125
|
return [4 /*yield*/, clickAllSlides(t, container, accumulator + 1)];
|
|
126
126
|
case 5:
|
|
127
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
128
127
|
_a.sent();
|
|
129
128
|
return [2 /*return*/];
|
|
130
129
|
}
|
|
@@ -40,15 +40,6 @@ 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
|
-
};
|
|
52
43
|
export declare type CorrectionPopinProps = {
|
|
53
44
|
klf?: CorrectionPopinKlf;
|
|
54
45
|
information: CorrectionPopinInformation;
|
|
@@ -56,14 +47,6 @@ export declare type CorrectionPopinProps = {
|
|
|
56
47
|
resultLabel: string;
|
|
57
48
|
type: 'right' | 'wrong';
|
|
58
49
|
};
|
|
59
|
-
export declare type QuitPopinProps = {
|
|
60
|
-
content: string;
|
|
61
|
-
icon: string;
|
|
62
|
-
mode: string;
|
|
63
|
-
descriptionText: string;
|
|
64
|
-
firstButton: QuitPopinButton;
|
|
65
|
-
secondButton: QuitPopinButton;
|
|
66
|
-
};
|
|
67
50
|
export declare type SlidesViewProps = {
|
|
68
51
|
header: {
|
|
69
52
|
mode: string;
|
|
@@ -104,7 +87,6 @@ export declare type SlidesViewProps = {
|
|
|
104
87
|
type: string;
|
|
105
88
|
};
|
|
106
89
|
};
|
|
107
|
-
quitPopin?: QuitPopinProps;
|
|
108
90
|
};
|
|
109
91
|
export declare const initialState: SlidesStack;
|
|
110
92
|
export declare const buildStepItems: (state: StoreState) => StepItem[];
|
|
@@ -17,7 +17,6 @@ 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';
|
|
21
20
|
import { getProgressionSlidesRefs } from '../../common';
|
|
22
21
|
import { postAnswer } from '../../actions/api/post-answer';
|
|
23
22
|
import { nextSlide } from '../../actions/ui/next-slide';
|
|
@@ -165,44 +164,16 @@ var getCorrectionPopinProps = function (dispatch) {
|
|
|
165
164
|
};
|
|
166
165
|
};
|
|
167
166
|
};
|
|
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
|
-
};
|
|
195
167
|
export var mapStateToSlidesProps = function (state, dispatch, onQuitClick) {
|
|
196
168
|
var currentSlideRef = get(['ui', 'currentSlideRef'], state);
|
|
197
169
|
var correction = get(['data', 'corrections', currentSlideRef], state);
|
|
198
170
|
var isCorrect = get(['data', 'progression', 'state', 'isCorrect'], state);
|
|
199
171
|
var klf = getOr('', ['data', 'slides', currentSlideRef, 'klf'], state);
|
|
200
|
-
var showQuitPopin = get(['ui', 'showQuitPopin'], state);
|
|
201
172
|
return {
|
|
202
173
|
header: {
|
|
203
174
|
mode: '__revision_mode',
|
|
204
175
|
skillName: '__agility',
|
|
205
|
-
onQuitClick:
|
|
176
|
+
onQuitClick: onQuitClick,
|
|
206
177
|
'aria-label': 'aria-header-wrapper',
|
|
207
178
|
closeButtonAriaLabel: 'aria-close-button',
|
|
208
179
|
steps: buildStepItems(state)
|
|
@@ -219,7 +190,6 @@ export var mapStateToSlidesProps = function (state, dispatch, onQuitClick) {
|
|
|
219
190
|
correctionPopinProps: correction && getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf),
|
|
220
191
|
endReview: false
|
|
221
192
|
},
|
|
222
|
-
congrats: undefined
|
|
223
|
-
quitPopin: showQuitPopin === true ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
|
|
193
|
+
congrats: undefined
|
|
224
194
|
};
|
|
225
195
|
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/app-review",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.15.0"
|
|
7
7
|
},
|
|
8
8
|
"license": "UNLICENSED",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"static": "webpack --progress --output-path static
|
|
11
|
-
"poststatic": "cp sandbox/index.html static/index.html",
|
|
10
|
+
"static": "webpack --progress --output-path static",
|
|
12
11
|
"start": "cross-env BABEL_ENV=es webpack-dev-server",
|
|
13
12
|
"prepare": "npm run clean && npm run build --production",
|
|
14
13
|
"build:commonjs": "tsc -p tsconfig.lib.json",
|
|
@@ -43,8 +42,8 @@
|
|
|
43
42
|
"./package.json": "./package.json"
|
|
44
43
|
},
|
|
45
44
|
"dependencies": {
|
|
46
|
-
"@coorpacademy/components": "10.
|
|
47
|
-
"@coorpacademy/redux-task": "1.1.
|
|
45
|
+
"@coorpacademy/components": "10.24.1",
|
|
46
|
+
"@coorpacademy/redux-task": "1.1.6",
|
|
48
47
|
"cross-fetch": "^3.1.5",
|
|
49
48
|
"jwt-decode": "^3.1.2",
|
|
50
49
|
"react-redux": "^7.2.9",
|
|
@@ -58,7 +57,7 @@
|
|
|
58
57
|
"devDependencies": {
|
|
59
58
|
"@coorpacademy/css-modules-require-hook": "2.1.5",
|
|
60
59
|
"@coorpacademy/eslint-plugin-coorpacademy": "^11.0.0",
|
|
61
|
-
"@coorpacademy/webpack-config": "
|
|
60
|
+
"@coorpacademy/webpack-config": "11.0.0",
|
|
62
61
|
"@testing-library/react": "^12.1.5",
|
|
63
62
|
"@types/lodash": "^4.14.182",
|
|
64
63
|
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
|
@@ -68,6 +67,7 @@
|
|
|
68
67
|
"concurrently": "^5.2.0",
|
|
69
68
|
"eslint": "^8.18.0",
|
|
70
69
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
70
|
+
"html-webpack-plugin": "^5.5.0",
|
|
71
71
|
"nock": "^13.2.9",
|
|
72
72
|
"react-dom": "^17.0.2",
|
|
73
73
|
"ts-loader": "^9.4.1",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"webpack-cli": "^4.10.0",
|
|
78
78
|
"webpack-dev-server": "^4.11.1"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "59ed58c1e02784b3fbf1bf503ce7117a7288ccda"
|
|
81
81
|
}
|
|
@@ -75,8 +75,7 @@ const initialState: StoreState = {
|
|
|
75
75
|
animateCorrectionPopin: false,
|
|
76
76
|
showCorrectionPopin: false
|
|
77
77
|
}
|
|
78
|
-
}
|
|
79
|
-
showQuitPopin: false
|
|
78
|
+
}
|
|
80
79
|
}
|
|
81
80
|
};
|
|
82
81
|
|
|
@@ -178,8 +177,7 @@ test('should dispatch post-answer, fetch-correction and fetch-end-rank actions w
|
|
|
178
177
|
animateCorrectionPopin: false,
|
|
179
178
|
showCorrectionPopin: false
|
|
180
179
|
}
|
|
181
|
-
}
|
|
182
|
-
showQuitPopin: false
|
|
180
|
+
}
|
|
183
181
|
}
|
|
184
182
|
};
|
|
185
183
|
|
package/src/reducers/ui/index.ts
CHANGED
|
@@ -5,7 +5,6 @@ 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';
|
|
9
8
|
|
|
10
9
|
export type UIState = {
|
|
11
10
|
currentSlideRef: CurrentSlideRefState;
|
|
@@ -13,7 +12,6 @@ export type UIState = {
|
|
|
13
12
|
answers: UIAnswerState;
|
|
14
13
|
slide: UISlideState;
|
|
15
14
|
positions: UIPositionState;
|
|
16
|
-
showQuitPopin: ShowQuitPopinState;
|
|
17
15
|
};
|
|
18
16
|
|
|
19
17
|
export default combineReducers({
|
|
@@ -21,6 +19,5 @@ export default combineReducers({
|
|
|
21
19
|
navigation,
|
|
22
20
|
answers,
|
|
23
21
|
slide,
|
|
24
|
-
positions
|
|
25
|
-
showQuitPopin
|
|
22
|
+
positions
|
|
26
23
|
});
|
package/src/test/index.test.tsx
CHANGED
|
@@ -22,6 +22,7 @@ const waitForChanges = async (msToWait = 3000): Promise<void> => {
|
|
|
22
22
|
|
|
23
23
|
const LIMIT = 5;
|
|
24
24
|
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
26
|
const clickAllSlides = async (
|
|
26
27
|
t: ExecutionContext<unknown>,
|
|
27
28
|
container: HTMLElement,
|
|
@@ -53,7 +54,6 @@ const clickAllSlides = async (
|
|
|
53
54
|
await fireEvent.click(nextButton[0]);
|
|
54
55
|
});
|
|
55
56
|
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
57
57
|
await clickAllSlides(t, container, accumulator + 1);
|
|
58
58
|
};
|
|
59
59
|
|
|
@@ -19,8 +19,7 @@ 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: {}
|
|
23
|
-
showQuitPopin: false
|
|
22
|
+
slide: {}
|
|
24
23
|
}
|
|
25
24
|
};
|
|
26
25
|
|
|
@@ -65,8 +64,7 @@ test('should create initial props when skills on the state', t => {
|
|
|
65
64
|
positions: [0, 1, 2, 3, 4],
|
|
66
65
|
navigation: ['loader', 'skills'],
|
|
67
66
|
answers: {},
|
|
68
|
-
slide: {}
|
|
69
|
-
showQuitPopin: false
|
|
67
|
+
slide: {}
|
|
70
68
|
}
|
|
71
69
|
};
|
|
72
70
|
|
|
@@ -7,7 +7,6 @@ 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';
|
|
11
10
|
import type {ProgressionAnswerItem} from '../../types/common';
|
|
12
11
|
import {getProgressionSlidesRefs, type SlideIndexes} from '../../common';
|
|
13
12
|
import type {StoreState} from '../../reducers';
|
|
@@ -63,16 +62,6 @@ type CorrectionPopinNext = {
|
|
|
63
62
|
onClick: Function;
|
|
64
63
|
};
|
|
65
64
|
|
|
66
|
-
type QuitPopinButton = {
|
|
67
|
-
label: string;
|
|
68
|
-
type: string;
|
|
69
|
-
customStyle?: {
|
|
70
|
-
color: string;
|
|
71
|
-
};
|
|
72
|
-
handleOnclick: Function;
|
|
73
|
-
ariaLabel: string;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
65
|
export type CorrectionPopinProps = {
|
|
77
66
|
klf?: CorrectionPopinKlf;
|
|
78
67
|
information: CorrectionPopinInformation;
|
|
@@ -81,15 +70,6 @@ export type CorrectionPopinProps = {
|
|
|
81
70
|
type: 'right' | 'wrong';
|
|
82
71
|
};
|
|
83
72
|
|
|
84
|
-
export type QuitPopinProps = {
|
|
85
|
-
content: string;
|
|
86
|
-
icon: string;
|
|
87
|
-
mode: string;
|
|
88
|
-
descriptionText: string;
|
|
89
|
-
firstButton: QuitPopinButton;
|
|
90
|
-
secondButton: QuitPopinButton;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
73
|
export type SlidesViewProps = {
|
|
94
74
|
header: {
|
|
95
75
|
mode: string;
|
|
@@ -130,7 +110,6 @@ export type SlidesViewProps = {
|
|
|
130
110
|
type: string;
|
|
131
111
|
};
|
|
132
112
|
};
|
|
133
|
-
quitPopin?: QuitPopinProps;
|
|
134
113
|
};
|
|
135
114
|
|
|
136
115
|
// TODO replace this, position no more needed
|
|
@@ -314,33 +293,6 @@ const getCorrectionPopinProps =
|
|
|
314
293
|
};
|
|
315
294
|
};
|
|
316
295
|
|
|
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
|
-
};
|
|
344
296
|
export const mapStateToSlidesProps = (
|
|
345
297
|
state: StoreState,
|
|
346
298
|
dispatch: Dispatch,
|
|
@@ -350,12 +302,12 @@ export const mapStateToSlidesProps = (
|
|
|
350
302
|
const correction = get(['data', 'corrections', currentSlideRef], state);
|
|
351
303
|
const isCorrect = get(['data', 'progression', 'state', 'isCorrect'], state);
|
|
352
304
|
const klf = getOr('', ['data', 'slides', currentSlideRef, 'klf'], state);
|
|
353
|
-
|
|
305
|
+
|
|
354
306
|
return {
|
|
355
307
|
header: {
|
|
356
308
|
mode: '__revision_mode',
|
|
357
309
|
skillName: '__agility',
|
|
358
|
-
onQuitClick
|
|
310
|
+
onQuitClick,
|
|
359
311
|
'aria-label': 'aria-header-wrapper',
|
|
360
312
|
closeButtonAriaLabel: 'aria-close-button',
|
|
361
313
|
steps: buildStepItems(state)
|
|
@@ -373,7 +325,6 @@ export const mapStateToSlidesProps = (
|
|
|
373
325
|
correction && getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf),
|
|
374
326
|
endReview: false
|
|
375
327
|
},
|
|
376
|
-
congrats: undefined
|
|
377
|
-
quitPopin: showQuitPopin === true ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
|
|
328
|
+
congrats: undefined
|
|
378
329
|
};
|
|
379
330
|
};
|
|
@@ -42,8 +42,7 @@ test('should create initial props when fetched slide is not still received', t =
|
|
|
42
42
|
animateCorrectionPopin: false,
|
|
43
43
|
showCorrectionPopin: false
|
|
44
44
|
}
|
|
45
|
-
}
|
|
46
|
-
showQuitPopin: false
|
|
45
|
+
}
|
|
47
46
|
}
|
|
48
47
|
};
|
|
49
48
|
|
|
@@ -134,8 +133,7 @@ test('should create props when first slide is on the state', t => {
|
|
|
134
133
|
animateCorrectionPopin: false,
|
|
135
134
|
showCorrectionPopin: false
|
|
136
135
|
}
|
|
137
|
-
}
|
|
138
|
-
showQuitPopin: false
|
|
136
|
+
}
|
|
139
137
|
}
|
|
140
138
|
};
|
|
141
139
|
|
|
@@ -241,8 +239,7 @@ test('should create props when slide is on the state and user has selected answe
|
|
|
241
239
|
animateCorrectionPopin: false,
|
|
242
240
|
showCorrectionPopin: false
|
|
243
241
|
}
|
|
244
|
-
}
|
|
245
|
-
showQuitPopin: false
|
|
242
|
+
}
|
|
246
243
|
}
|
|
247
244
|
};
|
|
248
245
|
|
|
@@ -354,8 +351,7 @@ test('should verify props when first slide was answered correctly and next slide
|
|
|
354
351
|
animateCorrectionPopin: false,
|
|
355
352
|
showCorrectionPopin: false
|
|
356
353
|
}
|
|
357
|
-
}
|
|
358
|
-
showQuitPopin: false
|
|
354
|
+
}
|
|
359
355
|
}
|
|
360
356
|
};
|
|
361
357
|
|
|
@@ -471,8 +467,7 @@ test('should verify props when first slide was answered with error and next slid
|
|
|
471
467
|
animateCorrectionPopin: false,
|
|
472
468
|
showCorrectionPopin: false
|
|
473
469
|
}
|
|
474
|
-
}
|
|
475
|
-
showQuitPopin: false
|
|
470
|
+
}
|
|
476
471
|
}
|
|
477
472
|
};
|
|
478
473
|
|
|
@@ -545,8 +540,7 @@ test('should verify props when first slide was answered, next slide is fetched &
|
|
|
545
540
|
animateCorrectionPopin: false,
|
|
546
541
|
showCorrectionPopin: false
|
|
547
542
|
}
|
|
548
|
-
}
|
|
549
|
-
showQuitPopin: false
|
|
543
|
+
}
|
|
550
544
|
}
|
|
551
545
|
};
|
|
552
546
|
|
|
@@ -676,8 +670,7 @@ test('should verify props when first slide was answered incorrectly, next slide
|
|
|
676
670
|
animateCorrectionPopin: false,
|
|
677
671
|
showCorrectionPopin: false
|
|
678
672
|
}
|
|
679
|
-
}
|
|
680
|
-
showQuitPopin: false
|
|
673
|
+
}
|
|
681
674
|
}
|
|
682
675
|
};
|
|
683
676
|
|
|
@@ -814,8 +807,7 @@ test('should verify props when currentSlideRef has changed to nextContent of pro
|
|
|
814
807
|
animateCorrectionPopin: false,
|
|
815
808
|
showCorrectionPopin: false
|
|
816
809
|
}
|
|
817
|
-
}
|
|
818
|
-
showQuitPopin: false
|
|
810
|
+
}
|
|
819
811
|
}
|
|
820
812
|
};
|
|
821
813
|
|
|
@@ -946,8 +938,7 @@ test('should verify props when progression is in success', t => {
|
|
|
946
938
|
animateCorrectionPopin: true,
|
|
947
939
|
showCorrectionPopin: true
|
|
948
940
|
}
|
|
949
|
-
}
|
|
950
|
-
showQuitPopin: false
|
|
941
|
+
}
|
|
951
942
|
}
|
|
952
943
|
};
|
|
953
944
|
|
|
@@ -1054,8 +1045,7 @@ test('should verify props when progression has answered a current pendingSlide',
|
|
|
1054
1045
|
showCorrectionPopin: false,
|
|
1055
1046
|
animationType: 'unstack'
|
|
1056
1047
|
}
|
|
1057
|
-
}
|
|
1058
|
-
showQuitPopin: false
|
|
1048
|
+
}
|
|
1059
1049
|
}
|
|
1060
1050
|
};
|
|
1061
1051
|
|
|
@@ -1159,8 +1149,7 @@ test('should verify props when progression still has a pendingSlide', t => {
|
|
|
1159
1149
|
showCorrectionPopin: false,
|
|
1160
1150
|
animationType: 'unstack'
|
|
1161
1151
|
}
|
|
1162
|
-
}
|
|
1163
|
-
showQuitPopin: false
|
|
1152
|
+
}
|
|
1164
1153
|
}
|
|
1165
1154
|
};
|
|
1166
1155
|
|
|
@@ -1199,34 +1188,3 @@ test('should verify props when progression still has a pendingSlide', t => {
|
|
|
1199
1188
|
]
|
|
1200
1189
|
});
|
|
1201
1190
|
});
|
|
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
|
-
});
|
|
@@ -1,4 +0,0 @@
|
|
|
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;
|
|
@@ -1,16 +0,0 @@
|
|
|
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;
|
|
@@ -1,4 +0,0 @@
|
|
|
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;
|
|
@@ -1,17 +0,0 @@
|
|
|
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;
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
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
|
-
});
|