@coorpacademy/app-review 0.1.16 → 0.1.17
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/actions/api/fetch-skills.d.ts +3 -3
- package/es/actions/api/fetch-skills.js +7 -2
- package/es/actions/api/fetch-slide.d.ts +1 -1
- package/es/actions/api/fetch-slide.js +3 -1
- package/es/actions/api/post-answer.d.ts +10 -0
- package/es/actions/api/post-answer.js +25 -0
- package/es/actions/api/post-progression.d.ts +3 -3
- package/es/actions/api/post-progression.js +5 -2
- package/es/actions/api/test/fetch-skills.test.js +7 -4
- package/es/actions/api/test/fetch-slide.test.js +7 -4
- package/es/actions/api/test/post-answer.test.d.ts +1 -0
- package/es/actions/api/test/post-answer.test.js +82 -0
- package/es/actions/api/test/post-progression.test.js +7 -4
- package/es/actions/data/test/token.test.d.ts +1 -0
- package/es/actions/data/test/token.test.js +25 -0
- package/es/actions/index.d.ts +1 -8
- package/es/actions/{api/test → test}/create-test-store.d.ts +2 -2
- package/es/actions/{api/test → test}/create-test-store.js +1 -1
- package/es/actions/ui/answers.d.ts +17 -3
- package/es/actions/ui/answers.js +39 -3
- package/es/actions/ui/slides.d.ts +0 -5
- package/es/actions/ui/slides.js +0 -4
- package/es/actions/ui/test/answers.test.d.ts +1 -0
- package/es/actions/ui/test/answers.test.js +90 -0
- package/es/actions/ui/test/slides.test.d.ts +1 -0
- package/es/actions/ui/test/slides.test.js +26 -0
- package/es/common/index.d.ts +0 -3
- package/es/common/index.js +0 -4
- package/es/index.js +1 -3
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +2 -3
- package/es/reducers/data/progression.js +0 -5
- package/es/reducers/data/slides.d.ts +2 -3
- package/es/reducers/data/test/progression.test.js +1 -1
- package/es/reducers/index.d.ts +2 -1
- package/es/reducers/ui/answers.d.ts +2 -2
- package/es/reducers/ui/answers.js +4 -8
- package/es/reducers/ui/index.d.ts +4 -1
- package/es/reducers/ui/index.js +3 -1
- package/es/reducers/ui/slide.d.ts +8 -0
- package/es/reducers/ui/slide.js +26 -0
- package/es/reducers/ui/test/answers.test.js +19 -3
- package/es/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/es/reducers/ui/test/navigation.test.js +5 -5
- package/es/reducers/ui/test/slide.test.d.ts +1 -0
- package/es/reducers/ui/test/slide.test.js +12 -0
- package/es/test/util/services.mock.d.ts +2 -1
- package/es/test/util/services.mock.js +86 -72
- package/es/types/common.d.ts +0 -25
- package/es/views/skills/index.d.ts +1 -1
- package/es/views/skills/index.js +0 -3
- package/es/views/skills/test/skills.test.d.ts +1 -0
- package/es/views/skills/test/skills.test.js +94 -0
- package/es/views/slides/index.d.ts +13 -2
- package/es/views/slides/index.js +18 -14
- package/es/views/slides/map-api-slide-to-ui.js +44 -51
- package/es/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/es/views/slides/test/fixtures/select-template.d.ts +2 -1
- package/es/views/slides/test/fixtures/slider.d.ts +2 -1
- package/es/views/slides/test/fixtures/text-template.d.ts +2 -1
- package/es/views/slides/test/index.test.d.ts +1 -0
- package/es/views/slides/test/index.test.js +234 -0
- package/lib/actions/api/fetch-skills.d.ts +3 -3
- package/lib/actions/api/fetch-skills.js +22 -19
- package/lib/actions/api/fetch-slide.d.ts +1 -1
- package/lib/actions/api/fetch-slide.js +3 -1
- package/lib/actions/api/post-answer.d.ts +10 -0
- package/lib/actions/api/post-answer.js +75 -0
- package/lib/actions/api/post-progression.d.ts +3 -3
- package/lib/actions/api/post-progression.js +6 -3
- package/lib/actions/api/test/fetch-skills.test.js +7 -4
- package/lib/actions/api/test/fetch-slide.test.js +7 -4
- package/lib/actions/api/test/post-answer.test.d.ts +1 -0
- package/lib/actions/api/test/post-answer.test.js +145 -0
- package/lib/actions/api/test/post-progression.test.js +7 -4
- package/lib/actions/data/test/token.test.d.ts +1 -0
- package/lib/actions/data/test/token.test.js +70 -0
- package/lib/actions/index.d.ts +1 -8
- package/lib/actions/{api/test → test}/create-test-store.d.ts +2 -2
- package/lib/actions/{api/test → test}/create-test-store.js +1 -1
- package/lib/actions/ui/answers.d.ts +17 -3
- package/lib/actions/ui/answers.js +48 -3
- package/lib/actions/ui/slides.d.ts +0 -5
- package/lib/actions/ui/slides.js +0 -4
- package/lib/actions/ui/test/answers.test.d.ts +1 -0
- package/lib/actions/ui/test/answers.test.js +171 -0
- package/lib/actions/ui/test/slides.test.d.ts +1 -0
- package/lib/actions/ui/test/slides.test.js +71 -0
- package/lib/common/index.d.ts +0 -3
- package/lib/common/index.js +0 -4
- package/lib/index.js +1 -3
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +2 -3
- package/lib/reducers/data/progression.js +0 -5
- package/lib/reducers/data/slides.d.ts +2 -3
- package/lib/reducers/data/test/progression.test.js +1 -1
- package/lib/reducers/index.d.ts +2 -1
- package/lib/reducers/ui/answers.d.ts +2 -2
- package/lib/reducers/ui/answers.js +4 -8
- package/lib/reducers/ui/index.d.ts +4 -1
- package/lib/reducers/ui/index.js +3 -1
- package/lib/reducers/ui/slide.d.ts +8 -0
- package/lib/reducers/ui/slide.js +27 -0
- package/lib/reducers/ui/test/answers.test.js +19 -3
- package/lib/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/lib/reducers/ui/test/navigation.test.js +5 -5
- package/lib/reducers/ui/test/slide.test.d.ts +1 -0
- package/lib/reducers/ui/test/slide.test.js +12 -0
- package/lib/test/util/services.mock.d.ts +2 -1
- package/lib/test/util/services.mock.js +86 -72
- package/lib/types/common.d.ts +0 -25
- package/lib/views/skills/index.d.ts +1 -1
- package/lib/views/skills/index.js +0 -3
- package/lib/views/skills/test/skills.test.d.ts +1 -0
- package/lib/views/skills/test/skills.test.js +94 -0
- package/lib/views/slides/index.d.ts +13 -2
- package/lib/views/slides/index.js +18 -14
- package/lib/views/slides/map-api-slide-to-ui.js +77 -76
- package/lib/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/lib/views/slides/test/fixtures/select-template.d.ts +2 -1
- package/lib/views/slides/test/fixtures/slider.d.ts +2 -1
- package/lib/views/slides/test/fixtures/text-template.d.ts +2 -1
- package/lib/views/slides/test/index.test.d.ts +1 -0
- package/lib/views/slides/test/index.test.js +234 -0
- package/package.json +6 -5
- package/src/actions/api/fetch-skills.ts +18 -11
- package/src/actions/api/fetch-slide.ts +3 -1
- package/src/actions/api/post-answer.ts +39 -0
- package/src/actions/api/post-progression.ts +7 -4
- package/src/actions/api/test/fetch-skills.test.ts +9 -6
- package/src/actions/api/test/fetch-slide.test.ts +9 -6
- package/src/actions/api/test/post-answer.test.ts +101 -0
- package/src/actions/api/test/post-progression.test.ts +9 -6
- package/src/actions/data/test/token.test.ts +29 -0
- package/src/actions/index.ts +1 -17
- package/src/actions/{api/test → test}/create-test-store.ts +2 -2
- package/src/actions/ui/answers.ts +52 -5
- package/src/actions/ui/slides.ts +1 -8
- package/src/actions/ui/test/answers.test.ts +103 -0
- package/src/actions/ui/test/slides.test.ts +30 -0
- package/src/common/index.ts +0 -7
- package/src/index.tsx +1 -3
- package/src/reducers/data/progression.ts +2 -7
- package/src/reducers/data/slides.ts +2 -3
- package/src/reducers/data/test/progression.test.ts +3 -3
- package/src/reducers/ui/answers.ts +5 -9
- package/src/reducers/ui/index.ts +4 -1
- package/src/reducers/ui/slide.ts +43 -0
- package/src/reducers/ui/test/answers.test.ts +24 -4
- package/src/reducers/ui/test/current-slide-ref.test.ts +1 -1
- package/src/reducers/ui/test/navigation.test.ts +5 -5
- package/src/reducers/ui/test/slide.test.ts +15 -0
- package/src/test/util/services.mock.ts +91 -73
- package/src/types/common.ts +0 -30
- package/src/views/skills/index.ts +1 -5
- package/src/views/skills/test/skills.test.ts +101 -0
- package/src/views/slides/index.ts +37 -22
- package/src/views/slides/map-api-slide-to-ui.ts +89 -89
- package/src/views/slides/test/fixtures/free-text.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-drag.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-graphic.ts +2 -1
- package/src/views/slides/test/fixtures/qcm.ts +2 -1
- package/src/views/slides/test/fixtures/select-template.ts +2 -1
- package/src/views/slides/test/fixtures/slider.ts +2 -1
- package/src/views/slides/test/fixtures/text-template.ts +2 -1
- package/src/views/slides/test/index.test.ts +240 -0
- package/src/views/slides/test/map-api-slide-to-ui.test.ts +2 -1
- package/es/fixtures/qcm-slide.d.ts +0 -2
- package/es/fixtures/qcm-slide.js +0 -33
- package/es/fixtures/temp-fixture.d.ts +0 -3
- package/es/fixtures/temp-fixture.js +0 -84
- package/lib/fixtures/qcm-slide.d.ts +0 -2
- package/lib/fixtures/qcm-slide.js +0 -33
- package/lib/fixtures/temp-fixture.d.ts +0 -3
- package/lib/fixtures/temp-fixture.js +0 -84
- package/src/fixtures/qcm-slide.ts +0 -35
- package/src/fixtures/temp-fixture.ts +0 -94
|
@@ -8,9 +8,14 @@ import {
|
|
|
8
8
|
indexOf,
|
|
9
9
|
isEmpty,
|
|
10
10
|
map,
|
|
11
|
+
multiply,
|
|
12
|
+
pipe,
|
|
11
13
|
rangeStep,
|
|
14
|
+
round,
|
|
12
15
|
size,
|
|
13
|
-
toInteger
|
|
16
|
+
toInteger,
|
|
17
|
+
toString as _toString,
|
|
18
|
+
__
|
|
14
19
|
} from 'lodash/fp';
|
|
15
20
|
import {Dispatch} from 'redux';
|
|
16
21
|
import {
|
|
@@ -37,67 +42,63 @@ import {
|
|
|
37
42
|
} from '../../types/common';
|
|
38
43
|
import {editAnswer} from '../../actions/ui/answers';
|
|
39
44
|
|
|
40
|
-
const qcmProps =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
)
|
|
45
|
+
const qcmProps =
|
|
46
|
+
(dispatch: Dispatch) =>
|
|
47
|
+
(answers: string[], question: QcmQuestion): Qcm => {
|
|
48
|
+
return {
|
|
49
|
+
type: 'qcm',
|
|
50
|
+
answers: map(choice => {
|
|
51
|
+
const label = choice.label || '';
|
|
52
|
+
return {
|
|
53
|
+
title: label,
|
|
54
|
+
selected: includes(label, answers),
|
|
55
|
+
onClick: (): void => {
|
|
56
|
+
dispatch(editAnswer(label));
|
|
57
|
+
},
|
|
58
|
+
ariaLabel: choice.label
|
|
59
|
+
};
|
|
60
|
+
}, question.content.choices)
|
|
61
|
+
};
|
|
58
62
|
};
|
|
59
|
-
};
|
|
60
63
|
|
|
61
|
-
const qcmDragProps =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
64
|
+
const qcmDragProps =
|
|
65
|
+
(dispatch: Dispatch) =>
|
|
66
|
+
(answers: string[], question: QcmDragQuestion): QcmDrag => {
|
|
67
|
+
return {
|
|
68
|
+
type: 'qcmDrag',
|
|
69
|
+
answers: map(choice => {
|
|
70
|
+
const label = choice.label || '';
|
|
71
|
+
const indexInAnswer = indexOf(label, answers);
|
|
72
|
+
return {
|
|
73
|
+
title: label,
|
|
74
|
+
selected: includes(label, answers),
|
|
75
|
+
order: indexInAnswer,
|
|
76
|
+
onClick: (): void => {
|
|
77
|
+
dispatch(editAnswer(label));
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, question.content.choices)
|
|
81
|
+
};
|
|
78
82
|
};
|
|
79
|
-
};
|
|
80
83
|
|
|
81
|
-
const qcmGraphicProps =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
)
|
|
84
|
+
const qcmGraphicProps =
|
|
85
|
+
(dispatch: Dispatch) =>
|
|
86
|
+
(answers: string[], question: QcmGraphicQuestion): QcmGraphic => {
|
|
87
|
+
return {
|
|
88
|
+
type: 'qcmGraphic',
|
|
89
|
+
answers: map(choice => {
|
|
90
|
+
const label = choice.label || '';
|
|
91
|
+
return {
|
|
92
|
+
title: label,
|
|
93
|
+
image: get('media.src.0.url', choice),
|
|
94
|
+
selected: includes(label, answers),
|
|
95
|
+
onClick: (): void => {
|
|
96
|
+
dispatch(editAnswer(label));
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}, question.content.choices)
|
|
100
|
+
};
|
|
99
101
|
};
|
|
100
|
-
};
|
|
101
102
|
|
|
102
103
|
const templateTextProps = (choice: ChoiceFromAPI, index: number): TextTemplate => {
|
|
103
104
|
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
@@ -163,44 +164,43 @@ const basicProps =
|
|
|
163
164
|
placeholder: question.content.placeholder || '',
|
|
164
165
|
value: answers[0] || '',
|
|
165
166
|
onChange: (text: string): void => {
|
|
166
|
-
// eslint-disable-next-line no-console
|
|
167
|
-
console.log(text);
|
|
168
167
|
dispatch(editAnswer(text));
|
|
169
168
|
}
|
|
170
169
|
};
|
|
171
170
|
};
|
|
172
171
|
|
|
173
|
-
const sliderProps =
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const answers: string[] = [];
|
|
172
|
+
const sliderProps =
|
|
173
|
+
(dispatch: Dispatch) =>
|
|
174
|
+
(answers: string[], question: SliderQuestion): QuestionRange => {
|
|
175
|
+
const values: number[] = rangeStep(
|
|
176
|
+
getOr(1, 'content.step', question),
|
|
177
|
+
get('content.min', question),
|
|
178
|
+
get('content.max', question) + 1
|
|
179
|
+
// Lodash doesn't infer the type very well here
|
|
180
|
+
) as unknown as number[];
|
|
183
181
|
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
const stateValue = head(answers) || question.content.min;
|
|
183
|
+
const currentValue = toInteger(stateValue);
|
|
186
184
|
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
const indexValue = indexOf(currentValue, values);
|
|
186
|
+
const maxValue = size(values) - 1;
|
|
187
|
+
const sliderPosition = divide(indexValue, maxValue);
|
|
189
188
|
|
|
190
|
-
|
|
189
|
+
const unitLabel = get('content.unitLabel', question);
|
|
191
190
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
191
|
+
return {
|
|
192
|
+
type: 'slider',
|
|
193
|
+
placeholder: question.explanation,
|
|
194
|
+
minLabel: `${question.content.min} ${unitLabel}`,
|
|
195
|
+
maxLabel: `${question.content.max} ${unitLabel}`,
|
|
196
|
+
title: `${currentValue} ${question.content.unitLabel}`,
|
|
197
|
+
value: sliderPosition,
|
|
198
|
+
onChange: (position: number): void => {
|
|
199
|
+
const newValue = pipe(multiply(maxValue), round, get(__, values), _toString)(position);
|
|
200
|
+
dispatch(editAnswer(newValue));
|
|
201
|
+
}
|
|
202
|
+
};
|
|
202
203
|
};
|
|
203
|
-
};
|
|
204
204
|
|
|
205
205
|
export const getQuestionType = (question: Question): Question['type'] => question.type;
|
|
206
206
|
|
|
@@ -214,13 +214,13 @@ const getAnswerUIModel = (
|
|
|
214
214
|
const type = getQuestionType(question);
|
|
215
215
|
switch (type) {
|
|
216
216
|
case 'qcm':
|
|
217
|
-
return qcmProps(question as QcmQuestion);
|
|
217
|
+
return qcmProps(dispatch)(answers, question as QcmQuestion);
|
|
218
218
|
|
|
219
219
|
case 'qcmGraphic':
|
|
220
|
-
return qcmGraphicProps(question as QcmGraphicQuestion);
|
|
220
|
+
return qcmGraphicProps(dispatch)(answers, question as QcmGraphicQuestion);
|
|
221
221
|
|
|
222
222
|
case 'qcmDrag':
|
|
223
|
-
return qcmDragProps(question as QcmDragQuestion);
|
|
223
|
+
return qcmDragProps(dispatch)(answers, question as QcmDragQuestion);
|
|
224
224
|
|
|
225
225
|
case 'basic':
|
|
226
226
|
return basicProps(dispatch)(answers, question as BasicQuestion);
|
|
@@ -229,7 +229,7 @@ const getAnswerUIModel = (
|
|
|
229
229
|
return templateProps(question as TemplateQuestion);
|
|
230
230
|
|
|
231
231
|
case 'slider':
|
|
232
|
-
return sliderProps(question as SliderQuestion);
|
|
232
|
+
return sliderProps(dispatch)(answers, question as SliderQuestion);
|
|
233
233
|
|
|
234
234
|
default:
|
|
235
235
|
throw new Error(`${type} is not an handled question.type`);
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import identity from 'lodash/fp/identity';
|
|
3
|
+
import omit from 'lodash/fp/omit';
|
|
4
|
+
import {mapStateToSlidesProps} from '..';
|
|
5
|
+
import {StoreState} from '../../../reducers';
|
|
6
|
+
import {freeTextSlide} from './fixtures/free-text';
|
|
7
|
+
|
|
8
|
+
test('should create initial props when fetched slide is still not received', t => {
|
|
9
|
+
const state: StoreState = {
|
|
10
|
+
data: {
|
|
11
|
+
progression: {
|
|
12
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
13
|
+
content: {
|
|
14
|
+
ref: '_skillref',
|
|
15
|
+
type: 'skill'
|
|
16
|
+
},
|
|
17
|
+
engine: {
|
|
18
|
+
ref: 'review'
|
|
19
|
+
},
|
|
20
|
+
state: {
|
|
21
|
+
allAnswers: [],
|
|
22
|
+
isCorrect: true,
|
|
23
|
+
nextContent: {
|
|
24
|
+
ref: 'sli_N1XACJobn',
|
|
25
|
+
type: 'slide'
|
|
26
|
+
},
|
|
27
|
+
pendingSlides: [],
|
|
28
|
+
slides: [],
|
|
29
|
+
step: {
|
|
30
|
+
current: 1
|
|
31
|
+
},
|
|
32
|
+
stars: 0
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
skills: [],
|
|
36
|
+
slides: {
|
|
37
|
+
sli_N1XACJobn: null
|
|
38
|
+
},
|
|
39
|
+
token: '1234'
|
|
40
|
+
},
|
|
41
|
+
ui: {
|
|
42
|
+
currentSlideRef: '',
|
|
43
|
+
navigation: ['loader', 'slides'],
|
|
44
|
+
answers: [],
|
|
45
|
+
slide: {
|
|
46
|
+
validateButton: false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const props = mapStateToSlidesProps(state, identity);
|
|
52
|
+
t.is(props.congratsProps, undefined);
|
|
53
|
+
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
54
|
+
'aria-label': 'aria-header-wrapper',
|
|
55
|
+
closeButtonAriaLabel: 'aria-close-button',
|
|
56
|
+
mode: '__revision_mode',
|
|
57
|
+
skillName: '__agility',
|
|
58
|
+
steps: [
|
|
59
|
+
{
|
|
60
|
+
current: true,
|
|
61
|
+
icon: 'no-answer',
|
|
62
|
+
value: '1'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
current: false,
|
|
66
|
+
icon: 'no-answer',
|
|
67
|
+
value: '2'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
current: false,
|
|
71
|
+
icon: 'no-answer',
|
|
72
|
+
value: '3'
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
current: false,
|
|
76
|
+
icon: 'no-answer',
|
|
77
|
+
value: '4'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
current: false,
|
|
81
|
+
icon: 'no-answer',
|
|
82
|
+
value: '5'
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
t.deepEqual(omit(['validateButton'], props.stack), {
|
|
87
|
+
correctionPopinProps: undefined,
|
|
88
|
+
endReview: false,
|
|
89
|
+
slides: {
|
|
90
|
+
'0': {
|
|
91
|
+
hidden: false,
|
|
92
|
+
position: 0,
|
|
93
|
+
loading: true
|
|
94
|
+
},
|
|
95
|
+
'1': {
|
|
96
|
+
hidden: false,
|
|
97
|
+
position: 1,
|
|
98
|
+
loading: true
|
|
99
|
+
},
|
|
100
|
+
'2': {
|
|
101
|
+
hidden: false,
|
|
102
|
+
position: 2,
|
|
103
|
+
loading: true
|
|
104
|
+
},
|
|
105
|
+
'3': {
|
|
106
|
+
hidden: false,
|
|
107
|
+
position: 3,
|
|
108
|
+
loading: true
|
|
109
|
+
},
|
|
110
|
+
'4': {
|
|
111
|
+
hidden: false,
|
|
112
|
+
position: 4,
|
|
113
|
+
loading: true
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('should create initial props when the slide is on the state', t => {
|
|
120
|
+
const state: StoreState = {
|
|
121
|
+
data: {
|
|
122
|
+
progression: {
|
|
123
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
124
|
+
content: {
|
|
125
|
+
ref: '_skillref',
|
|
126
|
+
type: 'skill'
|
|
127
|
+
},
|
|
128
|
+
engine: {
|
|
129
|
+
ref: 'review'
|
|
130
|
+
},
|
|
131
|
+
state: {
|
|
132
|
+
allAnswers: [],
|
|
133
|
+
isCorrect: true,
|
|
134
|
+
nextContent: {
|
|
135
|
+
ref: 'sli_N1XACJobn',
|
|
136
|
+
type: 'slide'
|
|
137
|
+
},
|
|
138
|
+
pendingSlides: [],
|
|
139
|
+
slides: [],
|
|
140
|
+
step: {
|
|
141
|
+
current: 1
|
|
142
|
+
},
|
|
143
|
+
stars: 0
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
skills: [],
|
|
147
|
+
slides: {
|
|
148
|
+
sli_N1XACJobn: freeTextSlide
|
|
149
|
+
},
|
|
150
|
+
token: '1234'
|
|
151
|
+
},
|
|
152
|
+
ui: {
|
|
153
|
+
currentSlideRef: 'sli_N1XACJobn',
|
|
154
|
+
navigation: ['loader', 'slides'],
|
|
155
|
+
answers: ['My value'],
|
|
156
|
+
slide: {
|
|
157
|
+
validateButton: true
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const props = mapStateToSlidesProps(state, identity);
|
|
163
|
+
t.is(props.congratsProps, undefined);
|
|
164
|
+
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
165
|
+
'aria-label': 'aria-header-wrapper',
|
|
166
|
+
closeButtonAriaLabel: 'aria-close-button',
|
|
167
|
+
mode: '__revision_mode',
|
|
168
|
+
skillName: '__agility',
|
|
169
|
+
steps: [
|
|
170
|
+
{
|
|
171
|
+
current: true,
|
|
172
|
+
icon: 'no-answer',
|
|
173
|
+
value: '1'
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
current: false,
|
|
177
|
+
icon: 'no-answer',
|
|
178
|
+
value: '2'
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
current: false,
|
|
182
|
+
icon: 'no-answer',
|
|
183
|
+
value: '3'
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
current: false,
|
|
187
|
+
icon: 'no-answer',
|
|
188
|
+
value: '4'
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
current: false,
|
|
192
|
+
icon: 'no-answer',
|
|
193
|
+
value: '5'
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
});
|
|
197
|
+
t.deepEqual(omit(['validateButton', 'slides'], props.stack), {
|
|
198
|
+
correctionPopinProps: undefined,
|
|
199
|
+
endReview: false
|
|
200
|
+
});
|
|
201
|
+
t.false(props.stack.validateButton.disabled);
|
|
202
|
+
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
203
|
+
hidden: false,
|
|
204
|
+
position: 0,
|
|
205
|
+
loading: false,
|
|
206
|
+
parentContentTitle: 'From "Developing the review app" course',
|
|
207
|
+
questionText:
|
|
208
|
+
'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
|
|
209
|
+
});
|
|
210
|
+
t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
|
|
211
|
+
help: 'Type your answer.',
|
|
212
|
+
model: {
|
|
213
|
+
placeholder: 'Type here',
|
|
214
|
+
type: 'freeText',
|
|
215
|
+
value: 'My value'
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
t.deepEqual(omit(['0'], props.stack.slides), {
|
|
219
|
+
'1': {
|
|
220
|
+
hidden: false,
|
|
221
|
+
position: 1,
|
|
222
|
+
loading: true
|
|
223
|
+
},
|
|
224
|
+
'2': {
|
|
225
|
+
hidden: false,
|
|
226
|
+
position: 2,
|
|
227
|
+
loading: true
|
|
228
|
+
},
|
|
229
|
+
'3': {
|
|
230
|
+
hidden: false,
|
|
231
|
+
position: 3,
|
|
232
|
+
loading: true
|
|
233
|
+
},
|
|
234
|
+
'4': {
|
|
235
|
+
hidden: false,
|
|
236
|
+
position: 4,
|
|
237
|
+
loading: true
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import identity from 'lodash/fp/identity';
|
|
3
|
-
import {SlideFromAPI
|
|
3
|
+
import {SlideFromAPI} from '../../../types/common';
|
|
4
4
|
import {mapApiSlideToUi} from '../map-api-slide-to-ui';
|
|
5
|
+
import {UISlide} from '..';
|
|
5
6
|
import {qcmUISlide, qcmSlide} from './fixtures/qcm';
|
|
6
7
|
import {qcmDragUISlide, qcmDragSlide} from './fixtures/qcm-drag';
|
|
7
8
|
import {freeTextSlide, freeTextUISlide} from './fixtures/free-text';
|
package/es/fixtures/qcm-slide.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import noop from 'lodash/fp/noop';
|
|
2
|
-
export const slide = {
|
|
3
|
-
questionText: 'QCM',
|
|
4
|
-
answerUI: {
|
|
5
|
-
help: '__help',
|
|
6
|
-
model: {
|
|
7
|
-
type: 'qcm',
|
|
8
|
-
answers: [
|
|
9
|
-
{
|
|
10
|
-
selected: false,
|
|
11
|
-
title: 'choix1',
|
|
12
|
-
help: '(help choix1)',
|
|
13
|
-
ariaLabel: '__ariaLabel1',
|
|
14
|
-
onClick: noop
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
selected: false,
|
|
18
|
-
title: 'choix2',
|
|
19
|
-
help: '(help choix2)',
|
|
20
|
-
ariaLabel: '__ariaLabel2',
|
|
21
|
-
onClick: noop
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
selected: false,
|
|
25
|
-
title: 'choix3',
|
|
26
|
-
help: '(help choix3)',
|
|
27
|
-
ariaLabel: '__ariaLabel3',
|
|
28
|
-
onClick: noop
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
export const correctionPopinProps = {
|
|
2
|
-
klf: {
|
|
3
|
-
label: 'Key learning factor',
|
|
4
|
-
tooltip: 'Some tooltip info.',
|
|
5
|
-
onClick: () => {
|
|
6
|
-
console.log('klf onClick');
|
|
7
|
-
}
|
|
8
|
-
},
|
|
9
|
-
information: {
|
|
10
|
-
label: 'Key learning factor',
|
|
11
|
-
message: 'info msg'
|
|
12
|
-
},
|
|
13
|
-
next: {
|
|
14
|
-
label: 'Next',
|
|
15
|
-
ariaLabel: 'Next'
|
|
16
|
-
},
|
|
17
|
-
successLabel: 'CORRECT ANSWER',
|
|
18
|
-
failureLabel: 'WRONG ANSWER'
|
|
19
|
-
};
|
|
20
|
-
const confettiAnimationProps = {
|
|
21
|
-
'aria-label': 'aria lottie',
|
|
22
|
-
'data-name': 'default-lottie',
|
|
23
|
-
className: undefined,
|
|
24
|
-
animationSrc: 'https://static-staging.coorpacademy.com/animations/review/confetti.json',
|
|
25
|
-
loop: undefined,
|
|
26
|
-
autoplay: true,
|
|
27
|
-
rendererSettings: {
|
|
28
|
-
hideOnTransparent: false,
|
|
29
|
-
animationClassName: ''
|
|
30
|
-
},
|
|
31
|
-
ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/conffeti_congrats.svg',
|
|
32
|
-
animationControl: undefined
|
|
33
|
-
};
|
|
34
|
-
const starAnimationProps = {
|
|
35
|
-
'aria-label': 'Review Card Congrats Container',
|
|
36
|
-
'data-name': 'card-star',
|
|
37
|
-
animationLottie: {
|
|
38
|
-
'aria-label': 'aria lottie',
|
|
39
|
-
'data-name': 'default-lottie',
|
|
40
|
-
animationSrc: 'https://static-staging.coorpacademy.com/animations/review/star.json',
|
|
41
|
-
ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg'
|
|
42
|
-
},
|
|
43
|
-
iconAriaLabel: 'Image without information',
|
|
44
|
-
cardType: 'card-star',
|
|
45
|
-
reviewCardTitle: 'You have won',
|
|
46
|
-
reviewCardValue: '100',
|
|
47
|
-
timerAnimation: 200
|
|
48
|
-
};
|
|
49
|
-
const rankAnimationProps = {
|
|
50
|
-
'aria-label': 'Review Card Congrats Container',
|
|
51
|
-
'data-name': 'card-rank',
|
|
52
|
-
animationLottie: {
|
|
53
|
-
'aria-label': 'aria lottie',
|
|
54
|
-
'data-name': 'default-lottie',
|
|
55
|
-
animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',
|
|
56
|
-
ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg'
|
|
57
|
-
},
|
|
58
|
-
cardType: 'card-rank',
|
|
59
|
-
iconAriaLabel: 'Image without information',
|
|
60
|
-
reviewCardTitle: 'You are now',
|
|
61
|
-
reviewCardValue: '14',
|
|
62
|
-
rankSuffix: 'th',
|
|
63
|
-
timerAnimation: 200
|
|
64
|
-
};
|
|
65
|
-
export const congratsProps = {
|
|
66
|
-
'aria-label': 'Review Congratulations',
|
|
67
|
-
'data-name': 'review-congrats',
|
|
68
|
-
animationLottie: confettiAnimationProps,
|
|
69
|
-
title: 'Congratulations!',
|
|
70
|
-
cardCongratsStar: starAnimationProps,
|
|
71
|
-
cardCongratsRank: rankAnimationProps,
|
|
72
|
-
buttonRevising: {
|
|
73
|
-
'aria-label': 'Continue revising button',
|
|
74
|
-
label: 'Continue revising',
|
|
75
|
-
onClick: () => console.log('Continue revising'),
|
|
76
|
-
type: 'tertiary'
|
|
77
|
-
},
|
|
78
|
-
buttonRevisingSkill: {
|
|
79
|
-
label: 'Revise another skill',
|
|
80
|
-
'aria-label': 'Revise another skill button',
|
|
81
|
-
onClick: () => console.log('Revise another skill'),
|
|
82
|
-
type: 'primary'
|
|
83
|
-
}
|
|
84
|
-
};
|