@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.
Files changed (74) hide show
  1. package/es/index.js +3 -0
  2. package/es/index.js.map +1 -1
  3. package/es/map-state-to-props/header.js +23 -3
  4. package/es/map-state-to-props/header.js.map +1 -1
  5. package/es/map-state-to-props/slide.js +149 -7
  6. package/es/map-state-to-props/slide.js.map +1 -1
  7. package/es/map-state-to-props/test/header.js +160 -1
  8. package/es/map-state-to-props/test/header.js.map +1 -1
  9. package/es/map-state-to-props/test/popin-error.js +12 -8
  10. package/es/map-state-to-props/test/popin-error.js.map +1 -1
  11. package/es/map-state-to-props/test/slide.js +224 -0
  12. package/es/map-state-to-props/test/slide.js.map +1 -0
  13. package/es/map-state-to-props/test/tourguide-sync.js +243 -0
  14. package/es/map-state-to-props/test/tourguide-sync.js.map +1 -0
  15. package/es/store.js +3 -2
  16. package/es/store.js.map +1 -1
  17. package/es/test/init-reducers.js +10 -1
  18. package/es/test/init-reducers.js.map +1 -1
  19. package/es/test/store.js +3 -5
  20. package/es/test/store.js.map +1 -1
  21. package/es/tourguide-sync.js +24 -0
  22. package/es/tourguide-sync.js.map +1 -0
  23. package/lib/index.js +3 -0
  24. package/lib/index.js.map +1 -1
  25. package/lib/map-state-to-props/header.js +22 -2
  26. package/lib/map-state-to-props/header.js.map +1 -1
  27. package/lib/map-state-to-props/slide.js +149 -7
  28. package/lib/map-state-to-props/slide.js.map +1 -1
  29. package/lib/map-state-to-props/test/header.js +160 -1
  30. package/lib/map-state-to-props/test/header.js.map +1 -1
  31. package/lib/map-state-to-props/test/popin-error.js +12 -8
  32. package/lib/map-state-to-props/test/popin-error.js.map +1 -1
  33. package/lib/map-state-to-props/test/slide.js +227 -0
  34. package/lib/map-state-to-props/test/slide.js.map +1 -0
  35. package/lib/map-state-to-props/test/tourguide-sync.js +246 -0
  36. package/lib/map-state-to-props/test/tourguide-sync.js.map +1 -0
  37. package/lib/store.js +3 -2
  38. package/lib/store.js.map +1 -1
  39. package/lib/test/init-reducers.js +10 -1
  40. package/lib/test/init-reducers.js.map +1 -1
  41. package/lib/test/store.js +3 -5
  42. package/lib/test/store.js.map +1 -1
  43. package/lib/tourguide-sync.js +29 -0
  44. package/lib/tourguide-sync.js.map +1 -0
  45. package/locales/bs/player.json +19 -1
  46. package/locales/cs/player.json +19 -1
  47. package/locales/de/player.json +19 -1
  48. package/locales/en/player.json +19 -1
  49. package/locales/es/player.json +19 -1
  50. package/locales/et/player.json +19 -1
  51. package/locales/fi/player.json +19 -1
  52. package/locales/fr/player.json +19 -1
  53. package/locales/hr/player.json +19 -1
  54. package/locales/hu/player.json +19 -1
  55. package/locales/hy/player.json +19 -1
  56. package/locales/it/player.json +19 -1
  57. package/locales/ja/player.json +19 -1
  58. package/locales/ko/player.json +19 -1
  59. package/locales/lt/player.json +19 -1
  60. package/locales/nl/player.json +19 -1
  61. package/locales/pl/player.json +19 -1
  62. package/locales/pt/player.json +19 -1
  63. package/locales/ro/player.json +19 -1
  64. package/locales/ru/player.json +19 -1
  65. package/locales/sk/player.json +19 -1
  66. package/locales/sl/player.json +19 -1
  67. package/locales/sv/player.json +19 -1
  68. package/locales/tl/player.json +19 -1
  69. package/locales/tr/player.json +19 -1
  70. package/locales/uk/player.json +19 -1
  71. package/locales/vi/player.json +19 -1
  72. package/locales/zh/player.json +19 -1
  73. package/locales/zh_TW/player.json +19 -1
  74. package/package.json +4 -4
package/es/index.js CHANGED
@@ -7,6 +7,7 @@ import runApp from './run-app';
7
7
  import createStore from './store';
8
8
  import { selectMapStateToVNode } from './map-state-to-props';
9
9
  import { createStateToVNode, views } from './views';
