@coorpacademy/player-web 4.2.10 → 4.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -4
- package/es/map-state-to-props/test/answer.js +0 -390
- package/es/map-state-to-props/test/answer.js.map +0 -1
- package/es/map-state-to-props/test/fixtures/player/clue.json +0 -131
- package/es/map-state-to-props/test/fixtures/player/loading-clue.json +0 -131
- package/es/map-state-to-props/test/fixtures/player/no-clue.json +0 -118
- package/es/map-state-to-props/test/fixtures/player/slide-no-lessons.json +0 -115
- package/es/map-state-to-props/test/fixtures/player/slide.json +0 -127
- package/es/map-state-to-props/test/fixtures/popin-correction/popin-extra-life.json +0 -139
- package/es/map-state-to-props/test/fixtures/popin-correction/popin-failure.json +0 -145
- package/es/map-state-to-props/test/fixtures/popin-correction/popin-next-level.json +0 -282
- package/es/map-state-to-props/test/fixtures/popin-correction/popin-revival.json +0 -140
- package/es/map-state-to-props/test/fixtures/popin-correction/popin-success-node.json +0 -154
- package/es/map-state-to-props/test/fixtures/popin-correction/popin-success.json +0 -268
- package/es/map-state-to-props/test/fixtures/popin-correction/state-fail-multiple-answers.json +0 -473
- package/es/map-state-to-props/test/fixtures/popin-end/fail.json +0 -205
- package/es/map-state-to-props/test/fixtures/popin-end/learner-adaptive-failure.json +0 -209
- package/es/map-state-to-props/test/fixtures/popin-end/learner-failure-with-redirection.json +0 -211
- package/es/map-state-to-props/test/fixtures/popin-end/learner-failure.json +0 -211
- package/es/map-state-to-props/test/fixtures/popin-end/learner-success-with-redirection.json +0 -278
- package/es/map-state-to-props/test/fixtures/popin-end/learner-success.json +0 -275
- package/es/map-state-to-props/test/fixtures/popin-end/success.json +0 -223
- package/es/map-state-to-props/test/fixtures/progression-learner.json +0 -102
- package/es/map-state-to-props/test/fixtures/progression-state.json +0 -45
- package/es/map-state-to-props/test/fixtures/slides/basic.json +0 -60
- package/es/map-state-to-props/test/fixtures/slides/plop.json +0 -56
- package/es/map-state-to-props/test/fixtures/slides/qcm-drag.json +0 -56
- package/es/map-state-to-props/test/fixtures/slides/qcm-graphic.json +0 -49
- package/es/map-state-to-props/test/fixtures/slides/qcm.json +0 -43
- package/es/map-state-to-props/test/fixtures/slides/slider.json +0 -57
- package/es/map-state-to-props/test/fixtures/slides/template.json +0 -49
- package/es/map-state-to-props/test/fixtures/slides/videos.json +0 -163
- package/es/map-state-to-props/test/fixtures/slides/with-context.json +0 -69
- package/es/map-state-to-props/test/header.js +0 -131
- package/es/map-state-to-props/test/header.js.map +0 -1
- package/es/map-state-to-props/test/index.js +0 -107
- package/es/map-state-to-props/test/index.js.map +0 -1
- package/es/map-state-to-props/test/player.js +0 -680
- package/es/map-state-to-props/test/player.js.map +0 -1
- package/es/map-state-to-props/test/popin-correction.create-header-cta.js +0 -301
- package/es/map-state-to-props/test/popin-correction.create-header-cta.js.map +0 -1
- package/es/map-state-to-props/test/popin-correction.js +0 -80
- package/es/map-state-to-props/test/popin-correction.js.map +0 -1
- package/es/map-state-to-props/test/popin-end.js +0 -313
- package/es/map-state-to-props/test/popin-end.js.map +0 -1
- package/es/map-state-to-props/test/popin-error.js +0 -77
- package/es/map-state-to-props/test/popin-error.js.map +0 -1
- package/es/map-state-to-props/test/resources.js +0 -31
- package/es/map-state-to-props/test/resources.js.map +0 -1
- package/es/test/add-timeout.js +0 -8
- package/es/test/add-timeout.js.map +0 -1
- package/es/test/helpers/css-register.js +0 -3
- package/es/test/helpers/css-register.js.map +0 -1
- package/es/test/helpers/macro.js +0 -6
- package/es/test/helpers/macro.js.map +0 -1
- package/es/test/index.js +0 -39
- package/es/test/index.js.map +0 -1
- package/es/test/init-reducers.js +0 -50
- package/es/test/init-reducers.js.map +0 -1
- package/es/test/locales.js +0 -8
- package/es/test/locales.js.map +0 -1
- package/es/test/run-app.js +0 -20
- package/es/test/run-app.js.map +0 -1
- package/es/test/store.js +0 -38
- package/es/test/store.js.map +0 -1
- package/es/views/test/helpers/render.js +0 -13
- package/es/views/test/helpers/render.js.map +0 -1
- package/es/views/test/helpers/state-to-vnode.js +0 -7
- package/es/views/test/helpers/state-to-vnode.js.map +0 -1
- package/es/views/test/loading.js +0 -15
- package/es/views/test/loading.js.map +0 -1
- package/es/views/test/popin-correction.js +0 -223
- package/es/views/test/popin-correction.js.map +0 -1
- package/es/views/test/popin-end.js +0 -93
- package/es/views/test/popin-end.js.map +0 -1
- package/es/views/test/router.js +0 -22
- package/es/views/test/router.js.map +0 -1
- package/es/views/test/slide.js +0 -335
- package/es/views/test/slide.js.map +0 -1
- package/lib/map-state-to-props/test/answer.js +0 -408
- package/lib/map-state-to-props/test/answer.js.map +0 -1
- package/lib/map-state-to-props/test/fixtures/player/clue.json +0 -131
- package/lib/map-state-to-props/test/fixtures/player/loading-clue.json +0 -131
- package/lib/map-state-to-props/test/fixtures/player/no-clue.json +0 -118
- package/lib/map-state-to-props/test/fixtures/player/slide-no-lessons.json +0 -115
- package/lib/map-state-to-props/test/fixtures/player/slide.json +0 -127
- package/lib/map-state-to-props/test/fixtures/popin-correction/popin-extra-life.json +0 -139
- package/lib/map-state-to-props/test/fixtures/popin-correction/popin-failure.json +0 -145
- package/lib/map-state-to-props/test/fixtures/popin-correction/popin-next-level.json +0 -282
- package/lib/map-state-to-props/test/fixtures/popin-correction/popin-revival.json +0 -140
- package/lib/map-state-to-props/test/fixtures/popin-correction/popin-success-node.json +0 -154
- package/lib/map-state-to-props/test/fixtures/popin-correction/popin-success.json +0 -268
- package/lib/map-state-to-props/test/fixtures/popin-correction/state-fail-multiple-answers.json +0 -473
- package/lib/map-state-to-props/test/fixtures/popin-end/fail.json +0 -205
- package/lib/map-state-to-props/test/fixtures/popin-end/learner-adaptive-failure.json +0 -209
- package/lib/map-state-to-props/test/fixtures/popin-end/learner-failure-with-redirection.json +0 -211
- package/lib/map-state-to-props/test/fixtures/popin-end/learner-failure.json +0 -211
- package/lib/map-state-to-props/test/fixtures/popin-end/learner-success-with-redirection.json +0 -278
- package/lib/map-state-to-props/test/fixtures/popin-end/learner-success.json +0 -275
- package/lib/map-state-to-props/test/fixtures/popin-end/success.json +0 -223
- package/lib/map-state-to-props/test/fixtures/progression-learner.json +0 -102
- package/lib/map-state-to-props/test/fixtures/progression-state.json +0 -45
- package/lib/map-state-to-props/test/fixtures/slides/basic.json +0 -60
- package/lib/map-state-to-props/test/fixtures/slides/plop.json +0 -56
- package/lib/map-state-to-props/test/fixtures/slides/qcm-drag.json +0 -56
- package/lib/map-state-to-props/test/fixtures/slides/qcm-graphic.json +0 -49
- package/lib/map-state-to-props/test/fixtures/slides/qcm.json +0 -43
- package/lib/map-state-to-props/test/fixtures/slides/slider.json +0 -57
- package/lib/map-state-to-props/test/fixtures/slides/template.json +0 -49
- package/lib/map-state-to-props/test/fixtures/slides/videos.json +0 -163
- package/lib/map-state-to-props/test/fixtures/slides/with-context.json +0 -69
- package/lib/map-state-to-props/test/header.js +0 -143
- package/lib/map-state-to-props/test/header.js.map +0 -1
- package/lib/map-state-to-props/test/index.js +0 -100
- package/lib/map-state-to-props/test/index.js.map +0 -1
- package/lib/map-state-to-props/test/player.js +0 -714
- package/lib/map-state-to-props/test/player.js.map +0 -1
- package/lib/map-state-to-props/test/popin-correction.create-header-cta.js +0 -315
- package/lib/map-state-to-props/test/popin-correction.create-header-cta.js.map +0 -1
- package/lib/map-state-to-props/test/popin-correction.js +0 -85
- package/lib/map-state-to-props/test/popin-correction.js.map +0 -1
- package/lib/map-state-to-props/test/popin-end.js +0 -328
- package/lib/map-state-to-props/test/popin-end.js.map +0 -1
- package/lib/map-state-to-props/test/popin-error.js +0 -85
- package/lib/map-state-to-props/test/popin-error.js.map +0 -1
- package/lib/map-state-to-props/test/resources.js +0 -42
- package/lib/map-state-to-props/test/resources.js.map +0 -1
- package/lib/test/add-timeout.js +0 -14
- package/lib/test/add-timeout.js.map +0 -1
- package/lib/test/helpers/css-register.js +0 -8
- package/lib/test/helpers/css-register.js.map +0 -1
- package/lib/test/helpers/macro.js +0 -12
- package/lib/test/helpers/macro.js.map +0 -1
- package/lib/test/index.js +0 -53
- package/lib/test/index.js.map +0 -1
- package/lib/test/init-reducers.js +0 -57
- package/lib/test/init-reducers.js.map +0 -1
- package/lib/test/locales.js +0 -18
- package/lib/test/locales.js.map +0 -1
- package/lib/test/run-app.js +0 -27
- package/lib/test/run-app.js.map +0 -1
- package/lib/test/store.js +0 -45
- package/lib/test/store.js.map +0 -1
- package/lib/views/test/helpers/render.js +0 -24
- package/lib/views/test/helpers/render.js.map +0 -1
- package/lib/views/test/helpers/state-to-vnode.js +0 -14
- package/lib/views/test/helpers/state-to-vnode.js.map +0 -1
- package/lib/views/test/loading.js +0 -22
- package/lib/views/test/loading.js.map +0 -1
- package/lib/views/test/popin-correction.js +0 -237
- package/lib/views/test/popin-correction.js.map +0 -1
- package/lib/views/test/popin-end.js +0 -105
- package/lib/views/test/popin-end.js.map +0 -1
- package/lib/views/test/router.js +0 -32
- package/lib/views/test/router.js.map +0 -1
- package/lib/views/test/slide.js +0 -359
- package/lib/views/test/slide.js.map +0 -1
|
@@ -1,680 +0,0 @@
|
|
|
1
|
-
import _omit from "lodash/fp/omit";
|
|
2
|
-
import _identity from "lodash/fp/identity";
|
|
3
|
-
import _isFunction from "lodash/fp/isFunction";
|
|
4
|
-
import _fromPairs from "lodash/fp/fromPairs";
|
|
5
|
-
import _pipe from "lodash/fp/pipe";
|
|
6
|
-
import _set from "lodash/fp/set";
|
|
7
|
-
import _isEmpty from "lodash/fp/isEmpty";
|
|
8
|
-
import _get from "lodash/fp/get";
|
|
9
|
-
import _map from "lodash/fp/map";
|
|
10
|
-
|
|
11
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
|
-
|
|
13
|
-
import test from 'ava';
|
|
14
|
-
import { mockTranslate } from '@coorpacademy/translate';
|
|
15
|
-
import { Analytics as AnalyticsService, Answers as AnswersService, Clues as CluesService, Coach as CoachService, Comments as CommentsService, Content as ContentService, ExitNodes as ExitNodesService, LeaderBoard as LeaderBoardService, Location as LocationService, Progressions as ProgressionsService, Recommendations as RecommendationsService } from '@coorpacademy/player-services';
|
|
16
|
-
import { UI_SELECT_ROUTE } from '@coorpacademy/player-store';
|
|
17
|
-
import createPlayer from '../player';
|
|
18
|
-
import createHeader from '../header';
|
|
19
|
-
import * as fixtures from '../../../sandbox/fixtures';
|
|
20
|
-
import learnerProgressionStateFixture from './fixtures/progression-learner';
|
|
21
|
-
import plopSlide from './fixtures/slides/plop';
|
|
22
|
-
import basicSlide from './fixtures/slides/basic';
|
|
23
|
-
import contextSlide from './fixtures/slides/with-context';
|
|
24
|
-
import templateSlide from './fixtures/slides/template';
|
|
25
|
-
import qcmSlide from './fixtures/slides/qcm';
|
|
26
|
-
import qcmDragSlide from './fixtures/slides/qcm-drag';
|
|
27
|
-
import qcmGraphicSlide from './fixtures/slides/qcm-graphic';
|
|
28
|
-
const services = {
|
|
29
|
-
Analytics: AnalyticsService,
|
|
30
|
-
Answers: AnswersService(fixtures),
|
|
31
|
-
Clues: CluesService(fixtures),
|
|
32
|
-
Coach: CoachService,
|
|
33
|
-
Comments: CommentsService,
|
|
34
|
-
Content: ContentService(fixtures),
|
|
35
|
-
ExitNodes: ExitNodesService(fixtures),
|
|
36
|
-
LeaderBoard: LeaderBoardService,
|
|
37
|
-
Location: LocationService,
|
|
38
|
-
Logger: console,
|
|
39
|
-
Progressions: ProgressionsService(fixtures),
|
|
40
|
-
Recommendations: RecommendationsService(fixtures)
|
|
41
|
-
};
|
|
42
|
-
export const options = {
|
|
43
|
-
translate: mockTranslate,
|
|
44
|
-
services
|
|
45
|
-
};
|
|
46
|
-
export const store = {
|
|
47
|
-
dispatch: _identity
|
|
48
|
-
};
|
|
49
|
-
const createPlayerProps = createPlayer(options, store);
|
|
50
|
-
const createHeaderProps = createHeader(options, store);
|
|
51
|
-
|
|
52
|
-
const availableSlides = _pipe(_map(slide => [slide._id, slide]), _fromPairs)([basicSlide, plopSlide, qcmSlide, qcmDragSlide, qcmGraphicSlide, contextSlide]);
|
|
53
|
-
|
|
54
|
-
const createProgression = (slide, contentRef) => ({
|
|
55
|
-
engine: {
|
|
56
|
-
ref: 'microlearning',
|
|
57
|
-
version: '1'
|
|
58
|
-
},
|
|
59
|
-
content: {
|
|
60
|
-
ref: contentRef,
|
|
61
|
-
type: 'chapter'
|
|
62
|
-
},
|
|
63
|
-
state: {
|
|
64
|
-
nextContent: {
|
|
65
|
-
ref: slide._id,
|
|
66
|
-
type: 'slide'
|
|
67
|
-
},
|
|
68
|
-
lives: 1,
|
|
69
|
-
livesDisabled: false,
|
|
70
|
-
step: {
|
|
71
|
-
current: 1
|
|
72
|
-
},
|
|
73
|
-
viewedResources: []
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
export const data = {
|
|
78
|
-
contents: {
|
|
79
|
-
chapter: {
|
|
80
|
-
entities: {
|
|
81
|
-
nonAdaptiveContent: {
|
|
82
|
-
_id: 'nonAdaptiveContent',
|
|
83
|
-
isConditional: false
|
|
84
|
-
},
|
|
85
|
-
adaptiveContent: {
|
|
86
|
-
_id: 'adaptiveContent',
|
|
87
|
-
isConditional: true
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
slide: {
|
|
92
|
-
entities: availableSlides
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
progressions: {
|
|
96
|
-
entities: {
|
|
97
|
-
basic: createProgression(basicSlide, 'nonAdaptiveContent'),
|
|
98
|
-
plop: createProgression(plopSlide, 'nonAdaptiveContent'),
|
|
99
|
-
qcm: createProgression(qcmSlide, 'nonAdaptiveContent'),
|
|
100
|
-
qcmDrag: createProgression(qcmDragSlide, 'nonAdaptiveContent'),
|
|
101
|
-
qcmGraphic: createProgression(qcmGraphicSlide, 'nonAdaptiveContent'),
|
|
102
|
-
template: createProgression(templateSlide, 'nonAdaptiveContent'),
|
|
103
|
-
context: createProgression(contextSlide, 'nonAdaptiveContent'),
|
|
104
|
-
adaptiveBasic: createProgression(basicSlide, 'adaptiveContent'),
|
|
105
|
-
adaptiveQcm: createProgression(qcmSlide, 'adaptiveContent'),
|
|
106
|
-
adaptiveQcmDrag: createProgression(qcmDragSlide, 'adaptiveContent'),
|
|
107
|
-
adaptiveQcmGraphic: createProgression(qcmGraphicSlide, 'adaptiveContent'),
|
|
108
|
-
adaptiveContext: createProgression(contextSlide, 'adaptiveContent'),
|
|
109
|
-
adaptiveTemplate: createProgression(templateSlide, 'adaptiveContent')
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const isDisabledFor = (slide, isConditional, answer) => {
|
|
115
|
-
const progressionId = 'progression';
|
|
116
|
-
const chapterId = 'chapter';
|
|
117
|
-
return createPlayerProps({
|
|
118
|
-
data: {
|
|
119
|
-
contents: {
|
|
120
|
-
slide: {
|
|
121
|
-
entities: {
|
|
122
|
-
[slide._id]: _extends({}, slide, {
|
|
123
|
-
chapter_id: chapterId
|
|
124
|
-
})
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
chapter: {
|
|
128
|
-
entities: {
|
|
129
|
-
[chapterId]: {
|
|
130
|
-
_id: chapterId,
|
|
131
|
-
isConditional
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
progressions: {
|
|
137
|
-
entities: {
|
|
138
|
-
[progressionId]: createProgression(slide, chapterId)
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
ui: {
|
|
143
|
-
route: {
|
|
144
|
-
[progressionId]: 'answer'
|
|
145
|
-
},
|
|
146
|
-
current: {
|
|
147
|
-
progressionId
|
|
148
|
-
},
|
|
149
|
-
answers: {
|
|
150
|
-
[progressionId]: {
|
|
151
|
-
value: answer
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}).cta.disabled;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
test('should create player props for basic question and show coaches', t => {
|
|
159
|
-
const state = {
|
|
160
|
-
data,
|
|
161
|
-
ui: {
|
|
162
|
-
route: {
|
|
163
|
-
basic: 'answer'
|
|
164
|
-
},
|
|
165
|
-
current: {
|
|
166
|
-
progressionId: 'basic'
|
|
167
|
-
},
|
|
168
|
-
coaches: {
|
|
169
|
-
availableCoaches: 1
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
const props = createPlayerProps(state);
|
|
174
|
-
const headerProps = createHeaderProps(state);
|
|
175
|
-
t.deepEqual(props.answerType.media, {
|
|
176
|
-
_id: '593eb72a187bd18c01283592',
|
|
177
|
-
mimeType: 'image/jpeg',
|
|
178
|
-
type: 'img',
|
|
179
|
-
url: '//static.coorpacademy.com/content/ijoinchanel/en/slides/1B2_Q6/1B2-Q6-canap-v1.jpg'
|
|
180
|
-
});
|
|
181
|
-
t.is(props.typeClue, 'answer');
|
|
182
|
-
t.is(props.question, "Écrivez le mot Text dans l'input.\n");
|
|
183
|
-
t.is(props.answerType.model.type, 'freeText');
|
|
184
|
-
t.true(_isFunction(props.answerType.model.onChange));
|
|
185
|
-
t.is(props.slideContext, undefined);
|
|
186
|
-
t.is(props.cta.submitValue, '__Validate');
|
|
187
|
-
t.true(props.cta.disabled);
|
|
188
|
-
t.is(props.buttons.length, 4);
|
|
189
|
-
t.is(props.buttons[3].title, '__Coach');
|
|
190
|
-
t.is(props.buttons[3].type, 'coach');
|
|
191
|
-
t.deepEqual(_omit('content.onClick', props.header), _omit('content.onClick', headerProps));
|
|
192
|
-
t.true(_isFunction(props.header.content.onClick));
|
|
193
|
-
});
|
|
194
|
-
test('should enable the validate button when there is an answer', t => {
|
|
195
|
-
t.true(isDisabledFor(basicSlide, false, []));
|
|
196
|
-
t.false(isDisabledFor(basicSlide, false, ['foo']));
|
|
197
|
-
});
|
|
198
|
-
test('should enable the validate button when there are two answers in an non-adaptive content for all questions', t => {
|
|
199
|
-
const answers = ['foo', 'bar'];
|
|
200
|
-
t.false(isDisabledFor(basicSlide, false, answers));
|
|
201
|
-
t.false(isDisabledFor(qcmSlide, false, answers));
|
|
202
|
-
t.false(isDisabledFor(qcmGraphicSlide, false, answers));
|
|
203
|
-
t.false(isDisabledFor(qcmDragSlide, false, answers));
|
|
204
|
-
t.false(isDisabledFor(contextSlide, false, answers));
|
|
205
|
-
t.false(isDisabledFor(templateSlide, false, answers));
|
|
206
|
-
});
|
|
207
|
-
test('should disable the validate button when there are several answers in an adaptive content for qcm questions', t => {
|
|
208
|
-
t.false(isDisabledFor(basicSlide, true, ['foo', 'bar']));
|
|
209
|
-
t.true(isDisabledFor(qcmSlide, true, ['foo', 'bar']));
|
|
210
|
-
t.true(isDisabledFor(qcmGraphicSlide, true, ['foo', 'bar']));
|
|
211
|
-
t.false(isDisabledFor(qcmDragSlide, true, ['foo', 'bar']));
|
|
212
|
-
t.false(isDisabledFor(contextSlide, true, ['foo', 'bar']));
|
|
213
|
-
t.false(isDisabledFor(templateSlide, true, ['foo', 'bar']));
|
|
214
|
-
t.false(isDisabledFor(basicSlide, true, ['foo', 'bar', 'baz']));
|
|
215
|
-
t.true(isDisabledFor(qcmSlide, true, ['foo', 'bar', 'baz']));
|
|
216
|
-
t.true(isDisabledFor(qcmGraphicSlide, true, ['foo', 'bar', 'baz']));
|
|
217
|
-
t.false(isDisabledFor(qcmDragSlide, true, ['foo', 'bar', 'baz']));
|
|
218
|
-
t.false(isDisabledFor(contextSlide, true, ['foo', 'bar', 'baz']));
|
|
219
|
-
t.false(isDisabledFor(templateSlide, true, ['foo', 'bar', 'baz']));
|
|
220
|
-
});
|
|
221
|
-
test('should disable the validate button when there the text answer has been deleted', t => {
|
|
222
|
-
const state = {
|
|
223
|
-
data,
|
|
224
|
-
ui: {
|
|
225
|
-
route: {
|
|
226
|
-
basic: 'answer'
|
|
227
|
-
},
|
|
228
|
-
current: {
|
|
229
|
-
progressionId: 'basic'
|
|
230
|
-
},
|
|
231
|
-
answers: {
|
|
232
|
-
basic: {
|
|
233
|
-
value: ['']
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
const props = createPlayerProps(state);
|
|
239
|
-
t.true(props.cta.disabled);
|
|
240
|
-
});
|
|
241
|
-
test('should return defaut props when slide.question.type is not handles', t => {
|
|
242
|
-
const state = {
|
|
243
|
-
data,
|
|
244
|
-
ui: {
|
|
245
|
-
route: {
|
|
246
|
-
basic: 'answer'
|
|
247
|
-
},
|
|
248
|
-
current: {
|
|
249
|
-
progressionId: 'plop'
|
|
250
|
-
},
|
|
251
|
-
answers: {
|
|
252
|
-
basic: {
|
|
253
|
-
value: ['']
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
t.throws(() => createPlayerProps(state), {
|
|
259
|
-
message: 'plop is not an handled question.type'
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
test('should disable the validate button when no answer is provided', t => {
|
|
263
|
-
const state = {
|
|
264
|
-
data,
|
|
265
|
-
ui: {
|
|
266
|
-
route: {
|
|
267
|
-
basic: 'answer'
|
|
268
|
-
},
|
|
269
|
-
current: {
|
|
270
|
-
progressionId: 'basic'
|
|
271
|
-
},
|
|
272
|
-
answers: {}
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
const props = createPlayerProps(state);
|
|
276
|
-
t.true(props.cta.disabled);
|
|
277
|
-
});
|
|
278
|
-
test('should disable the validate button when a previous selected answer has been unselected', t => {
|
|
279
|
-
const state = {
|
|
280
|
-
data,
|
|
281
|
-
ui: {
|
|
282
|
-
route: {
|
|
283
|
-
basic: 'answer'
|
|
284
|
-
},
|
|
285
|
-
current: {
|
|
286
|
-
progressionId: 'basic'
|
|
287
|
-
},
|
|
288
|
-
answers: {
|
|
289
|
-
basic: {
|
|
290
|
-
value: []
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
const props = createPlayerProps(state);
|
|
296
|
-
t.true(props.cta.disabled);
|
|
297
|
-
});
|
|
298
|
-
test('should disable the validate button when some answer fields are empty', t => {
|
|
299
|
-
const state = {
|
|
300
|
-
data,
|
|
301
|
-
ui: {
|
|
302
|
-
route: {
|
|
303
|
-
template: 'answer'
|
|
304
|
-
},
|
|
305
|
-
current: {
|
|
306
|
-
progressionId: 'template'
|
|
307
|
-
},
|
|
308
|
-
answers: {
|
|
309
|
-
template: {
|
|
310
|
-
value: ['', 'Test']
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
const props = createPlayerProps(state);
|
|
316
|
-
t.true(props.cta.disabled);
|
|
317
|
-
});
|
|
318
|
-
test('should disable the validate button when no answer has been selected by user on template question', t => {
|
|
319
|
-
const state = {
|
|
320
|
-
data,
|
|
321
|
-
ui: {
|
|
322
|
-
route: {
|
|
323
|
-
template: 'answer'
|
|
324
|
-
},
|
|
325
|
-
current: {
|
|
326
|
-
progressionId: 'template'
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
const props = createPlayerProps(state);
|
|
331
|
-
t.true(props.cta.disabled);
|
|
332
|
-
});
|
|
333
|
-
test('should display context tab button if slide context is available', t => {
|
|
334
|
-
t.plan(10);
|
|
335
|
-
const state = {
|
|
336
|
-
data,
|
|
337
|
-
ui: {
|
|
338
|
-
route: {
|
|
339
|
-
context: 'answer'
|
|
340
|
-
},
|
|
341
|
-
current: {
|
|
342
|
-
progressionId: 'context'
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
const dispatch = action => {
|
|
348
|
-
t.deepEqual(action, {
|
|
349
|
-
type: UI_SELECT_ROUTE,
|
|
350
|
-
payload: 'context',
|
|
351
|
-
meta: {
|
|
352
|
-
progressionId: 'context'
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
const props = createPlayer(options, {
|
|
358
|
-
dispatch: action => action(dispatch, () => state)
|
|
359
|
-
})(state);
|
|
360
|
-
t.is(typeof props.slideContext, 'object');
|
|
361
|
-
t.is(props.slideContext.title, 'Some context title');
|
|
362
|
-
t.is(typeof props.slideContext.description, 'string');
|
|
363
|
-
t.is(props.slideContext.description, contextSlide.context.description);
|
|
364
|
-
t.is(props.buttons.length, 5);
|
|
365
|
-
t.is(props.buttons[0].title, '__Context');
|
|
366
|
-
t.is(props.buttons[0].type, 'context');
|
|
367
|
-
t.false(props.buttons[0].selected);
|
|
368
|
-
t.is(typeof props.buttons[0].onClick, 'function');
|
|
369
|
-
props.buttons[0].onClick();
|
|
370
|
-
});
|
|
371
|
-
test('should display "Back to question" for the cta in the tabs', t => {
|
|
372
|
-
const state = {
|
|
373
|
-
data,
|
|
374
|
-
ui: {
|
|
375
|
-
current: {
|
|
376
|
-
progressionId: 'basic'
|
|
377
|
-
},
|
|
378
|
-
route: {
|
|
379
|
-
basic: 'media'
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
const props = createPlayerProps(state);
|
|
384
|
-
t.is(props.cta.submitValue, '__Back to question');
|
|
385
|
-
state.ui.route.foo = 'clue';
|
|
386
|
-
t.is(typeof props.onClickSeeClue, 'function');
|
|
387
|
-
props.onClickSeeClue();
|
|
388
|
-
t.is(props.cta.submitValue, '__Back to question');
|
|
389
|
-
});
|
|
390
|
-
test('should display "Go to question" for the context tab cta', t => {
|
|
391
|
-
const state = {
|
|
392
|
-
data,
|
|
393
|
-
ui: {
|
|
394
|
-
current: {
|
|
395
|
-
progressionId: 'basic'
|
|
396
|
-
},
|
|
397
|
-
route: {
|
|
398
|
-
basic: 'context'
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
const props = createPlayerProps(state);
|
|
403
|
-
t.is(props.cta.submitValue, '__Go to question');
|
|
404
|
-
});
|
|
405
|
-
test('should display new media notification when user has not seen any media for the current slide', t => {
|
|
406
|
-
const progression = createProgression(basicSlide);
|
|
407
|
-
progression.state.viewedResources = [{
|
|
408
|
-
resources: ['1234']
|
|
409
|
-
}];
|
|
410
|
-
const state = {
|
|
411
|
-
data: {
|
|
412
|
-
contents: data.contents,
|
|
413
|
-
progressions: {
|
|
414
|
-
entities: {
|
|
415
|
-
basic: progression
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
},
|
|
419
|
-
ui: {
|
|
420
|
-
current: {
|
|
421
|
-
progressionId: 'basic'
|
|
422
|
-
},
|
|
423
|
-
route: {
|
|
424
|
-
basic: 'answer'
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
const props = createPlayerProps(state);
|
|
429
|
-
t.true(props.showNewMedia);
|
|
430
|
-
});
|
|
431
|
-
test('should display new media notification for the answer/undefined route when user has not seen any media', t => {
|
|
432
|
-
const state = {
|
|
433
|
-
data: {
|
|
434
|
-
contents: data.contents,
|
|
435
|
-
progressions: {
|
|
436
|
-
entities: {
|
|
437
|
-
basic: createProgression(basicSlide)
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
},
|
|
441
|
-
ui: {
|
|
442
|
-
current: {
|
|
443
|
-
progressionId: 'basic'
|
|
444
|
-
},
|
|
445
|
-
route: {}
|
|
446
|
-
}
|
|
447
|
-
};
|
|
448
|
-
[undefined].forEach(route => {
|
|
449
|
-
const props = createPlayerProps(_set('ui.route.basic', route, state));
|
|
450
|
-
t.true(_isEmpty(props));
|
|
451
|
-
});
|
|
452
|
-
['media', 'clue', 'context', 'answer'].forEach(route => {
|
|
453
|
-
const props = createPlayerProps(_set('ui.route.basic', route, state));
|
|
454
|
-
t.false(_isEmpty(props));
|
|
455
|
-
});
|
|
456
|
-
});
|
|
457
|
-
test('should not display new media notification for the other routes when user has not seen any media', t => {
|
|
458
|
-
const state = {
|
|
459
|
-
data: {
|
|
460
|
-
contents: data.contents,
|
|
461
|
-
progressions: {
|
|
462
|
-
entities: {
|
|
463
|
-
basic: createProgression(basicSlide)
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
},
|
|
467
|
-
ui: {
|
|
468
|
-
current: {
|
|
469
|
-
progressionId: 'basic'
|
|
470
|
-
},
|
|
471
|
-
route: {}
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
['media', 'clue'].forEach(route => {
|
|
475
|
-
const props = createPlayerProps(_set('ui.route.basic', route, state));
|
|
476
|
-
t.false(props.showNewMedia);
|
|
477
|
-
});
|
|
478
|
-
});
|
|
479
|
-
test('should not display new media notification when user has seen at least one media of the current slide', t => {
|
|
480
|
-
const progression = createProgression(basicSlide);
|
|
481
|
-
progression.state.viewedResources = [{
|
|
482
|
-
type: 'chapter',
|
|
483
|
-
ref: basicSlide.chapter_id,
|
|
484
|
-
resources: [basicSlide.lessons[0].ref]
|
|
485
|
-
}];
|
|
486
|
-
const state = {
|
|
487
|
-
data: {
|
|
488
|
-
contents: data.contents,
|
|
489
|
-
progressions: {
|
|
490
|
-
entities: {
|
|
491
|
-
basic: progression
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
},
|
|
495
|
-
ui: {
|
|
496
|
-
current: {
|
|
497
|
-
progressionId: 'basic'
|
|
498
|
-
},
|
|
499
|
-
route: {
|
|
500
|
-
basic: 'answer'
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
const props = createPlayerProps(state);
|
|
505
|
-
t.false(props.showNewMedia);
|
|
506
|
-
});
|
|
507
|
-
test('should display review lesson notification when user has seen at least one media of the current slide', t => {
|
|
508
|
-
const progression = createProgression(basicSlide);
|
|
509
|
-
progression.state.viewedResources = [{
|
|
510
|
-
type: 'chapter',
|
|
511
|
-
ref: basicSlide.chapter_id,
|
|
512
|
-
resources: [basicSlide.lessons[0].ref]
|
|
513
|
-
}];
|
|
514
|
-
const state = {
|
|
515
|
-
data: {
|
|
516
|
-
contents: data.contents,
|
|
517
|
-
progressions: {
|
|
518
|
-
entities: {
|
|
519
|
-
basic: progression
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
},
|
|
523
|
-
ui: {
|
|
524
|
-
current: {
|
|
525
|
-
progressionId: 'basic'
|
|
526
|
-
},
|
|
527
|
-
route: {
|
|
528
|
-
basic: 'answer'
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
const props = createPlayerProps(state);
|
|
533
|
-
t.true(props.showReviewLesson);
|
|
534
|
-
});
|
|
535
|
-
test('should not display review lesson notification when user has not seen any media for the current slide', t => {
|
|
536
|
-
const progression = createProgression(basicSlide);
|
|
537
|
-
progression.state.viewedResources = [{
|
|
538
|
-
type: 'chapter',
|
|
539
|
-
ref: basicSlide.chapter_id,
|
|
540
|
-
resources: []
|
|
541
|
-
}];
|
|
542
|
-
const state = {
|
|
543
|
-
data: {
|
|
544
|
-
contents: data.contents,
|
|
545
|
-
progressions: {
|
|
546
|
-
entities: {
|
|
547
|
-
basic: progression
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
},
|
|
551
|
-
ui: {
|
|
552
|
-
current: {
|
|
553
|
-
progressionId: 'basic'
|
|
554
|
-
},
|
|
555
|
-
route: {
|
|
556
|
-
basic: 'answer'
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
};
|
|
560
|
-
const props = createPlayerProps(state);
|
|
561
|
-
t.false(props.showReviewLesson);
|
|
562
|
-
});
|
|
563
|
-
test('should feed step prop in non-adaptive mode', t => {
|
|
564
|
-
const state = _set('data.contents.level.entities.1.info.nbSlides', 12, learnerProgressionStateFixture);
|
|
565
|
-
|
|
566
|
-
const props = createPlayerProps(state);
|
|
567
|
-
t.deepEqual(props.step, {
|
|
568
|
-
current: 0,
|
|
569
|
-
total: 12
|
|
570
|
-
});
|
|
571
|
-
});
|
|
572
|
-
test('should not feed step prop in adaptive mode', t => {
|
|
573
|
-
const state = _pipe(_set('data.contents.level.entities.1.info.nbSlides', 12), _set('data.contents.chapter.entities.chapter2.isConditional', true))(learnerProgressionStateFixture);
|
|
574
|
-
|
|
575
|
-
const props = createPlayerProps(state);
|
|
576
|
-
t.falsy(props.step);
|
|
577
|
-
});
|
|
578
|
-
test('should not send an id prop in resources', t => {
|
|
579
|
-
const props = createPlayerProps(learnerProgressionStateFixture);
|
|
580
|
-
t.is(_get('resources.0.id', props), undefined);
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
const createLearnerProgression = (slide, contentRef) => ({
|
|
584
|
-
engine: {
|
|
585
|
-
ref: 'learner',
|
|
586
|
-
version: '1'
|
|
587
|
-
},
|
|
588
|
-
content: {
|
|
589
|
-
ref: contentRef,
|
|
590
|
-
type: 'level'
|
|
591
|
-
},
|
|
592
|
-
state: {
|
|
593
|
-
nextContent: {
|
|
594
|
-
ref: slide._id,
|
|
595
|
-
type: 'slide'
|
|
596
|
-
},
|
|
597
|
-
lives: 1,
|
|
598
|
-
livesDisabled: false,
|
|
599
|
-
step: {
|
|
600
|
-
current: 1
|
|
601
|
-
},
|
|
602
|
-
viewedResources: []
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
|
|
606
|
-
const check = (slide, answer) => {
|
|
607
|
-
const progressionId = 'progression';
|
|
608
|
-
const levelId = 'level';
|
|
609
|
-
const chapterId = 'chapter';
|
|
610
|
-
return createPlayerProps({
|
|
611
|
-
data: {
|
|
612
|
-
contents: {
|
|
613
|
-
slide: {
|
|
614
|
-
entities: {
|
|
615
|
-
[slide._id]: _extends({}, slide, {
|
|
616
|
-
chapter_id: chapterId
|
|
617
|
-
})
|
|
618
|
-
}
|
|
619
|
-
},
|
|
620
|
-
level: {
|
|
621
|
-
entities: {
|
|
622
|
-
[levelId]: {
|
|
623
|
-
ref: levelId,
|
|
624
|
-
chapterIds: [chapterId],
|
|
625
|
-
isConditional: true
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
},
|
|
629
|
-
chapter: {
|
|
630
|
-
entities: {
|
|
631
|
-
[chapterId]: {
|
|
632
|
-
_id: chapterId,
|
|
633
|
-
isConditional: false
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
},
|
|
638
|
-
progressions: {
|
|
639
|
-
entities: {
|
|
640
|
-
[progressionId]: createLearnerProgression(slide, levelId)
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
},
|
|
644
|
-
ui: {
|
|
645
|
-
route: {
|
|
646
|
-
[progressionId]: 'answer'
|
|
647
|
-
},
|
|
648
|
-
current: {
|
|
649
|
-
progressionId
|
|
650
|
-
},
|
|
651
|
-
answers: {
|
|
652
|
-
[progressionId]: {
|
|
653
|
-
value: answer
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
}).cta.disabled;
|
|
658
|
-
};
|
|
659
|
-
|
|
660
|
-
test('should allow multi answers on adaptive level if the current chapter is not adaptive', t => {
|
|
661
|
-
t.true(check(basicSlide, []));
|
|
662
|
-
t.true(check(qcmSlide, []));
|
|
663
|
-
t.true(check(qcmGraphicSlide, []));
|
|
664
|
-
t.true(check(qcmDragSlide, []));
|
|
665
|
-
t.true(check(contextSlide, []));
|
|
666
|
-
t.true(check(templateSlide, []));
|
|
667
|
-
t.false(check(basicSlide, ['foo']));
|
|
668
|
-
t.false(check(qcmSlide, ['foo']));
|
|
669
|
-
t.false(check(qcmGraphicSlide, ['foo']));
|
|
670
|
-
t.false(check(qcmDragSlide, ['foo']));
|
|
671
|
-
t.false(check(contextSlide, ['foo']));
|
|
672
|
-
t.false(check(templateSlide, ['foo']));
|
|
673
|
-
t.false(check(basicSlide, ['foo', 'bar']));
|
|
674
|
-
t.false(check(qcmSlide, ['foo', 'bar']));
|
|
675
|
-
t.false(check(qcmGraphicSlide, ['foo', 'bar']));
|
|
676
|
-
t.false(check(qcmDragSlide, ['foo', 'bar']));
|
|
677
|
-
t.false(check(contextSlide, ['foo', 'bar']));
|
|
678
|
-
t.false(check(templateSlide, ['foo', 'bar']));
|
|
679
|
-
});
|
|
680
|
-
//# sourceMappingURL=player.js.map
|