@coorpacademy/player-web 4.29.18 → 4.29.20
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/index.js +3 -0
- package/es/index.js.map +1 -1
- package/es/map-state-to-props/header.js +23 -3
- package/es/map-state-to-props/header.js.map +1 -1
- package/es/map-state-to-props/slide.js +149 -7
- package/es/map-state-to-props/slide.js.map +1 -1
- package/es/map-state-to-props/test/header.js +160 -1
- package/es/map-state-to-props/test/header.js.map +1 -1
- package/es/map-state-to-props/test/popin-error.js +12 -8
- package/es/map-state-to-props/test/popin-error.js.map +1 -1
- package/es/map-state-to-props/test/slide.js +224 -0
- package/es/map-state-to-props/test/slide.js.map +1 -0
- package/es/map-state-to-props/test/tourguide-sync.js +243 -0
- package/es/map-state-to-props/test/tourguide-sync.js.map +1 -0
- package/es/store.js +3 -2
- package/es/store.js.map +1 -1
- package/es/test/init-reducers.js +10 -1
- package/es/test/init-reducers.js.map +1 -1
- package/es/test/store.js +3 -5
- package/es/test/store.js.map +1 -1
- package/es/tourguide-sync.js +24 -0
- package/es/tourguide-sync.js.map +1 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/map-state-to-props/header.js +22 -2
- package/lib/map-state-to-props/header.js.map +1 -1
- package/lib/map-state-to-props/slide.js +149 -7
- package/lib/map-state-to-props/slide.js.map +1 -1
- package/lib/map-state-to-props/test/header.js +160 -1
- package/lib/map-state-to-props/test/header.js.map +1 -1
- package/lib/map-state-to-props/test/popin-error.js +12 -8
- package/lib/map-state-to-props/test/popin-error.js.map +1 -1
- package/lib/map-state-to-props/test/slide.js +227 -0
- package/lib/map-state-to-props/test/slide.js.map +1 -0
- package/lib/map-state-to-props/test/tourguide-sync.js +246 -0
- package/lib/map-state-to-props/test/tourguide-sync.js.map +1 -0
- package/lib/store.js +3 -2
- package/lib/store.js.map +1 -1
- package/lib/test/init-reducers.js +10 -1
- package/lib/test/init-reducers.js.map +1 -1
- package/lib/test/store.js +3 -5
- package/lib/test/store.js.map +1 -1
- package/lib/tourguide-sync.js +29 -0
- package/lib/tourguide-sync.js.map +1 -0
- package/locales/bs/player.json +19 -1
- package/locales/cs/player.json +19 -1
- package/locales/de/player.json +19 -1
- package/locales/en/player.json +19 -1
- package/locales/es/player.json +19 -1
- package/locales/et/player.json +19 -1
- package/locales/fi/player.json +19 -1
- package/locales/fr/player.json +19 -1
- package/locales/hr/player.json +19 -1
- package/locales/hu/player.json +19 -1
- package/locales/hy/player.json +19 -1
- package/locales/it/player.json +19 -1
- package/locales/ja/player.json +19 -1
- package/locales/ko/player.json +19 -1
- package/locales/lt/player.json +19 -1
- package/locales/nl/player.json +19 -1
- package/locales/pl/player.json +19 -1
- package/locales/pt/player.json +19 -1
- package/locales/ro/player.json +19 -1
- package/locales/ru/player.json +19 -1
- package/locales/sk/player.json +19 -1
- package/locales/sl/player.json +19 -1
- package/locales/sv/player.json +19 -1
- package/locales/tl/player.json +19 -1
- package/locales/tr/player.json +19 -1
- package/locales/uk/player.json +19 -1
- package/locales/vi/player.json +19 -1
- package/locales/zh/player.json +19 -1
- package/locales/zh_TW/player.json +19 -1
- package/package.json +4 -4
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_reactDom","require","_react","_components","_playerStore","_runApp","_interopRequireDefault","_store","_mapStateToProps","_views","e","__esModule","default","createUpdate","container","store","options","_selectMapStateToVNode","getState","mapStateToVNode","views","createStateToVNode","mapStateToView","_pipe2","vNode","createElement","Provider","state","view","render","create","createStore","update","selectMapStateToVNode","unsubscribe","subscribe","module","hot","accept","runApp","dispatch","updateCoaches","coachState","selectProgression","id","unmountComponentAtNode","exports"],"sources":["../src/index.js"],"sourcesContent":["import {render, unmountComponentAtNode} from 'react-dom';\nimport {createElement} from 'react';\nimport {pipe} from 'lodash/fp';\nimport {Provider} from '@coorpacademy/components';\nimport {selectProgression, updateCoaches} from '@coorpacademy/player-store';\nimport runApp from './run-app';\nimport createStore from './store';\nimport {selectMapStateToVNode} from './map-state-to-props';\nimport {createStateToVNode, views} from './views';\n\nconst createUpdate = (container, store, options) => _selectMapStateToVNode => {\n const {getState} = store;\n const mapStateToVNode = _selectMapStateToVNode(options, store, views, createStateToVNode);\n const mapStateToView = pipe(mapStateToVNode, vNode => createElement(Provider, options, vNode));\n\n return () => {\n const state = getState();\n const view = mapStateToView(state);\n return render(view, container);\n };\n};\n\nconst create = options => {\n const {container} = options;\n const store = createStore(options);\n\n let update = createUpdate(container, store, options)(selectMapStateToVNode);\n let unsubscribe = store.subscribe(update);\n\n /* istanbul ignore if */\n if (module.hot) {\n module.hot.accept('./views', () => {\n unsubscribe();\n update = createUpdate(container, store, options)(require('./views').default);\n update();\n unsubscribe = store.subscribe(update);\n });\n }\n\n runApp(options, store);\n\n const {dispatch} = store;\n return {\n update: () => update(),\n\n updateCoaches: coachState => dispatch(updateCoaches(coachState)),\n selectProgression: id => dispatch(selectProgression(id)),\n\n unsubscribe: () => {\n unmountComponentAtNode(container);\n return unsubscribe();\n }\n };\n};\n\nexport {create};\n"],"mappings":";;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,MAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","names":["_reactDom","require","_react","_components","_playerStore","_runApp","_interopRequireDefault","_store","_mapStateToProps","_views","_tourguideSync","e","__esModule","default","createUpdate","container","store","options","_selectMapStateToVNode","getState","mapStateToVNode","views","createStateToVNode","mapStateToView","_pipe2","vNode","createElement","Provider","state","view","render","create","createStore","unsubscribeTourguideSync","createTourguideSync","update","selectMapStateToVNode","unsubscribe","subscribe","module","hot","accept","runApp","dispatch","updateCoaches","coachState","selectProgression","id","unmountComponentAtNode","exports"],"sources":["../src/index.js"],"sourcesContent":["import {render, unmountComponentAtNode} from 'react-dom';\nimport {createElement} from 'react';\nimport {pipe} from 'lodash/fp';\nimport {Provider} from '@coorpacademy/components';\nimport {selectProgression, updateCoaches} from '@coorpacademy/player-store';\nimport runApp from './run-app';\nimport createStore from './store';\nimport {selectMapStateToVNode} from './map-state-to-props';\nimport {createStateToVNode, views} from './views';\nimport createTourguideSync from './tourguide-sync';\n\nconst createUpdate = (container, store, options) => _selectMapStateToVNode => {\n const {getState} = store;\n const mapStateToVNode = _selectMapStateToVNode(options, store, views, createStateToVNode);\n const mapStateToView = pipe(mapStateToVNode, vNode => createElement(Provider, options, vNode));\n\n return () => {\n const state = getState();\n const view = mapStateToView(state);\n return render(view, container);\n };\n};\n\nconst create = options => {\n const {container} = options;\n const store = createStore(options);\n const unsubscribeTourguideSync = createTourguideSync(options, store);\n\n let update = createUpdate(container, store, options)(selectMapStateToVNode);\n let unsubscribe = store.subscribe(update);\n\n /* istanbul ignore if */\n if (module.hot) {\n module.hot.accept('./views', () => {\n unsubscribe();\n update = createUpdate(container, store, options)(require('./views').default);\n update();\n unsubscribe = store.subscribe(update);\n });\n }\n\n runApp(options, store);\n\n const {dispatch} = store;\n return {\n update: () => update(),\n\n updateCoaches: coachState => dispatch(updateCoaches(coachState)),\n selectProgression: id => dispatch(selectProgression(id)),\n\n unsubscribe: () => {\n unmountComponentAtNode(container);\n unsubscribeTourguideSync();\n return unsubscribe();\n }\n };\n};\n\nexport {create};\n"],"mappings":";;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,MAAA,GAAAD,sBAAA,CAAAL,O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,MAAM,CAACC,GAAG,CAACC,MAAM,CAAC,SAAS,EAAE,MAAM;MACjCJ,WAAW,CAAC,CAAC;MACbF,MAAM,GAAGrB,YAAY,CAACC,SAAS,EAAEC,KAAK,EAAEC,OAAO,CAAC,CAAChB,OAAO,CAAC,SAAS,CAAC,CAACY,OAAO,CAAC;MAC5EsB,MAAM,CAAC,CAAC;MACRE,WAAW,GAAGrB,KAAK,CAACsB,SAAS,CAACH,MAAM,CAAC;IACvC,CAAC,CAAC;EACJ;EAEA,IAAAO,eAAM,EAACzB,OAAO,EAAED,KAAK,CAAC;EAEtB,MAAM;IAAC2B;EAAQ,CAAC,GAAG3B,KAAK;EACxB,OAAO;IACLmB,MAAM,EAAEA,CAAA,KAAMA,MAAM,CAAC,CAAC;IAEtBS,aAAa,EAAEC,UAAU,IAAIF,QAAQ,CAAC,IAAAC,0BAAa,EAACC,UAAU,CAAC,CAAC;IAChEC,iBAAiB,EAAEC,EAAE,IAAIJ,QAAQ,CAAC,IAAAG,8BAAiB,EAACC,EAAE,CAAC,CAAC;IAExDV,WAAW,EAAEA,CAAA,KAAM;MACjB,IAAAW,gCAAsB,EAACjC,SAAS,CAAC;MACjCkB,wBAAwB,CAAC,CAAC;MAC1B,OAAOI,WAAW,CAAC,CAAC;IACtB;EACF,CAAC;AACH,CAAC;AAACY,OAAA,CAAAlB,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
5
|
var _indexOf2 = _interopRequireDefault(require("lodash/fp/indexOf"));
|
|
6
|
+
var _identity2 = _interopRequireDefault(require("lodash/fp/identity"));
|
|
6
7
|
var _getOr2 = _interopRequireDefault(require("lodash/fp/getOr"));
|
|
7
8
|
var _get2 = _interopRequireDefault(require("lodash/fp/get"));
|
|
8
9
|
var _playerStore = require("@coorpacademy/player-store");
|
|
@@ -40,6 +41,24 @@ const headerSubcontent = (engineRef, state) => {
|
|
|
40
41
|
return null;
|
|
41
42
|
}
|
|
42
43
|
};
|
|
44
|
+
const buildHelpProps = (state, options, dispatch) => {
|
|
45
|
+
const isQuestionTab = (0, _playerStore.getRoute)(state) === 'answer';
|
|
46
|
+
const translate = (0, _getOr2.default)(_identity2.default, 'translate', options);
|
|
47
|
+
const canShowHelp = (0, _playerStore.isTourguideEligible)(state, options);
|
|
48
|
+
if (!canShowHelp) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
onClick: () => {
|
|
53
|
+
if (!isQuestionTab) {
|
|
54
|
+
dispatch((0, _playerStore.selectRoute)('answer'));
|
|
55
|
+
}
|
|
56
|
+
dispatch((0, _playerStore.showTourguide)(undefined, true));
|
|
57
|
+
},
|
|
58
|
+
ariaLabel: translate('Help'),
|
|
59
|
+
title: translate('Help')
|
|
60
|
+
};
|
|
61
|
+
};
|
|
43
62
|
const headerProps = (options, {
|
|
44
63
|
dispatch
|
|
45
64
|
}) => state => {
|
|
@@ -61,8 +80,9 @@ const headerProps = (options, {
|
|
|
61
80
|
lives: hide ? false : {
|
|
62
81
|
count
|
|
63
82
|
},
|
|
64
|
-
mode:
|
|
65
|
-
multiLang:
|
|
83
|
+
mode: (0, _getOr2.default)('default', 'mode', options),
|
|
84
|
+
multiLang: (0, _get2.default)('multiLang', options),
|
|
85
|
+
help: buildHelpProps(state, options, dispatch)
|
|
66
86
|
};
|
|
67
87
|
};
|
|
68
88
|
var _default = exports.default = headerProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header.js","names":["_playerStore","require","_interopRequireDefault","e","__esModule","default","headerContent","engineRef","state","content","getCurrentContent","title","_getOr2","details","_get2","headerSubcontent","chapter","getCurrentChapter","level","chapterIds","_indexOf2","_id","length","
|
|
1
|
+
{"version":3,"file":"header.js","names":["_playerStore","require","_interopRequireDefault","e","__esModule","default","headerContent","engineRef","state","content","getCurrentContent","title","_getOr2","details","_get2","headerSubcontent","chapter","getCurrentChapter","level","chapterIds","_indexOf2","_id","length","buildHelpProps","options","dispatch","isQuestionTab","getRoute","translate","_identity2","canShowHelp","isTourguideEligible","onClick","selectRoute","showTourguide","undefined","ariaLabel","headerProps","engine","getEngine","ref","hide","count","getLives","type","back","subcontent","lives","mode","multiLang","help","_default","exports"],"sources":["../../src/map-state-to-props/header.js"],"sourcesContent":["import {get, getOr, identity, indexOf} from 'lodash/fp';\nimport {\n getCurrentChapter,\n getEngine,\n getLives,\n getCurrentContent,\n getRoute,\n selectRoute,\n back,\n showTourguide,\n isTourguideEligible\n} from '@coorpacademy/player-store';\n\nconst headerContent = (engineRef, state) => {\n const content = getCurrentContent(state);\n\n switch (engineRef) {\n case 'learner':\n return {\n title: getOr('', 'name')(content),\n details: get('levelTranslation')(content)\n };\n case 'microlearning':\n default:\n return {\n title: getOr('', 'name')(content)\n };\n }\n};\n\nconst headerSubcontent = (engineRef, state) => {\n switch (engineRef) {\n case 'learner': {\n const chapter = getCurrentChapter(state);\n const level = getCurrentContent(state);\n const chapterIds = get('chapterIds', level);\n const details =\n chapter && chapterIds\n ? `${1 + indexOf(chapter._id, chapterIds)}/${chapterIds.length}`\n : null;\n\n return {\n title: getOr('', 'name', chapter),\n details\n };\n }\n case 'microlearning':\n default:\n return null;\n }\n};\n\nconst buildHelpProps = (state, options, dispatch) => {\n const isQuestionTab = getRoute(state) === 'answer';\n const translate = getOr(identity, 'translate', options);\n const canShowHelp = isTourguideEligible(state, options);\n if (!canShowHelp) {\n return null;\n }\n return {\n onClick: () => {\n if (!isQuestionTab) {\n dispatch(selectRoute('answer'));\n }\n dispatch(showTourguide(undefined, true));\n },\n ariaLabel: translate('Help'),\n title: translate('Help')\n };\n};\n\nconst headerProps =\n (options, {dispatch}) =>\n state => {\n const engine = getEngine(state);\n const {ref: engineRef} = engine;\n const {hide, count} = getLives(state);\n\n return {\n type: engineRef,\n content: {\n ...headerContent(engineRef, state),\n onClick: () => dispatch(back)\n },\n subcontent: headerSubcontent(engineRef, state),\n lives: hide ? false : {count},\n mode: getOr('default', 'mode', options),\n multiLang: get('multiLang', options),\n help: buildHelpProps(state, options, dispatch)\n };\n };\n\nexport default headerProps;\n"],"mappings":";;;;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAUoC,SAAAC,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEpC,MAAMG,aAAa,GAAGA,CAACC,SAAS,EAAEC,KAAK,KAAK;EAC1C,MAAMC,OAAO,GAAG,IAAAC,8BAAiB,EAACF,KAAK,CAAC;EAExC,QAAQD,SAAS;IACf,KAAK,SAAS;MACZ,OAAO;QACLI,KAAK,EAAE,IAAAC,OAAA,CAAAP,OAAA,EAAM,EAAE,EAAE,MAAM,CAAC,CAACI,OAAO,CAAC;QACjCI,OAAO,EAAE,IAAAC,KAAA,CAAAT,OAAA,EAAI,kBAAkB,CAAC,CAACI,OAAO;MAC1C,CAAC;IACH,KAAK,eAAe;IACpB;MACE,OAAO;QACLE,KAAK,EAAE,IAAAC,OAAA,CAAAP,OAAA,EAAM,EAAE,EAAE,MAAM,CAAC,CAACI,OAAO;MAClC,CAAC;EACL;AACF,CAAC;AAED,MAAMM,gBAAgB,GAAGA,CAACR,SAAS,EAAEC,KAAK,KAAK;EAC7C,QAAQD,SAAS;IACf,KAAK,SAAS;MAAE;QACd,MAAMS,OAAO,GAAG,IAAAC,8BAAiB,EAACT,KAAK,CAAC;QACxC,MAAMU,KAAK,GAAG,IAAAR,8BAAiB,EAACF,KAAK,CAAC;QACtC,MAAMW,UAAU,GAAG,IAAAL,KAAA,CAAAT,OAAA,EAAI,YAAY,EAAEa,KAAK,CAAC;QAC3C,MAAML,OAAO,GACXG,OAAO,IAAIG,UAAU,GACjB,GAAG,CAAC,GAAG,IAAAC,SAAA,CAAAf,OAAA,EAAQW,OAAO,CAACK,GAAG,EAAEF,UAAU,CAAC,IAAIA,UAAU,CAACG,MA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,EAAErC,SAAS;IACfE,OAAO,EAAE;MACP,GAAGH,aAAa,CAACC,SAAS,EAAEC,KAAK,CAAC;MAClCwB,OAAO,EAAEA,CAAA,KAAMP,QAAQ,CAACoB,iBAAI;IAC9B,CAAC;IACDC,UAAU,EAAE/B,gBAAgB,CAACR,SAAS,EAAEC,KAAK,CAAC;IAC9CuC,KAAK,EAAEN,IAAI,GAAG,KAAK,GAAG;MAACC;IAAK,CAAC;IAC7BM,IAAI,EAAE,IAAApC,OAAA,CAAAP,OAAA,EAAM,SAAS,EAAE,MAAM,EAAEmB,OAAO,CAAC;IACvCyB,SAAS,EAAE,IAAAnC,KAAA,CAAAT,OAAA,EAAI,WAAW,EAAEmB,OAAO,CAAC;IACpC0B,IAAI,EAAE3B,cAAc,CAACf,KAAK,EAAEgB,OAAO,EAAEC,QAAQ;EAC/C,CAAC;AACH,CAAC;AAAC,IAAA0B,QAAA,GAAAC,OAAA,CAAA/C,OAAA,GAEWgC,WAAW","ignoreList":[]}
|
|
@@ -2,17 +2,159 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
|
+
var _size2 = _interopRequireDefault(require("lodash/fp/size"));
|
|
5
6
|
var _pipe2 = _interopRequireDefault(require("lodash/fp/pipe"));
|
|
6
|
-
var
|
|
7
|
-
var
|
|
7
|
+
var _map2 = _interopRequireDefault(require("lodash/fp/map"));
|
|
8
|
+
var _get2 = _interopRequireDefault(require("lodash/fp/get"));
|
|
9
|
+
var _filter2 = _interopRequireDefault(require("lodash/fp/filter"));
|
|
10
|
+
var _cloneDeep2 = _interopRequireDefault(require("lodash/fp/cloneDeep"));
|
|
11
|
+
var _playerStore = require("@coorpacademy/player-store");
|
|
8
12
|
var _player = _interopRequireDefault(require("./player"));
|
|
9
13
|
var _errorPopin = _interopRequireDefault(require("./error-popin"));
|
|
10
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const TOUR_GROUP = 'app-player-question-tour-guide';
|
|
16
|
+
const createTutorialSteps = translate => [{
|
|
17
|
+
ref: 'page',
|
|
18
|
+
target: 'body',
|
|
19
|
+
title: translate('Tourguide step 1 title'),
|
|
20
|
+
content: translate('Tourguide step 1 content'),
|
|
21
|
+
order: 1,
|
|
22
|
+
group: TOUR_GROUP
|
|
23
|
+
}, {
|
|
24
|
+
ref: 'slide',
|
|
25
|
+
target: '[data-name="slide"]',
|
|
26
|
+
title: translate('Tourguide step 2 title'),
|
|
27
|
+
content: translate('Tourguide step 2 content'),
|
|
28
|
+
order: 2,
|
|
29
|
+
group: TOUR_GROUP
|
|
30
|
+
}, {
|
|
31
|
+
ref: 'media',
|
|
32
|
+
target: '[data-type="media"]',
|
|
33
|
+
title: translate('Tourguide step 3 title'),
|
|
34
|
+
content: translate('Tourguide step 3 content'),
|
|
35
|
+
order: 3,
|
|
36
|
+
group: TOUR_GROUP
|
|
37
|
+
}, {
|
|
38
|
+
ref: 'clue',
|
|
39
|
+
target: '[data-type="clue"]',
|
|
40
|
+
title: translate('Tourguide step 4 title'),
|
|
41
|
+
content: translate('Tourguide step 4 content'),
|
|
42
|
+
order: 4,
|
|
43
|
+
group: TOUR_GROUP
|
|
44
|
+
}, {
|
|
45
|
+
ref: 'language',
|
|
46
|
+
target: '[data-name="button-multi-lang"]',
|
|
47
|
+
title: translate('Tourguide step 5 title'),
|
|
48
|
+
content: translate('Tourguide step 5 content'),
|
|
49
|
+
order: 5,
|
|
50
|
+
group: TOUR_GROUP
|
|
51
|
+
}, {
|
|
52
|
+
ref: 'help',
|
|
53
|
+
target: '[data-name="help-button"]',
|
|
54
|
+
title: translate('Tourguide step 6 title'),
|
|
55
|
+
content: translate('Tourguide step 6 content'),
|
|
56
|
+
order: 6,
|
|
57
|
+
group: TOUR_GROUP
|
|
58
|
+
}, {
|
|
59
|
+
ref: 'life',
|
|
60
|
+
target: '[data-name="life"]',
|
|
61
|
+
title: translate('Tourguide step 7 title'),
|
|
62
|
+
content: translate('Tourguide step 7 content'),
|
|
63
|
+
order: 7,
|
|
64
|
+
group: TOUR_GROUP
|
|
65
|
+
}];
|
|
66
|
+
const tourguideStateToProps = (state, options, store) => {
|
|
67
|
+
const {
|
|
68
|
+
translate
|
|
69
|
+
} = options;
|
|
70
|
+
const slide = (0, _playerStore.getCurrentSlide)(state);
|
|
71
|
+
const hasMedia = (0, _pipe2.default)((0, _get2.default)('lessons'), _size2.default)(slide) > 0;
|
|
72
|
+
const hasClue = (0, _pipe2.default)((0, _get2.default)('hasClue'), Boolean)(slide);
|
|
73
|
+
const {
|
|
74
|
+
hide: livesHidden
|
|
75
|
+
} = (0, _playerStore.getLives)(state);
|
|
76
|
+
const tourguideState = (0, _get2.default)('ui.tourguide', state) || {};
|
|
77
|
+
const tourguideVisible = Boolean(tourguideState.visible);
|
|
78
|
+
const tourguideStep = typeof tourguideState.step === 'number' ? tourguideState.step : 0;
|
|
79
|
+
const tourguideForceStart = Boolean(tourguideState.forceStart);
|
|
80
|
+
const canShowHelp = (0, _playerStore.isTourguideEligible)(state, options);
|
|
81
|
+
const multiLangOptions = options.multiLang || {};
|
|
82
|
+
const canShowLang = (0, _pipe2.default)((0, _get2.default)('supportedLangs'), _size2.default)(multiLangOptions) > 1;
|
|
83
|
+
const stepsForTour = (0, _pipe2.default)((0, _filter2.default)(step => {
|
|
84
|
+
if (step.order === 3) {
|
|
85
|
+
return hasMedia;
|
|
86
|
+
}
|
|
87
|
+
if (step.order === 4) {
|
|
88
|
+
return hasClue;
|
|
89
|
+
}
|
|
90
|
+
if (step.order === 5) {
|
|
91
|
+
return canShowLang;
|
|
92
|
+
}
|
|
93
|
+
if (step.order === 6) {
|
|
94
|
+
return canShowHelp;
|
|
95
|
+
}
|
|
96
|
+
if (step.order === 7) {
|
|
97
|
+
return !livesHidden;
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
100
|
+
}), (0, _map2.default)(_cloneDeep2.default))(createTutorialSteps(translate));
|
|
101
|
+
const getStepTracking = stepIndex => {
|
|
102
|
+
const totalSteps = stepsForTour.length;
|
|
103
|
+
const isValidIndex = typeof stepIndex === 'number' && stepIndex >= 0 && stepIndex < totalSteps;
|
|
104
|
+
const stepRef = isValidIndex ? stepsForTour[stepIndex].ref : null;
|
|
105
|
+
return {
|
|
106
|
+
stepRef,
|
|
107
|
+
stepNumber: isValidIndex ? stepIndex + 1 : null,
|
|
108
|
+
totalSteps
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
if (!tourguideVisible) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
steps: stepsForTour,
|
|
116
|
+
group: TOUR_GROUP,
|
|
117
|
+
autoStart: tourguideVisible,
|
|
118
|
+
forceStart: tourguideForceStart,
|
|
119
|
+
startStep: tourguideStep,
|
|
120
|
+
onStart: () => store.dispatch((0, _playerStore.trackTourguideStarted)(TOUR_GROUP, getStepTracking(tourguideStep))),
|
|
121
|
+
onStepChange: step => {
|
|
122
|
+
store.dispatch((0, _playerStore.trackTourguideStepViewed)(TOUR_GROUP, getStepTracking(step)));
|
|
123
|
+
store.dispatch((0, _playerStore.setTourguideStep)(step));
|
|
124
|
+
},
|
|
125
|
+
onExit: () => {
|
|
126
|
+
store.dispatch((0, _playerStore.trackTourguideDismissed)(TOUR_GROUP, getStepTracking(tourguideStep)));
|
|
127
|
+
store.dispatch((0, _playerStore.hideTourguide)());
|
|
128
|
+
},
|
|
129
|
+
onFinish: () => store.dispatch((0, _playerStore.trackTourguideCompleted)(TOUR_GROUP, getStepTracking(tourguideStep))),
|
|
130
|
+
options: {
|
|
131
|
+
closeButton: false,
|
|
132
|
+
nextLabel: translate('Tourguide next'),
|
|
133
|
+
prevLabel: translate('Tourguide prev'),
|
|
134
|
+
finishLabel: translate('Tourguide finish'),
|
|
135
|
+
targetPadding: 2,
|
|
136
|
+
showStepDots: false,
|
|
137
|
+
keyboardControls: true,
|
|
138
|
+
exitOnEscape: true,
|
|
139
|
+
exitOnClickOutside: true,
|
|
140
|
+
debug: false,
|
|
141
|
+
completeOnFinish: true,
|
|
142
|
+
rememberStep: true
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
const playerProps = (options, store) => {
|
|
147
|
+
const errorPopinStateToProps = (0, _errorPopin.default)({
|
|
148
|
+
dispatch: store.dispatch
|
|
149
|
+
});
|
|
150
|
+
const playerStateToProps = (0, _player.default)(options, store);
|
|
151
|
+
return state => {
|
|
152
|
+
return {
|
|
153
|
+
player: playerStateToProps(state),
|
|
154
|
+
tourguide: tourguideStateToProps(state, options, store),
|
|
155
|
+
popin: errorPopinStateToProps(state)
|
|
156
|
+
};
|
|
157
|
+
};
|
|
16
158
|
};
|
|
17
159
|
var _default = exports.default = playerProps;
|
|
18
160
|
//# sourceMappingURL=slide.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slide.js","names":["_player","_interopRequireDefault","require","_errorPopin","e","__esModule","default","playerProps","options","dispatch","_pipe2","state","mapStateToProps","_mapValues2","_2","player","createPlayerStateToProps","popin","mapStateToErrorPopinProps","_default","exports"],"sources":["../../src/map-state-to-props/slide.js"],"sourcesContent":["import {__, mapValues, pipe} from 'lodash/fp';\n\nimport createPlayerStateToProps from './player';\nimport mapStateToErrorPopinProps from './error-popin';\n\nconst playerProps = (options, dispatch) => {\n return pipe(\n state => mapStateToProps => mapStateToProps(state),\n mapValues(__, {\n player: createPlayerStateToProps(options, dispatch),\n popin: mapStateToErrorPopinProps(dispatch)\n })\n );\n};\n\nexport default playerProps;\n"],"mappings":";;;;;;;AAEA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAsD,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtD,MAAMG,WAAW,GAAGA,CAACC,OAAO,EAAEC,QAAQ,KAAK;EACzC,OAAO,IAAAC,MAAA,CAAAJ,OAAA,EACLK,KAAK,IAAIC,eAAe,IAAIA,eAAe,CAACD,KAAK,CAAC,EAClD,IAAAE,WAAA,CAAAP,OAAA,EAAAQ,EAAA,CAAAR,OAAA,EAAc;IACZS,MAAM,EAAE,IAAAC,eAAwB,EAACR,OAAO,EAAEC,QAAQ,CAAC;IACnDQ,KAAK,EAAE,IAAAC,mBAAyB,EAACT,QAAQ;EAC3C,CAAC,CACH,CAAC;AACH,CAAC;AAAC,IAAAU,QAAA,GAAAC,OAAA,CAAAd,OAAA,GAEaC,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"slide.js","names":["_playerStore","require","_player","_interopRequireDefault","_errorPopin","e","__esModule","default","TOUR_GROUP","createTutorialSteps","translate","ref","target","title","content","order","group","tourguideStateToProps","state","options","store","slide","getCurrentSlide","hasMedia","_pipe2","_get2","_size2","hasClue","Boolean","hide","livesHidden","getLives","tourguideState","tourguideVisible","visible","tourguideStep","step","tourguideForceStart","forceStart","canShowHelp","isTourguideEligible","multiLangOptions","multiLang","canShowLang","stepsForTour","_filter2","_map2","_cloneDeep2","getStepTracking","stepIndex","totalSteps","length","isValidIndex","stepRef","stepNumber","steps","autoStart","startStep","onStart","dispatch","trackTourguideStarted","onStepChange","trackTourguideStepViewed","setTourguideStep","onExit","trackTourguideDismissed","hideTourguide","onFinish","trackTourguideCompleted","closeButton","nextLabel","prevLabel","finishLabel","targetPadding","showStepDots","keyboardControls","exitOnEscape","exitOnClickOutside","debug","completeOnFinish","rememberStep","playerProps","errorPopinStateToProps","mapStateToErrorPopinProps","playerStateToProps","createPlayerStateToProps","player","tourguide","popin","_default","exports"],"sources":["../../src/map-state-to-props/slide.js"],"sourcesContent":["import {\n getCurrentSlide,\n getLives,\n hideTourguide,\n isTourguideEligible,\n setTourguideStep,\n trackTourguideCompleted,\n trackTourguideDismissed,\n trackTourguideStarted,\n trackTourguideStepViewed\n} from '@coorpacademy/player-store';\nimport {cloneDeep, filter, get, map, pipe, size} from 'lodash/fp';\nimport createPlayerStateToProps from './player';\nimport mapStateToErrorPopinProps from './error-popin';\n\nconst TOUR_GROUP = 'app-player-question-tour-guide';\n\nconst createTutorialSteps = translate => [\n {\n ref: 'page',\n target: 'body',\n title: translate('Tourguide step 1 title'),\n content: translate('Tourguide step 1 content'),\n order: 1,\n group: TOUR_GROUP\n },\n {\n ref: 'slide',\n target: '[data-name=\"slide\"]',\n title: translate('Tourguide step 2 title'),\n content: translate('Tourguide step 2 content'),\n order: 2,\n group: TOUR_GROUP\n },\n {\n ref: 'media',\n target: '[data-type=\"media\"]',\n title: translate('Tourguide step 3 title'),\n content: translate('Tourguide step 3 content'),\n order: 3,\n group: TOUR_GROUP\n },\n {\n ref: 'clue',\n target: '[data-type=\"clue\"]',\n title: translate('Tourguide step 4 title'),\n content: translate('Tourguide step 4 content'),\n order: 4,\n group: TOUR_GROUP\n },\n {\n ref: 'language',\n target: '[data-name=\"button-multi-lang\"]',\n title: translate('Tourguide step 5 title'),\n content: translate('Tourguide step 5 content'),\n order: 5,\n group: TOUR_GROUP\n },\n {\n ref: 'help',\n target: '[data-name=\"help-button\"]',\n title: translate('Tourguide step 6 title'),\n content: translate('Tourguide step 6 content'),\n order: 6,\n group: TOUR_GROUP\n },\n {\n ref: 'life',\n target: '[data-name=\"life\"]',\n title: translate('Tourguide step 7 title'),\n content: translate('Tourguide step 7 content'),\n order: 7,\n group: TOUR_GROUP\n }\n];\n\nconst tourguideStateToProps = (state, options, store) => {\n const {translate} = options;\n const slide = getCurrentSlide(state);\n const hasMedia = pipe(get('lessons'), size)(slide) > 0;\n const hasClue = pipe(get('hasClue'), Boolean)(slide);\n const {hide: livesHidden} = getLives(state);\n const tourguideState = get('ui.tourguide', state) || {};\n const tourguideVisible = Boolean(tourguideState.visible);\n const tourguideStep = typeof tourguideState.step === 'number' ? tourguideState.step : 0;\n const tourguideForceStart = Boolean(tourguideState.forceStart);\n const canShowHelp = isTourguideEligible(state, options);\n const multiLangOptions = options.multiLang || {};\n const canShowLang = pipe(get('supportedLangs'), size)(multiLangOptions) > 1;\n\n const stepsForTour = pipe(\n filter(step => {\n if (step.order === 3) {\n return hasMedia;\n }\n if (step.order === 4) {\n return hasClue;\n }\n if (step.order === 5) {\n return canShowLang;\n }\n if (step.order === 6) {\n return canShowHelp;\n }\n if (step.order === 7) {\n return !livesHidden;\n }\n return true;\n }),\n map(cloneDeep)\n )(createTutorialSteps(translate));\n const getStepTracking = stepIndex => {\n const totalSteps = stepsForTour.length;\n const isValidIndex = typeof stepIndex === 'number' && stepIndex >= 0 && stepIndex < totalSteps;\n const stepRef = isValidIndex ? stepsForTour[stepIndex].ref : null;\n return {\n stepRef,\n stepNumber: isValidIndex ? stepIndex + 1 : null,\n totalSteps\n };\n };\n\n if (!tourguideVisible) {\n return null;\n }\n\n return {\n steps: stepsForTour,\n group: TOUR_GROUP,\n autoStart: tourguideVisible,\n forceStart: tourguideForceStart,\n startStep: tourguideStep,\n onStart: () =>\n store.dispatch(trackTourguideStarted(TOUR_GROUP, getStepTracking(tourguideStep))),\n onStepChange: step => {\n store.dispatch(trackTourguideStepViewed(TOUR_GROUP, getStepTracking(step)));\n store.dispatch(setTourguideStep(step));\n },\n onExit: () => {\n store.dispatch(trackTourguideDismissed(TOUR_GROUP, getStepTracking(tourguideStep)));\n store.dispatch(hideTourguide());\n },\n onFinish: () =>\n store.dispatch(trackTourguideCompleted(TOUR_GROUP, getStepTracking(tourguideStep))),\n options: {\n closeButton: false,\n nextLabel: translate('Tourguide next'),\n prevLabel: translate('Tourguide prev'),\n finishLabel: translate('Tourguide finish'),\n targetPadding: 2,\n showStepDots: false,\n keyboardControls: true,\n exitOnEscape: true,\n exitOnClickOutside: true,\n debug: false,\n completeOnFinish: true,\n rememberStep: true\n }\n };\n};\n\nconst playerProps = (options, store) => {\n const errorPopinStateToProps = mapStateToErrorPopinProps({dispatch: store.dispatch});\n const playerStateToProps = createPlayerStateToProps(options, store);\n\n return state => {\n return {\n player: playerStateToProps(state),\n tourguide: tourguideStateToProps(state, options, store),\n popin: errorPopinStateToProps(state)\n };\n };\n};\n\nexport default playerProps;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAYA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAD,sBAAA,CAAAF,OAAA;AAAsD,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtD,MAAMG,UAAU,GAAG,gCAAgC;AAEnD,MAAMC,mBAAmB,GAAGC,SAAS,IAAI,CACvC;EACEC,GAAG,EAAE,MAAM;EACXC,MAAM,EAAE,MAAM;EACdC,KAAK,EAAEH,SAAS,CAAC,wBAAwB,CAAC;EAC1CI,OAAO,EAAEJ,SAAS,CAAC,0BAA0B,CAAC;EAC9CK,KAAK,EAAE,CAAC;EACRC,KAAK,EAAER;AACT,CAAC,EACD;EACEG,GAAG,EAAE,OAAO;EACZC,MAAM,EAAE,qBAAqB;EAC7BC,KAAK,EAAEH,SAAS,CAAC,wBAAwB,CAAC;EAC1CI,OAAO,EAAEJ,SAAS,CAAC,0BAA0B,CAAC;EAC9CK,KAAK,EAAE,CAAC;EACRC,KAAK,EAAER;AACT,CAAC,EACD;EACEG,GAAG,EAAE,OAAO;EACZC,MAAM,EAAE,qBAAqB;EAC7BC,KAAK,EAAEH,SAAS,CAAC,wBAAwB,CAAC;EAC1CI,OAAO,EAAEJ,SAAS,CAAC,0BAA0B,CAAC;EAC9CK,KAAK,EAAE,CAAC;EACRC,KAAK,EAAER;AACT,CAAC,EACD;EACEG,GAAG,EAAE,MAAM;EACXC,MAAM,EAAE,oBAAoB;EAC5BC,KAAK,EAAEH,SAAS,CAAC,wBAAwB,CAAC;EAC1CI,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ity2 = _interopRequireDefault(require("lodash/fp/identity"));
|
|
|
6
6
|
var _set2 = _interopRequireDefault(require("lodash/fp/set"));
|
|
7
7
|
var _ava = _interopRequireDefault(require("ava"));
|
|
8
8
|
var _translate = require("@coorpacademy/translate");
|
|
9
|
+
var _playerStore = require("@coorpacademy/player-store");
|
|
9
10
|
var _header = _interopRequireDefault(require("../header"));
|
|
10
11
|
var _basic = _interopRequireDefault(require("./fixtures/slides/basic"));
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
13
|
const options = {
|
|
13
|
-
translate: _translate.mockTranslate
|
|
14
|
+
translate: _translate.mockTranslate,
|
|
15
|
+
mode: 'scorm'
|
|
14
16
|
};
|
|
15
17
|
const store = {
|
|
16
18
|
dispatch: _identity2.default
|
|
@@ -129,4 +131,161 @@ const data = {
|
|
|
129
131
|
const props = headerProps(state);
|
|
130
132
|
t.is(props.lives, false);
|
|
131
133
|
});
|
|
134
|
+
(0, _ava.default)('content click should dispatch back', t => {
|
|
135
|
+
const calls = [];
|
|
136
|
+
const dispatch = action => {
|
|
137
|
+
calls.push(action);
|
|
138
|
+
return action;
|
|
139
|
+
};
|
|
140
|
+
const headerWithDispatch = (0, _header.default)(options, {
|
|
141
|
+
dispatch
|
|
142
|
+
});
|
|
143
|
+
const ui = {
|
|
144
|
+
current: {
|
|
145
|
+
progressionId: 'basic'
|
|
146
|
+
},
|
|
147
|
+
route: {
|
|
148
|
+
basic: 'answer'
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const state = {
|
|
152
|
+
data,
|
|
153
|
+
ui
|
|
154
|
+
};
|
|
155
|
+
const props = headerWithDispatch(state);
|
|
156
|
+
props.content.onClick();
|
|
157
|
+
t.is(calls.length, 1);
|
|
158
|
+
t.is(typeof calls[0], 'function');
|
|
159
|
+
});
|
|
160
|
+
(0, _ava.default)('should expose help action when eligible', t => {
|
|
161
|
+
const ui = {
|
|
162
|
+
current: {
|
|
163
|
+
progressionId: 'basic'
|
|
164
|
+
},
|
|
165
|
+
route: {
|
|
166
|
+
basic: 'answer'
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const state = {
|
|
170
|
+
data,
|
|
171
|
+
ui
|
|
172
|
+
};
|
|
173
|
+
const props = headerProps(state);
|
|
174
|
+
t.truthy(props.help);
|
|
175
|
+
t.is(props.help.title, '__Help');
|
|
176
|
+
});
|
|
177
|
+
(0, _ava.default)('should not expose help action when adaptive', t => {
|
|
178
|
+
const ui = {
|
|
179
|
+
current: {
|
|
180
|
+
progressionId: 'basic'
|
|
181
|
+
},
|
|
182
|
+
route: {
|
|
183
|
+
basic: 'answer'
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
const adaptiveData = (0, _set2.default)(['contents', 'chapter', 'entities', '1.B2', 'isConditional'], true, data);
|
|
187
|
+
const state = {
|
|
188
|
+
data: adaptiveData,
|
|
189
|
+
ui
|
|
190
|
+
};
|
|
191
|
+
const props = headerProps(state);
|
|
192
|
+
t.is(props.help, null);
|
|
193
|
+
});
|
|
194
|
+
(0, _ava.default)('help click should dispatch route change and show action when not on question tab', t => {
|
|
195
|
+
const calls = [];
|
|
196
|
+
const dispatch = action => {
|
|
197
|
+
calls.push(action);
|
|
198
|
+
return action;
|
|
199
|
+
};
|
|
200
|
+
const headerWithDispatch = (0, _header.default)(options, {
|
|
201
|
+
dispatch
|
|
202
|
+
});
|
|
203
|
+
const ui = {
|
|
204
|
+
current: {
|
|
205
|
+
progressionId: 'basic'
|
|
206
|
+
},
|
|
207
|
+
route: {
|
|
208
|
+
basic: 'clue'
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const state = {
|
|
212
|
+
data,
|
|
213
|
+
ui
|
|
214
|
+
};
|
|
215
|
+
const props = headerWithDispatch(state);
|
|
216
|
+
props.help.onClick();
|
|
217
|
+
t.is(calls.length, 2);
|
|
218
|
+
t.is(typeof calls[0], 'function');
|
|
219
|
+
t.is(calls[1].type, _playerStore.SHOW_TOURGUIDE);
|
|
220
|
+
});
|
|
221
|
+
(0, _ava.default)('help click should only show when already on question tab', t => {
|
|
222
|
+
const calls = [];
|
|
223
|
+
const dispatch = action => {
|
|
224
|
+
calls.push(action);
|
|
225
|
+
return action;
|
|
226
|
+
};
|
|
227
|
+
const headerWithDispatch = (0, _header.default)(options, {
|
|
228
|
+
dispatch
|
|
229
|
+
});
|
|
230
|
+
const ui = {
|
|
231
|
+
current: {
|
|
232
|
+
progressionId: 'basic'
|
|
233
|
+
},
|
|
234
|
+
route: {
|
|
235
|
+
basic: 'answer'
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const state = {
|
|
239
|
+
data,
|
|
240
|
+
ui
|
|
241
|
+
};
|
|
242
|
+
const props = headerWithDispatch(state);
|
|
243
|
+
props.help.onClick();
|
|
244
|
+
t.is(calls.length, 1);
|
|
245
|
+
t.is(calls[0].type, _playerStore.SHOW_TOURGUIDE);
|
|
246
|
+
});
|
|
247
|
+
(0, _ava.default)('header uses default options when none provided', t => {
|
|
248
|
+
const dispatch = _identity2.default;
|
|
249
|
+
const headerWithDefaults = (0, _header.default)(undefined, {
|
|
250
|
+
dispatch
|
|
251
|
+
});
|
|
252
|
+
const ui = {
|
|
253
|
+
current: {
|
|
254
|
+
progressionId: 'basic'
|
|
255
|
+
},
|
|
256
|
+
route: {
|
|
257
|
+
basic: 'answer'
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const state = {
|
|
261
|
+
data,
|
|
262
|
+
ui
|
|
263
|
+
};
|
|
264
|
+
const props = headerWithDefaults(state);
|
|
265
|
+
t.is(props.mode, 'default');
|
|
266
|
+
});
|
|
267
|
+
(0, _ava.default)('help labels fall back to raw key when translate is missing', t => {
|
|
268
|
+
const dispatch = _identity2.default;
|
|
269
|
+
const headerWithDefaults = (0, _header.default)({
|
|
270
|
+
mode: 'scorm'
|
|
271
|
+
}, {
|
|
272
|
+
dispatch
|
|
273
|
+
});
|
|
274
|
+
const ui = {
|
|
275
|
+
current: {
|
|
276
|
+
progressionId: 'basic'
|
|
277
|
+
},
|
|
278
|
+
route: {
|
|
279
|
+
basic: 'answer'
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
const state = {
|
|
283
|
+
data,
|
|
284
|
+
ui
|
|
285
|
+
};
|
|
286
|
+
const props = headerWithDefaults(state);
|
|
287
|
+
t.truthy(props.help);
|
|
288
|
+
t.is(props.help.title, 'Help');
|
|
289
|
+
t.is(props.help.ariaLabel, 'Help');
|
|
290
|
+
});
|
|
132
291
|
//# sourceMappingURL=header.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header.js","names":["_ava","_interopRequireDefault","require","_translate","_header","_basic","e","__esModule","default","options","translate","mockTranslate","store","dispatch","_identity2","headerProps","createHeader","createProgression","slide","engine","ref","version","content","type","state","nextContent","_id","lives","livesDisabled","step","current","viewedResources","data","contents","chapter","entities","name","level","chapterIds","basicSlide","chapter_id","progressions","basic","test","t","ui","progressionId","props","deepEqual","count","_set2","_omit2","title","_pipe2","subcontent","details","is"],"sources":["../../../src/map-state-to-props/test/header.js"],"sourcesContent":["import test from 'ava';\nimport {set, identity, omit, pipe} from 'lodash/fp';\n\nimport {mockTranslate} from '@coorpacademy/translate';\nimport createHeader from '../header';\nimport basicSlide from './fixtures/slides/basic';\n\nconst options = {translate: mockTranslate};\nconst store = {dispatch: identity};\nconst headerProps = createHeader(options, store);\n\nconst createProgression = slide => ({\n engine: {\n ref: 'microlearning',\n version: '1'\n },\n content: {\n ref: '1.B1',\n type: 'chapter'\n },\n state: {\n nextContent: {\n ref: slide._id,\n type: 'slide'\n },\n lives: 100,\n livesDisabled: false,\n step: {\n current: 1\n },\n viewedResources: []\n }\n});\n\nconst data = {\n contents: {\n chapter: {\n entities: {\n '1.B2': {\n _id: '1.B2',\n name: 'some-title'\n }\n }\n },\n level: {\n entities: {\n '1.B': {\n name: 'level-with-chapters',\n chapterIds: ['1.B1', '1.B2', '1.B3']\n }\n }\n },\n slide: {\n entities: {\n [basicSlide._id]: {\n chapter_id: '1.B2'\n }\n }\n }\n },\n progressions: {\n entities: {\n basic: createProgression(basicSlide)\n }\n }\n};\n\ntest('should create header with the number of lives in the state', t => {\n const ui = {current: {progressionId: 'basic'}};\n const state = {data, ui};\n const props = headerProps(state);\n t.deepEqual(props.lives, {\n count: 100\n });\n});\n\ntest('should read title from the content when available', t => {\n const ui = {current: {progressionId: 'basic'}};\n const state = {data: set('progressions.entities.basic.content.ref', '1.B2', data), ui};\n const props = headerProps(state);\n\n t.deepEqual(omit('onClick', props.content), {\n title: 'some-title'\n });\n});\n\ntest('should find chapter details within learner.header.subcontent', t => {\n const ui = {current: {progressionId: 'basic'}};\n const state = {\n data: pipe(\n set('progressions.entities.basic.engine.ref', 'learner'),\n set('progressions.entities.basic.content.type', 'level'),\n set('progressions.entities.basic.content.ref', '1.B')\n )(data),\n ui\n };\n const props = headerProps(state);\n\n t.deepEqual(props.subcontent, {\n title: 'some-title',\n details: '2/3'\n });\n});\n\ntest('should set lives to null if lives are disabled in the progression', t => {\n const ui = {current: {progressionId: 'basic'}};\n const state = {data: set('progressions.entities.basic.state.livesDisabled', true, data), ui};\n const props = headerProps(state);\n\n t.is(props.lives, false);\n});\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAiD,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEjD,MAAMG,OAAO,GAAG;EAACC,SAAS,EAAEC;AAAa,CAAC;AAC1C,MAAMC,KAAK,GAAG;EAACC,QAAQ,EAAAC,UAAA,CAAAN;AAAU,CAAC;AAClC,MAAMO,WAAW,GAAG,IAAAC,eAAY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CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,IAAAZ,YAAI,EAAC,mEAAmE,EAAEC,CAAC,IAAI;EAC7E,MAAMC,EAAE,GAAG;IAACf,OAAO,EAAE;MAACgB,aAAa,EAAE;IAAO;EAAC,CAAC;EAC9C,MAAMtB,KAAK,GAAG;IAACQ,IAAI,EAAE,IAAAkB,KAAA,CAAA1C,OAAA,EAAI,iDAAiD,EAAE,IAAI,EAAEwB,IAAI,CAAC;IAAEa;EAAE,CAAC;EAC5F,MAAME,KAAK,GAAGhC,WAAW,CAACS,KAAK,CAAC;EAEhCoB,CAAC,CAACY,EAAE,CAACT,KAAK,CAACpB,KAAK,EAAE,KAAK,CAAC;AAC1B,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"header.js","names":["_ava","_interopRequireDefault","require","_translate","_playerStore","_header","_basic","e","__esModule","default","options","translate","mockTranslate","mode","store","dispatch","_identity2","headerProps","createHeader","createProgression","slide","engine","ref","version","content","type","state","nextContent","_id","lives","livesDisabled","step","current","viewedResources","data","contents","chapter","entities","name","level","chapterIds","basicSlide","chapter_id","progressions","basic","test","t","ui","progressionId","props","deepEqual","count","_set2","_omit2","title","_pipe2","subcontent","details","is","calls","action","push","headerWithDispatch","route","onClick","length","truthy","help","adaptiveData","SHOW_TOURGUIDE","headerWithDefaults","undefined","ariaLabel"],"sources":["../../../src/map-state-to-props/test/header.js"],"sourcesContent":["import test from 'ava';\nimport {set, identity, omit, pipe} from 'lodash/fp';\n\nimport {mockTranslate} from '@coorpacademy/translate';\nimport {SHOW_TOURGUIDE} from '@coorpacademy/player-store';\nimport createHeader from '../header';\nimport basicSlide from './fixtures/slides/basic';\n\nconst options = {translate: mockTranslate, mode: 'scorm'};\nconst store = {dispatch: identity};\nconst headerProps = createHeader(options, store);\n\nconst createProgression = slide => ({\n engine: {\n ref: 'microlearning',\n version: '1'\n },\n content: {\n ref: '1.B1',\n type: 'chapter'\n },\n state: {\n nextContent: {\n ref: slide._id,\n type: 'slide'\n },\n lives: 100,\n livesDisabled: false,\n step: {\n current: 1\n },\n viewedResources: []\n }\n});\n\nconst data = {\n contents: {\n chapter: {\n entities: {\n '1.B2': {\n _id: '1.B2',\n name: 'some-title'\n }\n }\n },\n level: {\n entities: {\n '1.B': {\n name: 'level-with-chapters',\n chapterIds: ['1.B1', '1.B2', '1.B3']\n }\n }\n },\n slide: {\n entities: {\n [basicSlide._id]: {\n chapter_id: '1.B2'\n }\n }\n }\n },\n progressions: {\n entities: {\n basic: createProgression(basicSlide)\n }\n }\n};\n\ntest('should create header with the number of lives in the state', t => {\n const ui = {current: {progressionId: 'basic'}};\n const state = {data, ui};\n const props = headerProps(state);\n t.deepEqual(props.lives, {\n count: 100\n });\n});\n\ntest('should read title from the content when available', t => {\n const ui = {current: {progressionId: 'basic'}};\n const state = {data: set('progressions.entities.basic.content.ref', '1.B2', data), ui};\n const props = headerProps(state);\n\n t.deepEqual(omit('onClick', props.content), {\n title: 'some-title'\n });\n});\n\ntest('should find chapter details within learner.header.subcontent', t => {\n const ui = {current: {progressionId: 'basic'}};\n const state = {\n data: pipe(\n set('progressions.entities.basic.engine.ref', 'learner'),\n set('progressions.entities.basic.content.type', 'level'),\n set('progressions.entities.basic.content.ref', '1.B')\n )(data),\n ui\n };\n const props = headerProps(state);\n\n t.deepEqual(props.subcontent, {\n title: 'some-title',\n details: '2/3'\n });\n});\n\ntest('should set lives to null if lives are disabled in the progression', t => {\n const ui = {current: {progressionId: 'basic'}};\n const state = {data: set('progressions.entities.basic.state.livesDisabled', true, data), ui};\n const props = headerProps(state);\n\n t.is(props.lives, false);\n});\n\ntest('content click should dispatch back', t => {\n const calls = [];\n const dispatch = action => {\n calls.push(action);\n return action;\n };\n const headerWithDispatch = createHeader(options, {dispatch});\n const ui = {current: {progressionId: 'basic'}, route: {basic: 'answer'}};\n const state = {data, ui};\n const props = headerWithDispatch(state);\n\n props.content.onClick();\n\n t.is(calls.length, 1);\n t.is(typeof calls[0], 'function');\n});\n\ntest('should expose help action when eligible', t => {\n const ui = {current: {progressionId: 'basic'}, route: {basic: 'answer'}};\n const state = {data, ui};\n const props = headerProps(state);\n\n t.truthy(props.help);\n t.is(props.help.title, '__Help');\n});\n\ntest('should not expose help action when adaptive', t => {\n const ui = {current: {progressionId: 'basic'}, route: {basic: 'answer'}};\n const adaptiveData = set(\n ['contents', 'chapter', 'entities', '1.B2', 'isConditional'],\n true,\n data\n );\n const state = {data: adaptiveData, ui};\n const props = headerProps(state);\n\n t.is(props.help, null);\n});\n\ntest('help click should dispatch route change and show action when not on question tab', t => {\n const calls = [];\n const dispatch = action => {\n calls.push(action);\n return action;\n };\n const headerWithDispatch = createHeader(options, {dispatch});\n const ui = {current: {progressionId: 'basic'}, route: {basic: 'clue'}};\n const state = {data, ui};\n const props = headerWithDispatch(state);\n\n props.help.onClick();\n\n t.is(calls.length, 2);\n t.is(typeof calls[0], 'function');\n t.is(calls[1].type, SHOW_TOURGUIDE);\n});\n\ntest('help click should only show when already on question tab', t => {\n const calls = [];\n const dispatch = action => {\n calls.push(action);\n return action;\n };\n const headerWithDispatch = createHeader(options, {dispatch});\n const ui = {current: {progressionId: 'basic'}, route: {basic: 'answer'}};\n const state = {data, ui};\n const props = headerWithDispatch(state);\n\n props.help.onClick();\n\n t.is(calls.length, 1);\n t.is(calls[0].type, SHOW_TOURGUIDE);\n});\n\ntest('header uses default options when none provided', t => {\n const dispatch = identity;\n const headerWithDefaults = createHeader(undefined, {dispatch});\n const ui = {current: {progressionId: 'basic'}, route: {basic: 'answer'}};\n const state = {data, ui};\n\n const props = headerWithDefaults(state);\n\n t.is(props.mode, 'default');\n});\n\ntest('help labels fall back to raw key when translate is missing', t => {\n const dispatch = identity;\n const headerWithDefaults = createHeader({mode: 'scorm'}, {dispatch});\n const ui = {current: {progressionId: 'basic'}, route: {basic: 'answer'}};\n const state = {data, ui};\n\n const props = headerWithDefaults(state);\n\n t.truthy(props.help);\n t.is(props.help.title, 'Help');\n t.is(props.help.ariaLabel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C,CAAC,IAAI;EACtE,MAAM/B,QAAQ,GAAAC,UAAA,CAAAP,OAAW;EACzB,MAAM6D,kBAAkB,GAAG,IAAApD,eAAY,EAAC;IAACL,IAAI,EAAE;EAAO,CAAC,EAAE;IAACE;EAAQ,CAAC,CAAC;EACpE,MAAMgC,EAAE,GAAG;IAACf,OAAO,EAAE;MAACgB,aAAa,EAAE;IAAO,CAAC;IAAEe,KAAK,EAAE;MAACnB,KAAK,EAAE;IAAQ;EAAC,CAAC;EACxE,MAAMlB,KAAK,GAAG;IAACQ,IAAI;IAAEa;EAAE,CAAC;EAExB,MAAME,KAAK,GAAGqB,kBAAkB,CAAC5C,KAAK,CAAC;EAEvCoB,CAAC,CAACoB,MAAM,CAACjB,KAAK,CAACkB,IAAI,CAAC;EACpBrB,CAAC,CAACY,EAAE,CAACT,KAAK,CAACkB,IAAI,CAACb,KAAK,EAAE,MAAM,CAAC;EAC9BR,CAAC,CAACY,EAAE,CAACT,KAAK,CAACkB,IAAI,CAACK,SAAS,EAAE,MAAM,CAAC;AACpC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -7,13 +7,15 @@ var _errorPopin = _interopRequireDefault(require("../error-popin"));
|
|
|
7
7
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
8
|
(0, _ava.default)('should return error popin props if any call fails', t => {
|
|
9
9
|
t.plan(2);
|
|
10
|
-
global.window
|
|
11
|
-
|
|
10
|
+
Object.defineProperty(global.window, 'location', {
|
|
11
|
+
value: {
|
|
12
12
|
reload: () => {
|
|
13
13
|
t.pass();
|
|
14
14
|
}
|
|
15
|
-
}
|
|
16
|
-
|
|
15
|
+
},
|
|
16
|
+
// Allow redefinition across tests; jsdom's location is non-configurable by default.
|
|
17
|
+
configurable: true
|
|
18
|
+
});
|
|
17
19
|
const props = (0, _errorPopin.default)({
|
|
18
20
|
dispatch: _identity2.default
|
|
19
21
|
})({
|
|
@@ -39,13 +41,15 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
39
41
|
});
|
|
40
42
|
(0, _ava.default)('should return error popin props if content calls fail', t => {
|
|
41
43
|
t.plan(2);
|
|
42
|
-
global.window
|
|
43
|
-
|
|
44
|
+
Object.defineProperty(global.window, 'location', {
|
|
45
|
+
value: {
|
|
44
46
|
reload: () => {
|
|
45
47
|
t.pass();
|
|
46
48
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
+
},
|
|
50
|
+
// Allow redefinition across tests; jsdom's location is non-configurable by default.
|
|
51
|
+
configurable: true
|
|
52
|
+
});
|
|
49
53
|
const props = (0, _errorPopin.default)({
|
|
50
54
|
dispatch: _identity2.default
|
|
51
55
|
})({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popin-error.js","names":["_ava","_interopRequireDefault","require","_errorPopin","e","__esModule","default","test","t","plan","global","window","
|
|
1
|
+
{"version":3,"file":"popin-error.js","names":["_ava","_interopRequireDefault","require","_errorPopin","e","__esModule","default","test","t","plan","Object","defineProperty","global","window","value","reload","pass","configurable","props","mapStateToErrorPopinProps","dispatch","_identity2","data","progressions","isFailure","deepEqual","_omit2","content","icon","mode","descriptionText","firstButton","largeButton","label","type","handleOnclick","contents","level","is","undefined"],"sources":["../../../src/map-state-to-props/test/popin-error.js"],"sourcesContent":["import test from 'ava';\n\nimport {identity, omit} from 'lodash/fp';\n\nimport mapStateToErrorPopinProps from '../error-popin';\n\ntest('should return error popin props if any call fails', t => {\n t.plan(2);\n Object.defineProperty(global.window, 'location', {\n value: {\n reload: () => {\n t.pass();\n }\n },\n // Allow redefinition across tests; jsdom's location is non-configurable by default.\n configurable: true\n });\n const props = mapStateToErrorPopinProps({dispatch: identity})({\n data: {\n progressions: {\n isFailure: true\n }\n }\n });\n\n t.deepEqual(omit('firstButton.handleOnclick', props), {\n content: 'An unexpected error has occurred',\n icon: 'AlertDiamond',\n mode: 'alert',\n descriptionText: 'Please reload the page and try again',\n firstButton: {\n largeButton: true,\n label: 'Reload',\n type: 'primary',\n 'aria-label': 'Reload'\n }\n });\n props.firstButton.handleOnclick();\n});\n\ntest('should return error popin props if content calls fail', t => {\n t.plan(2);\n Object.defineProperty(global.window, 'location', {\n value: {\n reload: () => {\n t.pass();\n }\n },\n // Allow redefinition across tests; jsdom's location is non-configurable by default.\n configurable: true\n });\n const props = mapStateToErrorPopinProps({dispatch: identity})({\n data: {\n contents: {\n level: {\n isFailure: true\n }\n }\n }\n });\n\n t.deepEqual(omit('firstButton.handleOnclick', props), {\n content: 'An unexpected error has occurred',\n icon: 'AlertDiamond',\n mode: 'alert',\n descriptionText: 'Please reload the page and try again',\n firstButton: {\n largeButton: true,\n label: 'Reload',\n type: 'primary',\n 'aria-label': 'Reload'\n }\n });\n props.firstButton.handleOnclick();\n});\n\ntest('should not return error popin props', t => {\n const props = mapStateToErrorPopinProps({dispatch: identity})({});\n\n t.is(props, undefined);\n});\n"],"mappings":";;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAuD,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEvD,IAAAG,YAAI,EAAC,mDAAmD,EAAEC,CAAC,IAAI;EAC7DA,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC;EACTC,MAAM,CAACC,cAAc,CAACC,MAAM,CAACC,MAAM,EAAE,UAAU,EAAE;IAC/CC,KAAK,EAAE;MACLC,MAAM,EAAEA,CAAA,KAAM;QACZP,CAAC,CAACQ,IAAI,CAAC,CAAC;MACV;IACF,CAAC;IACD;IACAC,YAAY,EAAE;EAChB,CAAC,CAAC;EACF,MAAMC,KAAK,GAAG,IAAAC,mBAAyB,EAAC;IAACC,QAAQ,EAAAC,UAAA,CAAAf;EAAU,CAAC,CAAC,CAAC;IAC5DgB,IAAI,EAAE;MACJC,YAAY,EAAE;QACZC,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