10
+ import createTourguideSync from './tourguide-sync';
10
11
  const createUpdate = (container, store, options) => _selectMapStateToVNode => {
11
12
  const {
12
13
  getState
@@ -24,6 +25,7 @@ const create = options => {
24
25
  container
25
26
  } = options;
26
27
  const store = createStore(options);
28
+ const unsubscribeTourguideSync = createTourguideSync(options, store);
27
29
  let update = createUpdate(container, store, options)(selectMapStateToVNode);
28
30
  let unsubscribe = store.subscribe(update);
29
31
 
@@ -46,6 +48,7 @@ const create = options => {
46
48
  selectProgression: id => dispatch(selectProgression(id)),
47
49
  unsubscribe: () => {
48
50
  unmountComponentAtNode(container);
51
+ unsubscribeTourguideSync();
49
52
  return unsubscribe();
50
53
  }
51
54
  };
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["render","unmountComponentAtNode","createElement","Provider","selectProgression","updateCoaches","runApp","createStore","selectMapStateToVNode","createStateToVNode","views","createUpdate","container","store","options","_selectMapStateToVNode","getState","mapStateToVNode","mapStateToView","_pipe","vNode","state","view","create","update","unsubscribe","subscribe","module","hot","accept","require","default","dispatch","coachState","id"],"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,SAAQA,MAAM,EAAEC,sBAAsB,QAAO,WAAW;AACxD,SAAQC,aAAa,QAAO,OAAO;AAEnC,SAAQC,QAAQ,QAAO,0BAA0B;AACjD,SAAQC,iBAAiB,EAAEC,aAAa,QAAO,4BAA4B;AAC3E,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,WAAW,MAAM,SAAS;AACjC,SAAQC,qBAAqB,QAAO,sBAAsB;AAC1D,SAAQC,kBAAkB,EAAEC,KAAK,QAAO,SAAS;AAEjD,MAAMC,YAAY,GAAGA,CAACC,SAAS,EAAEC,KAAK,EAAEC,OAAO,KAAKC,sBAAsB,IAAI;EAC5E,MAAM;IAACC;EAAQ,CAAC,GAAGH,KAAK;EACxB,MAAMI,eAAe,GAAGF,sBAAsB,CAACD,OAAO,EAAED,KAAK,EAAEH,KAAK,EAAED,kBAAkB,CAAC;EACzF,MAAMS,cAAc,GAAGC,KAAA,CAAKF,eAAe,EAAEG,KAAK,IAAIlB,aAAa,CAACC,QAAQ,EAAEW,OAAO,EAAEM,KAAK,CAAC,CAAC;EAE9F,OAAO,MAAM;IACX,MAAMC,KAAK,GAAGL,QAAQ,CAAC,CAAC;IACxB,MAAMM,IAAI,GAAGJ,cAAc,CAACG,KAAK,CAAC;IAClC,OAAOrB,MAAM,CAACsB,IAAI,EAAEV,SAAS,CAAC;EAChC,CAAC;AACH,CAAC;AAED,MAAMW,MAAM,GAAGT,OAAO,IAAI;EACxB,MAAM;IAACF;EAAS,CAAC,GAAGE,OAAO;EAC3B,MAAMD,KAAK,GAAGN,WAAW,CAACO,OAAO,CAAC;EAElC,IAAIU,MAAM,GAAGb,YAAY,CAACC,SAAS,EAAEC,KAAK,EAAEC,OAAO,CAAC,CAACN,qBAAqB,CAAC;EAC3E,IAAIiB,WAAW,GAAGZ,KAAK,CAACa,SAAS,CAACF,MAAM,CAAC;;EAEzC;EACA,IAAIG,MAAM,CAACC,GAAG,EAAE;IACdD,MAAM,CAACC,GAAG,CAACC,MAAM,CAAC,SAAS,EAAE,MAAM;MACjCJ,WAAW,CAAC,CAAC;MACbD,MAAM,GAAGb,YAAY,CAACC,SAAS,EAAEC,KAAK,EAAEC,OAAO,CAAC,CAACgB,OAAO,CAAC,SAAS,CAAC,CAACC,OAAO,CAAC;MAC5EP,MAAM,CAAC,CAAC;MACRC,WAAW,GAAGZ,KAAK,CAACa,SAAS,CAACF,MAAM,CAAC;IACvC,CAAC,CAAC;EACJ;EAEAlB,MAAM,CAACQ,OAAO,EAAED,KAAK,CAAC;EAEtB,MAAM;IAACmB;EAAQ,CAAC,GAAGnB,KAAK;EACxB,OAAO;IACLW,MAAM,EAAEA,CAAA,KAAMA,MAAM,CAAC,CAAC;IAEtBnB,aAAa,EAAE4B,UAAU,IAAID,QAAQ,CAAC3B,aAAa,CAAC4B,UAAU,CAAC,CAAC;IAChE7B,iBAAiB,EAAE8B,EAAE,IAAIF,QAAQ,CAAC5B,iBAAiB,CAAC8B,EAAE,CAAC,CAAC;IAExDT,WAAW,EAAEA,CAAA,KAAM;MACjBxB,sBAAsB,CAACW,SAAS,CAAC;MACjC,OAAOa,WAAW,CAAC,CAAC;IACtB;EACF,CAAC;AACH,CAAC;AAED,SAAQF,MAAM","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["render","unmountComponentAtNode","createElement","Provider","selectProgression","updateCoaches","runApp","createStore","selectMapStateToVNode","createStateToVNode","views","createTourguideSync","createUpdate","container","store","options","_selectMapStateToVNode","getState","mapStateToVNode","mapStateToView","_pipe","vNode","state","view","create","unsubscribeTourguideSync","update","unsubscribe","subscribe","module","hot","accept","require","default","dispatch","coachState","id"],"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,SAAQA,MAAM,EAAEC,sBAAsB,QAAO,WAAW;AACxD,SAAQC,aAAa,QAAO,OAAO;AAEnC,SAAQC,QAAQ,QAAO,0BAA0B;AACjD,SAAQC,iBAAiB,EAAEC,aAAa,QAAO,4BAA4B;AAC3E,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,WAAW,MAAM,SAAS;AACjC,SAAQC,qBAAqB,QAAO,sBAAsB;AAC1D,SAAQC,kBAAkB,EAAEC,KAAK,QAAO,SAAS;AACjD,OAAOC,mBAAmB,MAAM,kBAAkB;AAElD,MAAMC,YAAY,GAAGA,CAACC,SAAS,EAAEC,KAAK,EAAEC,OA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AAK,CAAC;EAEtB,MAAM;IAACoB;EAAQ,CAAC,GAAGpB,KAAK;EACxB,OAAO;IACLY,MAAM,EAAEA,CAAA,KAAMA,MAAM,CAAC,CAAC;IAEtBrB,aAAa,EAAE8B,UAAU,IAAID,QAAQ,CAAC7B,aAAa,CAAC8B,UAAU,CAAC,CAAC;IAChE/B,iBAAiB,EAAEgC,EAAE,IAAIF,QAAQ,CAAC9B,iBAAiB,CAACgC,EAAE,CAAC,CAAC;IAExDT,WAAW,EAAEA,CAAA,KAAM;MACjB1B,sBAAsB,CAACY,SAAS,CAAC;MACjCY,wBAAwB,CAAC,CAAC;MAC1B,OAAOE,WAAW,CAAC,CAAC;IACtB;EACF,CAAC;AACH,CAAC;AAED,SAAQH,MAAM","ignoreList":[]}
@@ -1,7 +1,8 @@
1
1
  import _indexOf from "lodash/fp/indexOf";
2
+ import _identity from "lodash/fp/identity";
2
3
  import _getOr from "lodash/fp/getOr";
3
4
  import _get from "lodash/fp/get";
4
- import { getCurrentChapter, getEngine, getLives, getCurrentContent, back } from '@coorpacademy/player-store';
5
+ import { getCurrentChapter, getEngine, getLives, getCurrentContent, getRoute, selectRoute, back, showTourguide, isTourguideEligible } from '@coorpacademy/player-store';
5
6
  const headerContent = (engineRef, state) => {
6
7
  const content = getCurrentContent(state);
7
8
  switch (engineRef) {
@@ -35,6 +36,24 @@ const headerSubcontent = (engineRef, state) => {
35
36
  return null;
36
37
  }
37
38
  };
39
+ const buildHelpProps = (state, options, dispatch) => {
40
+ const isQuestionTab = getRoute(state) === 'answer';
41
+ const translate = _getOr(_identity, 'translate', options);
42
+ const canShowHelp = isTourguideEligible(state, options);
43
+ if (!canShowHelp) {
44
+ return null;
45
+ }
46
+ return {
47
+ onClick: () => {
48
+ if (!isQuestionTab) {
49
+ dispatch(selectRoute('answer'));
50
+ }
51
+ dispatch(showTourguide(undefined, true));
52
+ },
53
+ ariaLabel: translate('Help'),
54
+ title: translate('Help')
55
+ };
56
+ };
38
57
  const headerProps = (options, {
39
58
  dispatch
40
59
  }) => state => {
@@ -56,8 +75,9 @@ const headerProps = (options, {
56
75
  lives: hide ? false : {
57
76
  count
58
77
  },
59
- mode: options.mode || 'default',
60
- multiLang: options.multiLang
78
+ mode: _getOr('default', 'mode', options),
79
+ multiLang: _get('multiLang', options),
80
+ help: buildHelpProps(state, options, dispatch)
61
81
  };
62
82
  };
63
83
  export default headerProps;
@@ -1 +1 @@
1
- {"version":3,"file":"header.js","names":["getCurrentChapter","getEngine","getLives","getCurrentContent","back","headerContent","engineRef","state","content","title","_getOr","details","_get","headerSubcontent","chapter","level","chapterIds","_indexOf","_id","length","headerProps","options","dispatch","engine","ref","hide","count","type","onClick","subcontent","lives","mode","multiLang"],"sources":["../../src/map-state-to-props/header.js"],"sourcesContent":["import {get, getOr, indexOf} from 'lodash/fp';\nimport {\n getCurrentChapter,\n getEngine,\n getLives,\n getCurrentContent,\n back\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 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: options.mode || 'default',\n multiLang: options.multiL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AAK,IAAI;EACP,MAAMgB,MAAM,GAAGtB,SAAS,CAACM,KAAK,CAAC;EAC/B,MAAM;IAACiB,GAAG,EAAElB;EAAS,CAAC,GAAGiB,MAAM;EAC/B,MAAM;IAACE,IAAI;IAAEC;EAAK,CAAC,GAAGxB,QAAQ,CAACK,KAAK,CAAC;EAErC,OAAO;IACLoB,IAAI,EAAErB,SAAS;IACfE,OAAO,EAAE;MACP,GAAGH,aAAa,CAACC,SAAS,EAAEC,KAAK,CAAC;MAClCqB,OAAO,EAAEA,CAAA,KAAMN,QAAQ,CAAClB,IAAI;IAC9B,CAAC;IACDyB,UAAU,EAAEhB,gBAAgB,CAACP,SAAS,EAAEC,KAAK,CAAC;IAC9CuB,KAAK,EAAEL,IAAI,GAAG,KAAK,GAAG;MAACC;IAAK,CAAC;IAC7BK,IAAI,EAAEV,OAAO,CAACU,IAAI,IAAI,SAAS;IAC/BC,SAAS,EAAEX,OAAO,CAACW;EACrB,CAAC;AACH,CAAC;AAEH,eAAeZ,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"header.js","names":["getCurrentChapter","getEngine","getLives","getCurrentContent","getRoute","selectRoute","back","showTourguide","isTourguideEligible","headerContent","engineRef","state","content","title","_getOr","details","_get","headerSubcontent","chapter","level","chapterIds","_indexOf","_id","length","buildHelpProps","options","dispatch","isQuestionTab","translate","_identity","canShowHelp","onClick","undefined","ariaLabel","headerProps","engine","ref","hide","count","type","subcontent","lives","mode","multiLang","help"],"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,SACEA,iBAAiB,EACjBC,SAAS,EACTC,QAAQ,EACRC,iBAAiB,EACjBC,QAAQ,EACRC,WAAW,EACXC,IAAI,EACJC,aAAa,EACbC,mBAAmB,QACd,4BAA4B;AAEnC,MAAMC,aAAa,GAAGA,CAACC,SAAS,EAAEC,KAAK,KAAK;EAC1C,MAAMC,OAAO,GAAGT,iBAAiB,CAACQ,KAAK,CAAC;EAExC,QAAQD,SAAS;IACf,KAAK,SAAS;MACZ,OAAO;QACLG,KAAK,EAAEC,MAAA,CAAM,EAAE,EAAE,MAAM,CAAC,CAACF,OAAO,CAAC;QACjCG,OAAO,EAAE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QAAQ,CAAC,CAAC;MACjC;MACAqB,QAAQ,CAACnB,aAAa,CAACyB,SAAS,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IACDC,SAAS,EAAEL,SAAS,CAAC,MAAM,CAAC;IAC5Bf,KAAK,EAAEe,SAAS,CAAC,MAAM;EACzB,CAAC;AACH,CAAC;AAED,MAAMM,WAAW,GACfA,CAACT,OAAO,EAAE;EAACC;AAAQ,CAAC,KACpBf,KAAK,IAAI;EACP,MAAMwB,MAAM,GAAGlC,SAAS,CAACU,KAAK,CAAC;EAC/B,MAAM;IAACyB,GAAG,EAAE1B;EAAS,CAAC,GAAGyB,MAAM;EAC/B,MAAM;IAACE,IAAI;IAAEC;EAAK,CAAC,GAAGpC,QAAQ,CAACS,KAAK,CAAC;EAErC,OAAO;IACL4B,IAAI,EAAE7B,SAAS;IACfE,OAAO,EAAE;MACP,GAAGH,aAAa,CAACC,SAAS,EAAEC,KAAK,CAAC;MAClCoB,OAAO,EAAEA,CAAA,KAAML,QAAQ,CAACpB,IAAI;IAC9B,CAAC;IACDkC,UAAU,EAAEvB,gBAAgB,CAACP,SAAS,EAAEC,KAAK,CAAC;IAC9C8B,KAAK,EAAEJ,IAAI,GAAG,KAAK,GAAG;MAACC;IAAK,CAAC;IAC7BI,IAAI,EAAE5B,MAAA,CAAM,SAAS,EAAE,MAAM,EAAEW,OAAO,CAAC;IACvCkB,SAAS,EAAE3B,IAAA,CAAI,WAAW,EAAES,OAAO,CAAC;IACpCmB,IAAI,EAAEpB,cAAc,CAACb,KAAK,EAAEc,OAAO,EAAEC,QAAQ;EAC/C,CAAC;AACH,CAAC;AAEH,eAAeQ,WAAW","ignoreList":[]}
@@ -1,13 +1,155 @@
1
+ import _size from "lodash/fp/size";
1
2
  import _pipe from "lodash/fp/pipe";
2
- import _mapValues from "lodash/fp/mapValues";
3
- import _ from "lodash/fp/__";
3
+ import _map from "lodash/fp/map";
4
+ import _get from "lodash/fp/get";
5
+ import _filter from "lodash/fp/filter";
6
+ import _cloneDeep from "lodash/fp/cloneDeep";
7
+ import { getCurrentSlide, getLives, hideTourguide, isTourguideEligible, setTourguideStep, trackTourguideCompleted, trackTourguideDismissed, trackTourguideStarted, trackTourguideStepViewed } from '@coorpacademy/player-store';
4
8
  import createPlayerStateToProps from './player';
5
9
  import mapStateToErrorPopinProps from './error-popin';
6
- const playerProps = (options, dispatch) => {
7
- return _pipe(state => mapStateToProps => mapStateToProps(state), _mapValues(_, {
8
- player: createPlayerStateToProps(options, dispatch),
9
- popin: mapStateToErrorPopinProps(dispatch)
10
- }));
10
+ const TOUR_GROUP = 'app-player-question-tour-guide';
11
+ const createTutorialSteps = translate => [{
12
+ ref: 'page',
13
+ target: 'body',
14
+ title: translate('Tourguide step 1 title'),
15
+ content: translate('Tourguide step 1 content'),
16
+ order: 1,
17
+ group: TOUR_GROUP
18
+ }, {
19
+ ref: 'slide',
20
+ target: '[data-name="slide"]',
21
+ title: translate('Tourguide step 2 title'),
22
+ content: translate('Tourguide step 2 content'),
23
+ order: 2,
24
+ group: TOUR_GROUP
25
+ }, {
26
+ ref: 'media',
27
+ target: '[data-type="media"]',
28
+ title: translate('Tourguide step 3 title'),
29
+ content: translate('Tourguide step 3 content'),
30
+ order: 3,
31
+ group: TOUR_GROUP
32
+ }, {
33
+ ref: 'clue',
34
+ target: '[data-type="clue"]',
35
+ title: translate('Tourguide step 4 title'),
36
+ content: translate('Tourguide step 4 content'),
37
+ order: 4,
38
+ group: TOUR_GROUP
39
+ }, {
40
+ ref: 'language',
41
+ target: '[data-name="button-multi-lang"]',
42
+ title: translate('Tourguide step 5 title'),
43
+ content: translate('Tourguide step 5 content'),
44
+ order: 5,
45
+ group: TOUR_GROUP
46
+ }, {
47
+ ref: 'help',
48
+ target: '[data-name="help-button"]',
49
+ title: translate('Tourguide step 6 title'),
50
+ content: translate('Tourguide step 6 content'),
51
+ order: 6,
52
+ group: TOUR_GROUP
53
+ }, {
54
+ ref: 'life',
55
+ target: '[data-name="life"]',
56
+ title: translate('Tourguide step 7 title'),
57
+ content: translate('Tourguide step 7 content'),
58
+ order: 7,
59
+ group: TOUR_GROUP
60
+ }];
61
+ const tourguideStateToProps = (state, options, store) => {
62
+ const {
63
+ translate
64
+ } = options;
65
+ const slide = getCurrentSlide(state);
66
+ const hasMedia = _pipe(_get('lessons'), _size)(slide) > 0;
67
+ const hasClue = _pipe(_get('hasClue'), Boolean)(slide);
68
+ const {
69
+ hide: livesHidden
70
+ } = getLives(state);
71
+ const tourguideState = _get('ui.tourguide', state) || {};
72
+ const tourguideVisible = Boolean(tourguideState.visible);
73
+ const tourguideStep = typeof tourguideState.step === 'number' ? tourguideState.step : 0;
74
+ const tourguideForceStart = Boolean(tourguideState.forceStart);
75
+ const canShowHelp = isTourguideEligible(state, options);
76
+ const multiLangOptions = options.multiLang || {};
77
+ const canShowLang = _pipe(_get('supportedLangs'), _size)(multiLangOptions) > 1;
78
+ const stepsForTour = _pipe(_filter(step => {
79
+ if (step.order === 3) {
80
+ return hasMedia;
81
+ }
82
+ if (step.order === 4) {
83
+ return hasClue;
84
+ }
85
+ if (step.order === 5) {
86
+ return canShowLang;
87
+ }
88
+ if (step.order === 6) {
89
+ return canShowHelp;
90
+ }
91
+ if (step.order === 7) {
92
+ return !livesHidden;
93
+ }
94
+ return true;
95
+ }), _map(_cloneDeep))(createTutorialSteps(translate));
96
+ const getStepTracking = stepIndex => {
97
+ const totalSteps = stepsForTour.length;
98
+ const isValidIndex = typeof stepIndex === 'number' && stepIndex >= 0 && stepIndex < totalSteps;
99
+ const stepRef = isValidIndex ? stepsForTour[stepIndex].ref : null;
100
+ return {
101
+ stepRef,
102
+ stepNumber: isValidIndex ? stepIndex + 1 : null,
103
+ totalSteps
104
+ };
105
+ };
106
+ if (!tourguideVisible) {
107
+ return null;
108
+ }
109
+ return {
110
+ steps: stepsForTour,
111
+ group: TOUR_GROUP,
112
+ autoStart: tourguideVisible,
113
+ forceStart: tourguideForceStart,
114
+ startStep: tourguideStep,
115
+ onStart: () => store.dispatch(trackTourguideStarted(TOUR_GROUP, getStepTracking(tourguideStep))),
116
+ onStepChange: step => {
117
+ store.dispatch(trackTourguideStepViewed(TOUR_GROUP, getStepTracking(step)));
118
+ store.dispatch(setTourguideStep(step));
119
+ },
120
+ onExit: () => {
121
+ store.dispatch(trackTourguideDismissed(TOUR_GROUP, getStepTracking(tourguideStep)));
122
+ store.dispatch(hideTourguide());
123
+ },
124
+ onFinish: () => store.dispatch(trackTourguideCompleted(TOUR_GROUP, getStepTracking(tourguideStep))),
125
+ options: {
126
+ closeButton: false,
127
+ nextLabel: translate('Tourguide next'),
128
+ prevLabel: translate('Tourguide prev'),
129
+ finishLabel: translate('Tourguide finish'),
130
+ targetPadding: 2,
131
+ showStepDots: false,
132
+ keyboardControls: true,
133
+ exitOnEscape: true,
134
+ exitOnClickOutside: true,
135
+ debug: false,
136
+ completeOnFinish: true,
137
+ rememberStep: true
138
+ }
139
+ };
140
+ };
141
+ const playerProps = (options, store) => {
142
+ const errorPopinStateToProps = mapStateToErrorPopinProps({
143
+ dispatch: store.dispatch
144
+ });
145
+ const playerStateToProps = createPlayerStateToProps(options, store);
146
+ return state => {
147
+ return {
148
+ player: playerStateToProps(state),
149
+ tourguide: tourguideStateToProps(state, options, store),
150
+ popin: errorPopinStateToProps(state)
151
+ };
152
+ };
11
153
  };
12
154
  export default playerProps;
13
155
  //# sourceMappingURL=slide.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"slide.js","names":["createPlayerStateToProps","mapStateToErrorPopinProps","playerProps","options","dispatch","_pipe","state","mapStateToProps","_mapValues","_","player","popin"],"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,OAAOA,wBAAwB,MAAM,UAAU;AAC/C,OAAOC,yBAAyB,MAAM,eAAe;AAErD,MAAMC,WAAW,GAAGA,CAACC,OAAO,EAAEC,QAAQ,KAAK;EACzC,OAAOC,KAAA,CACLC,KAAK,IAAIC,eAAe,IAAIA,eAAe,CAACD,KAAK,CAAC,EAClDE,UAAA,CAAAC,CAAA,EAAc;IACZC,MAAM,EAAEV,wBAAwB,CAACG,OAAO,EAAEC,QAAQ,CAAC;IACnDO,KAAK,EAAEV,yBAAyB,CAACG,QAAQ;EAC3C,CAAC,CACH,CAAC;AACH,CAAC;AAED,eAAeF,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"slide.js","names":["getCurrentSlide","getLives","hideTourguide","isTourguideEligible","setTourguideStep","trackTourguideCompleted","trackTourguideDismissed","trackTourguideStarted","trackTourguideStepViewed","createPlayerStateToProps","mapStateToErrorPopinProps","TOUR_GROUP","createTutorialSteps","translate","ref","target","title","content","order","group","tourguideStateToProps","state","options","store","slide","hasMedia","_pipe","_get","_size","hasClue","Boolean","hide","livesHidden","tourguideState","tourguideVisible","visible","tourguideStep","step","tourguideForceStart","forceStart","canShowHelp","multiLangOptions","multiLang","canShowLang","stepsForTour","_filter","_map","_cloneDeep","getStepTracking","stepIndex","totalSteps","length","isValidIndex","stepRef","stepNumber","steps","autoStart","startStep","onStart","dispatch","onStepChange","onExit","onFinish","closeButton","nextLabel","prevLabel","finishLabel","targetPadding","showStepDots","keyboardControls","exitOnEscape","exitOnClickOutside","debug","completeOnFinish","rememberStep","playerProps","errorPopinStateToProps","playerStateToProps","player","tourguide","popin"],"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,SACEA,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,mBAAmB,EACnBC,gBAAgB,EAChBC,uBAAuB,EACvBC,uBAAuB,EACvBC,qBAAqB,EACrBC,wBAAwB,QACnB,4BAA4B;AAEnC,OAAOC,wBAAwB,MAAM,UAAU;AAC/C,OAAOC,yBAAyB,MAAM,eAAe;AAErD,MAAMC,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,OAAO,EAAEJ,SAAS,CAAC,0BAA0B,CAAC;EAC9CK,KAAK,EAAE,CAAC;EACRC,KAAK,EAAER;AACT,CAAC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AAC;MAC1CsD,aAAa,EAAE,CAAC;MAChBC,YAAY,EAAE,KAAK;MACnBC,gBAAgB,EAAE,IAAI;MACtBC,YAAY,EAAE,IAAI;MAClBC,kBAAkB,EAAE,IAAI;MACxBC,KAAK,EAAE,KAAK;MACZC,gBAAgB,EAAE,IAAI;MACtBC,YAAY,EAAE;IAChB;EACF,CAAC;AACH,CAAC;AAED,MAAMC,WAAW,GAAGA,CAACrD,OAAO,EAAEC,KAAK,KAAK;EACtC,MAAMqD,sBAAsB,GAAGlE,yBAAyB,CAAC;IAACiD,QAAQ,EAAEpC,KAAK,CAACoC;EAAQ,CAAC,CAAC;EACpF,MAAMkB,kBAAkB,GAAGpE,wBAAwB,CAACa,OAAO,EAAEC,KAAK,CAAC;EAEnE,OAAOF,KAAK,IAAI;IACd,OAAO;MACLyD,MAAM,EAAED,kBAAkB,CAACxD,KAAK,CAAC;MACjC0D,SAAS,EAAE3D,qBAAqB,CAACC,KAAK,EAAEC,OAAO,EAAEC,KAAK,CAAC;MACvDyD,KAAK,EAAEJ,sBAAsB,CAACvD,KAAK;IACrC,CAAC;EACH,CAAC;AACH,CAAC;AAED,eAAesD,WAAW","ignoreList":[]}
@@ -4,10 +4,12 @@ import _identity from "lodash/fp/identity";
4
4
  import _set from "lodash/fp/set";
5
5
  import test from 'ava';
6
6
  import { mockTranslate } from '@coorpacademy/translate';
7
+ import { SHOW_TOURGUIDE } from '@coorpacademy/player-store';
7
8
  import createHeader from '../header';
8
9
  import basicSlide from './fixtures/slides/basic';
9
10
  const options = {
10
- translate: mockTranslate
11
+ translate: mockTranslate,
12
+ mode: 'scorm'
11
13
  };
12
14
  const store = {
13
15
  dispatch: _identity
@@ -126,4 +128,161 @@ test('should set lives to null if lives are disabled in the progression', t => {
126
128
  const props = headerProps(state);
127
129
  t.is(props.lives, false);
128
130
  });
131
+ test('content click should dispatch back', t => {
132
+ const calls = [];
133
+ const dispatch = action => {
134
+ calls.push(action);
135
+ return action;
136
+ };
137
+ const headerWithDispatch = createHeader(options, {
138
+ dispatch
139
+ });
140
+ const ui = {
141
+ current: {
142
+ progressionId: 'basic'
143
+ },
144
+ route: {
145
+ basic: 'answer'
146
+ }
147
+ };
148
+ const state = {
149
+ data,
150
+ ui
151
+ };
152
+ const props = headerWithDispatch(state);
153
+ props.content.onClick();
154
+ t.is(calls.length, 1);
155
+ t.is(typeof calls[0], 'function');
156
+ });
157
+ test('should expose help action when eligible', t => {
158
+ const ui = {
159
+ current: {
160
+ progressionId: 'basic'
161
+ },
162
+ route: {
163
+ basic: 'answer'
164
+ }
165
+ };
166
+ const state = {
167
+ data,
168
+ ui
169
+ };
170
+ const props = headerProps(state);
171
+ t.truthy(props.help);
172
+ t.is(props.help.title, '__Help');
173
+ });
174
+ test('should not expose help action when adaptive', t => {
175
+ const ui = {
176
+ current: {
177
+ progressionId: 'basic'
178
+ },
179
+ route: {
180
+ basic: 'answer'
181
+ }
182
+ };
183
+ const adaptiveData = _set(['contents', 'chapter', 'entities', '1.B2', 'isConditional'], true, data);
184
+ const state = {
185
+ data: adaptiveData,
186
+ ui
187
+ };
188
+ const props = headerProps(state);
189
+ t.is(props.help, null);
190
+ });
191
+ test('help click should dispatch route change and show action when not on question tab', t => {
192
+ const calls = [];
193
+ const dispatch = action => {
194
+ calls.push(action);
195
+ return action;
196
+ };
197
+ const headerWithDispatch = createHeader(options, {
198
+ dispatch
199
+ });
200
+ const ui = {
201
+ current: {
202
+ progressionId: 'basic'
203
+ },
204
+ route: {
205
+ basic: 'clue'
206
+ }
207
+ };
208
+ const state = {
209
+ data,
210
+ ui
211
+ };
212
+ const props = headerWithDispatch(state);
213
+ props.help.onClick();
214
+ t.is(calls.length, 2);
215
+ t.is(typeof calls[0], 'function');
216
+ t.is(calls[1].type, SHOW_TOURGUIDE);
217
+ });
218
+ test('help click should only show when already on question tab', t => {
219
+ const calls = [];
220
+ const dispatch = action => {
221
+ calls.push(action);
222
+ return action;
223
+ };
224
+ const headerWithDispatch = createHeader(options, {
225
+ dispatch
226
+ });
227
+ const ui = {
228
+ current: {
229
+ progressionId: 'basic'
230
+ },
231
+ route: {
232
+ basic: 'answer'
233
+ }
234
+ };
235
+ const state = {
236
+ data,
237
+ ui
238
+ };
239
+ const props = headerWithDispatch(state);
240
+ props.help.onClick();
241
+ t.is(calls.length, 1);
242
+ t.is(calls[0].type, SHOW_TOURGUIDE);
243
+ });
244
+ test('header uses default options when none provided', t => {
245
+ const dispatch = _identity;
246
+ const headerWithDefaults = createHeader(undefined, {
247
+ dispatch
248
+ });
249
+ const ui = {
250
+ current: {
251
+ progressionId: 'basic'
252
+ },
253
+ route: {
254
+ basic: 'answer'
255
+ }
256
+ };
257
+ const state = {
258
+ data,
259
+ ui
260
+ };
261
+ const props = headerWithDefaults(state);
262
+ t.is(props.mode, 'default');
263
+ });
264
+ test('help labels fall back to raw key when translate is missing', t => {
265
+ const dispatch = _identity;
266
+ const headerWithDefaults = createHeader({
267
+ mode: 'scorm'
268
+ }, {
269
+ dispatch
270
+ });
271
+ const ui = {
272
+ current: {
273
+ progressionId: 'basic'
274
+ },
275
+ route: {
276
+ basic: 'answer'
277
+ }
278
+ };
279
+ const state = {
280
+ data,
281
+ ui
282
+ };
283
+ const props = headerWithDefaults(state);
284
+ t.truthy(props.help);
285
+ t.is(props.help.title, 'Help');
286
+ t.is(props.help.ariaLabel, 'Help');
287
+ });
129
288
  //# sourceMappingURL=header.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"header.js","names":["test","mockTranslate","createHeader","basicSlide","options","translate","store","dispatch","_identity","headerProps","createProgression","slide","engine","ref","version","content","type","state","nextContent","_id","lives","livesDisabled","step","current","viewedResources","data","contents","chapter","entities","name","level","chapterIds","chapter_id","progressions","basic","t","ui","progressionId","props","deepEqual","count","_set","_omit","title","_pipe","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":";;;;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AAG7B,WAAW,CAACQ,KAAK,CAAC;EAEhCkB,CAAC,CAACI,SAAS,CAACD,KAAK,CAACO,UAAU,EAAE;IAC5BF,KAAK,EAAE,YAAY;IACnBG,OAAO,EAAE;EACX,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF9C,IAAI,CAAC,mEAAmE,EAAEmC,CAAC,IAAI;EAC7E,MAAMC,EAAE,GAAG;IAACb,OAAO,EAAE;MAACc,aAAa,EAAE;IAAO;EAAC,CAAC;EAC9C,MAAMpB,KAAK,GAAG;IAACQ,IAAI,EAAEgB,IAAA,CAAI,iDAAiD,EAAE,IAAI,EAAEhB,IAAI,CAAC;IAAEW;EAAE,CAAC;EAC5F,MAAME,KAAK,GAAG7B,WAAW,CAACQ,KAAK,CAAC;EAEhCkB,CAAC,CAACY,EAAE,CAACT,KAAK,CAAClB,KAAK,EAAE,KAAK,CAAC;AAC1B,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"header.js","names":["test","mockTranslate","SHOW_TOURGUIDE","createHeader","basicSlide","options","translate","mode","store","dispatch","_identity","headerProps","createProgression","slide","engine","ref","version","content","type","state","nextContent","_id","lives","livesDisabled","step","current","viewedResources","data","contents","chapter","entities","name","level","chapterIds","chapter_id","progressions","basic","t","ui","progressionId","props","deepEqual","count","_set","_omit","title","_pipe","subcontent","details","is","calls","action","push","headerWithDispatch","route","onClick","length","truthy","help","adaptiveData","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\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,CAACzC,KAAK,CAAC;EAEvCkB,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,CAACI,SAAS,EAAE,MAAM,CAAC;AACpC,CAAC,CAAC","ignoreList":[]}
@@ -4,13 +4,15 @@ import test from 'ava';
4
4
  import mapStateToErrorPopinProps from '../error-popin';
5
5
  test('should return error popin props if any call fails', t => {
6
6
  t.plan(2);
7
- global.window = {
8
- location: {
7
+ Object.defineProperty(global.window, 'location', {
8
+ value: {
9
9
  reload: () => {
10
10
  t.pass();
11
11
  }
12
- }
13
- };
12
+ },
13
+ // Allow redefinition across tests; jsdom's location is non-configurable by default.
14
+ configurable: true
15
+ });
14
16
  const props = mapStateToErrorPopinProps({
15
17
  dispatch: _identity
16
18
  })({
@@ -36,13 +38,15 @@ test('should return error popin props if any call fails', t => {
36
38
  });
37
39
  test('should return error popin props if content calls fail', t => {
38
40
  t.plan(2);
39
- global.window = {
40
- location: {
41
+ Object.defineProperty(global.window, 'location', {
42
+ value: {
41
43
  reload: () => {
42
44
  t.pass();
43
45
  }
44
- }
45
- };
46
+ },
47
+ // Allow redefinition across tests; jsdom's location is non-configurable by default.
48
+ configurable: true
49
+ });
46
50
  const props = mapStateToErrorPopinProps({
47
51
  dispatch: _identity
48
52
  })({
@@ -1 +1 @@
1
- {"version":3,"file":"popin-error.js","names":["test","mapStateToErrorPopinProps","t","plan","global","window","location","reload","pass","props","dispatch","_identity","data","progressions","isFailure","deepEqual","_omit","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 global.window = {\n location: {\n reload: () => {\n t.pass();\n }\n }\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 global.window = {\n location: {\n reload: () => {\n t.pass();\n }\n }\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,OAAOA,IAAI,MAAM,KAAK;AAItB,OAAOC,yBAAyB,MAAM,gBAAgB;AAEtDD,IAAI,CAAC,mDAAmD,EAAEE,CAAC,IAAI;EAC7DA,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC;EACTC,MAAM,CAACC,MAAM,GAAG;IACdC,QAAQ,EAAE;MACRC,MAAM,EAAEA,CAAA,KAAM;QACZL,CAAC,CAACM,IAAI,CAAC,CAAC;MACV;IACF;EACF,CAAC;EACD,MAAMC,KAAK,GAAGR,yBAAyB,CAAC;IAACS,QAAQ,EAAAC;EAAU,CAAC,CAAC,CAAC;IAC5DC,IAAI,EAAE;MACJC,YAAY,EAAE;QACZC,SAAS,EAAE;MACb;IACF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AqC,EAAEE,CAAC,IAAI;EAC/C,MAAMO,KAAK,GAAGR,yBAAyB,CAAC;IAACS,QAAQ,EAAAC;EAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;EAEjET,CAAC,CAAC0B,EAAE,CAACnB,KAAK,EAAEoB,SAAS,CAAC;AACxB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"popin-error.js","names":["test","mapStateToErrorPopinProps","t","plan","Object","defineProperty","global","window","value","reload","pass","configurable","props","dispatch","_identity","data","progressions","isFailure","deepEqual","_omit","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,OAAOA,IAAI,MAAM,KAAK;AAItB,OAAOC,yBAAyB,MAAM,gBAAgB;AAEtDD,IAAI,CAAC,mDAAmD,EAAEE,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,GAAGX,yBAAyB,CAAC;IAACY,QAAQ,EAAAC;EAAU,CAAC,CAAC,CAAC;IAC5DC,IAAI,EAAE;MACJC,YAAY,EAAE;QACZC,SAAS,EAAE;MACb;IACF;EACF,CAAC,CAAC;EAEFf,CAAC,CAACgB,SAAS,CAACC,KAAA,CAAK,2BAA2B,EAAEP,KAAK,CAAC,EAAE;IACpDQ,OAAO,EAAE,kCAAkC;IAC3CC,IAAI,EAAE,cAAc;IACpBC,IAAI,EAAE,OAAO;IACbC,eAAe,EAAE,sCAAsC;IACvDC,WAAW,EAAE;MACXC,WAAW,EAAE,IAAI;MACjBC,KAAK,EAAE,QAAQ;MACfC,IAAI,EAAE,SAAS;MACf,YAAY,EAAE;IAChB;EACF,CAAC,CAAC;EACFf,KAAK,CAACY,WAAW,CAACI,aAAa,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF5B,IAAI,CAAC,uDAAuD,EAAEE,CAAC,IAAI;EACjEA,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC;EACTC,MAAM,CA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