@coorpacademy/app-review 0.0.21-alpha.8 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/actions/courses.d.ts +0 -1
- package/es/actions/{api → data}/is-fetching.d.ts +0 -1
- package/{lib/actions/api → es/actions/data}/validate-slide.d.ts +0 -1
- package/es/actions/finished-slides.d.ts +0 -1
- package/es/actions/index.d.ts +0 -1
- package/es/actions/navigation.d.ts +0 -1
- package/es/actions/review-status.d.ts +0 -1
- package/es/actions/slides.d.ts +0 -1
- package/es/actions/step-items.d.ts +0 -1
- package/es/actions/token.d.ts +0 -1
- package/es/common/index.d.ts +1 -1
- package/es/common/index.js +1 -0
- package/es/configure-store.d.ts +2 -3
- package/es/configure-store.js +3 -9
- package/es/fixtures/qcm-slide.d.ts +2 -0
- package/es/fixtures/qcm-slide.js +29 -0
- package/es/{temp-fixture.d.ts → fixtures/temp-fixture.d.ts} +1 -2
- package/es/helpers/css-register.js +2 -0
- package/es/index.d.ts +1 -3
- package/es/index.js +43 -27
- package/es/index.test.js +52 -0
- package/es/middlewares/on-start-app.d.ts +0 -1
- package/es/middlewares/on-start-app.js +2 -0
- package/es/reducers/courses.d.ts +0 -1
- package/es/reducers/data.d.ts +7 -0
- package/es/reducers/{api.js → data.js} +15 -8
- package/es/reducers/finished-slides.d.ts +1 -2
- package/es/reducers/finished-slides.js +17 -7
- package/es/reducers/index.d.ts +9 -14
- package/es/reducers/index.js +7 -6
- package/es/reducers/navigation.d.ts +0 -1
- package/es/reducers/navigation.js +1 -1
- package/es/reducers/review-status.d.ts +0 -1
- package/es/reducers/slides.d.ts +1 -2
- package/es/reducers/slides.js +37 -25
- package/es/reducers/step-items.d.ts +1 -2
- package/es/reducers/step-items.js +19 -12
- package/es/reducers/token.d.ts +4 -7
- package/es/reducers/token.js +3 -14
- package/es/services/fetch-demo.d.ts +0 -1
- package/es/services/fetch-demo.test.d.ts +0 -1
- package/es/services/fetch-responses.d.ts +0 -1
- package/es/services/fetch.mocks.d.ts +0 -1
- package/es/types/common.d.ts +0 -1
- package/es/types/data/index.d.ts +14 -0
- package/es/types/data/index.js +1 -0
- package/es/types/dispatchers.d.ts +1 -2
- package/es/types/finished-slides.d.ts +4 -2
- package/es/types/review-status.d.ts +0 -1
- package/es/types/slides.d.ts +4 -2
- package/es/types/states.d.ts +1 -3
- package/es/types/step-items.d.ts +4 -2
- package/es/types/store-state.d.ts +10 -10
- package/es/types/utils.d.ts +0 -1
- package/es/types/views.d.ts +9 -3
- package/lib/actions/courses.d.ts +0 -1
- package/lib/actions/{api → data}/is-fetching.d.ts +0 -1
- package/{es/actions/api → lib/actions/data}/validate-slide.d.ts +0 -1
- package/lib/actions/finished-slides.d.ts +0 -1
- package/lib/actions/index.d.ts +0 -1
- package/lib/actions/navigation.d.ts +0 -1
- package/lib/actions/review-status.d.ts +0 -1
- package/lib/actions/slides.d.ts +0 -1
- package/lib/actions/step-items.d.ts +0 -1
- package/lib/actions/token.d.ts +0 -1
- package/lib/common/index.d.ts +1 -1
- package/lib/common/index.js +1 -0
- package/lib/configure-store.d.ts +2 -3
- package/lib/configure-store.js +10 -66
- package/lib/fixtures/qcm-slide.d.ts +2 -0
- package/lib/fixtures/qcm-slide.js +29 -0
- package/lib/{temp-fixture.d.ts → fixtures/temp-fixture.d.ts} +1 -2
- package/lib/helpers/css-register.d.ts +1 -0
- package/lib/helpers/css-register.js +2 -0
- package/lib/index.d.ts +1 -3
- package/lib/index.js +52 -52
- package/lib/index.test.d.ts +1 -0
- package/lib/index.test.js +160 -0
- package/lib/middlewares/on-start-app.d.ts +0 -1
- package/lib/middlewares/on-start-app.js +2 -0
- package/lib/reducers/courses.d.ts +0 -1
- package/lib/reducers/courses.js +1 -17
- package/lib/reducers/data.d.ts +7 -0
- package/lib/reducers/{api.js → data.js} +15 -8
- package/lib/reducers/finished-slides.d.ts +1 -2
- package/lib/reducers/finished-slides.js +28 -45
- package/lib/reducers/index.d.ts +9 -14
- package/lib/reducers/index.js +7 -6
- package/lib/reducers/navigation.d.ts +0 -1
- package/lib/reducers/navigation.js +3 -19
- package/lib/reducers/review-status.d.ts +0 -1
- package/lib/reducers/slides.d.ts +1 -2
- package/lib/reducers/slides.js +58 -106
- package/lib/reducers/step-items.d.ts +1 -2
- package/lib/reducers/step-items.js +21 -52
- package/lib/reducers/token.d.ts +4 -7
- package/lib/reducers/token.js +3 -15
- package/lib/services/fetch-demo.d.ts +0 -1
- package/lib/services/fetch-demo.test.d.ts +0 -1
- package/lib/services/fetch-responses.d.ts +0 -1
- package/lib/services/fetch.mocks.d.ts +0 -1
- package/lib/types/common.d.ts +0 -1
- package/lib/types/data/index.d.ts +14 -0
- package/lib/types/data/index.js +1 -0
- package/lib/types/dispatchers.d.ts +1 -2
- package/lib/types/finished-slides.d.ts +4 -2
- package/lib/types/review-status.d.ts +0 -1
- package/lib/types/slides.d.ts +4 -2
- package/lib/types/states.d.ts +1 -3
- package/lib/types/step-items.d.ts +4 -2
- package/lib/types/store-state.d.ts +10 -10
- package/lib/types/utils.d.ts +0 -1
- package/lib/types/views.d.ts +9 -3
- package/package.json +10 -7
- package/src/common/index.ts +2 -0
- package/src/configure-store.ts +10 -20
- package/src/fixtures/qcm-slide.ts +31 -0
- package/src/{temp-fixture.ts → fixtures/temp-fixture.ts} +1 -1
- package/src/helpers/css-modules-require-hook.d.ts +4 -0
- package/src/helpers/css-register.ts +3 -0
- package/src/index.test.tsx +82 -0
- package/src/index.tsx +48 -34
- package/src/middlewares/on-start-app.ts +2 -0
- package/src/reducers/{api.ts → data.ts} +17 -14
- package/src/reducers/finished-slides.ts +22 -7
- package/src/reducers/index.ts +8 -6
- package/src/reducers/navigation.ts +1 -1
- package/src/reducers/slides.ts +38 -25
- package/src/reducers/step-items.ts +22 -12
- package/src/reducers/token.ts +5 -17
- package/src/types/data/index.ts +16 -0
- package/src/types/dispatchers.ts +1 -1
- package/src/types/finished-slides.ts +5 -2
- package/src/types/globals.d.ts +6 -0
- package/src/types/slides.ts +6 -3
- package/src/types/states.ts +1 -2
- package/src/types/step-items.ts +4 -1
- package/src/types/store-state.ts +11 -11
- package/src/types/views.tsx +9 -2
- package/es/actions/api/is-fetching.d.ts.map +0 -1
- package/es/actions/api/validate-slide.d.ts.map +0 -1
- package/es/actions/courses.d.ts.map +0 -1
- package/es/actions/finished-slides.d.ts.map +0 -1
- package/es/actions/index.d.ts.map +0 -1
- package/es/actions/navigation.d.ts.map +0 -1
- package/es/actions/review-status.d.ts.map +0 -1
- package/es/actions/slides.d.ts.map +0 -1
- package/es/actions/step-items.d.ts.map +0 -1
- package/es/actions/token.d.ts.map +0 -1
- package/es/common/index.d.ts.map +0 -1
- package/es/configure-store.d.ts.map +0 -1
- package/es/index.d.ts.map +0 -1
- package/es/middlewares/on-start-app.d.ts.map +0 -1
- package/es/reducers/api.d.ts +0 -12
- package/es/reducers/api.d.ts.map +0 -1
- package/es/reducers/courses.d.ts.map +0 -1
- package/es/reducers/finished-slides.d.ts.map +0 -1
- package/es/reducers/index.d.ts.map +0 -1
- package/es/reducers/navigation.d.ts.map +0 -1
- package/es/reducers/review-status.d.ts.map +0 -1
- package/es/reducers/slides.d.ts.map +0 -1
- package/es/reducers/step-items.d.ts.map +0 -1
- package/es/reducers/token.d.ts.map +0 -1
- package/es/services/fetch-demo.d.ts.map +0 -1
- package/es/services/fetch-demo.test.d.ts.map +0 -1
- package/es/services/fetch-responses.d.ts.map +0 -1
- package/es/services/fetch.mocks.d.ts.map +0 -1
- package/es/temp-fixture.d.ts.map +0 -1
- package/es/types/api/index.d.ts +0 -16
- package/es/types/api/index.d.ts.map +0 -1
- package/es/types/common.d.ts.map +0 -1
- package/es/types/dispatchers.d.ts.map +0 -1
- package/es/types/finished-slides.d.ts.map +0 -1
- package/es/types/review-status.d.ts.map +0 -1
- package/es/types/slides.d.ts.map +0 -1
- package/es/types/states.d.ts.map +0 -1
- package/es/types/step-items.d.ts.map +0 -1
- package/es/types/store-state.d.ts.map +0 -1
- package/es/types/utils.d.ts.map +0 -1
- package/es/types/views.d.ts.map +0 -1
- package/lib/actions/api/is-fetching.d.ts.map +0 -1
- package/lib/actions/api/validate-slide.d.ts.map +0 -1
- package/lib/actions/courses.d.ts.map +0 -1
- package/lib/actions/finished-slides.d.ts.map +0 -1
- package/lib/actions/index.d.ts.map +0 -1
- package/lib/actions/navigation.d.ts.map +0 -1
- package/lib/actions/review-status.d.ts.map +0 -1
- package/lib/actions/slides.d.ts.map +0 -1
- package/lib/actions/step-items.d.ts.map +0 -1
- package/lib/actions/token.d.ts.map +0 -1
- package/lib/common/index.d.ts.map +0 -1
- package/lib/configure-store.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/middlewares/on-start-app.d.ts.map +0 -1
- package/lib/reducers/api.d.ts +0 -12
- package/lib/reducers/api.d.ts.map +0 -1
- package/lib/reducers/courses.d.ts.map +0 -1
- package/lib/reducers/finished-slides.d.ts.map +0 -1
- package/lib/reducers/index.d.ts.map +0 -1
- package/lib/reducers/navigation.d.ts.map +0 -1
- package/lib/reducers/review-status.d.ts.map +0 -1
- package/lib/reducers/slides.d.ts.map +0 -1
- package/lib/reducers/step-items.d.ts.map +0 -1
- package/lib/reducers/token.d.ts.map +0 -1
- package/lib/services/fetch-demo.d.ts.map +0 -1
- package/lib/services/fetch-demo.test.d.ts.map +0 -1
- package/lib/services/fetch-responses.d.ts.map +0 -1
- package/lib/services/fetch.mocks.d.ts.map +0 -1
- package/lib/temp-fixture.d.ts.map +0 -1
- package/lib/types/api/index.d.ts +0 -16
- package/lib/types/api/index.d.ts.map +0 -1
- package/lib/types/common.d.ts.map +0 -1
- package/lib/types/dispatchers.d.ts.map +0 -1
- package/lib/types/finished-slides.d.ts.map +0 -1
- package/lib/types/review-status.d.ts.map +0 -1
- package/lib/types/slides.d.ts.map +0 -1
- package/lib/types/states.d.ts.map +0 -1
- package/lib/types/step-items.d.ts.map +0 -1
- package/lib/types/store-state.d.ts.map +0 -1
- package/lib/types/utils.d.ts.map +0 -1
- package/lib/types/views.d.ts.map +0 -1
- package/src/types/api/index.ts +0 -16
- /package/es/actions/{api → data}/is-fetching.js +0 -0
- /package/es/actions/{api → data}/validate-slide.js +0 -0
- /package/es/{temp-fixture.js → fixtures/temp-fixture.js} +0 -0
- /package/es/{types/api/index.js → helpers/css-register.d.ts} +0 -0
- /package/{lib/types/api/index.js → es/index.test.d.ts} +0 -0
- /package/lib/actions/{api → data}/is-fetching.js +0 -0
- /package/lib/actions/{api → data}/validate-slide.js +0 -0
- /package/lib/{temp-fixture.js → fixtures/temp-fixture.js} +0 -0
- /package/src/actions/{api → data}/is-fetching.ts +0 -0
- /package/src/actions/{api → data}/validate-slide.ts +0 -0
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { AppOptions } from './types/common';
|
|
1
|
+
import type { AppOptions } from './types/common';
|
|
3
2
|
declare const AppReview: ({ options }: {
|
|
4
3
|
options: AppOptions;
|
|
5
4
|
}) => JSX.Element;
|
|
@@ -9,4 +8,3 @@ declare global {
|
|
|
9
8
|
}
|
|
10
9
|
}
|
|
11
10
|
export default AppReview;
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -34,22 +34,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
38
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
39
|
-
if (!m) return o;
|
|
40
|
-
var i = m.call(o), r, ar = [], e;
|
|
41
|
-
try {
|
|
42
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
43
|
-
}
|
|
44
|
-
catch (error) { e = { error: error }; }
|
|
45
|
-
finally {
|
|
46
|
-
try {
|
|
47
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
48
|
-
}
|
|
49
|
-
finally { if (e) throw e.error; }
|
|
50
|
-
}
|
|
51
|
-
return ar;
|
|
52
|
-
};
|
|
53
37
|
import React, { useEffect, useState } from 'react';
|
|
54
38
|
import { connect, Provider } from 'react-redux';
|
|
55
39
|
import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
|
|
@@ -57,11 +41,11 @@ import configureStore from './configure-store';
|
|
|
57
41
|
import { navigateTo, navigateBack, startApp } from './actions/navigation';
|
|
58
42
|
import { updateSlidesOnNext, updateSlidesOnValidation } from './actions/slides';
|
|
59
43
|
import { getCurrentViewName } from './reducers/navigation';
|
|
60
|
-
import { congratsProps, correctionPopinProps } from './temp-fixture';
|
|
44
|
+
import { congratsProps, correctionPopinProps } from './fixtures/temp-fixture';
|
|
61
45
|
import { updateFinishedSlides } from './actions/finished-slides';
|
|
62
46
|
import { updateReviewStatus } from './actions/review-status';
|
|
63
47
|
import { updateStepItemsOnValidation, updateStepItemsOnNext } from './actions/step-items';
|
|
64
|
-
import { validateSlide } from './actions/
|
|
48
|
+
import { validateSlide } from './actions/data/validate-slide';
|
|
65
49
|
// -----------------------------------------------------------------------------
|
|
66
50
|
var mapDispatchToProps = {
|
|
67
51
|
navigateTo: navigateTo,
|
|
@@ -74,49 +58,65 @@ var mapDispatchToProps = {
|
|
|
74
58
|
updateStepItemsOnNext: updateStepItemsOnNext,
|
|
75
59
|
updateFinishedSlides: updateFinishedSlides
|
|
76
60
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
61
|
+
var mapStateToProps = function (state) {
|
|
62
|
+
return {
|
|
63
|
+
viewName: getCurrentViewName(state),
|
|
64
|
+
slides: {
|
|
65
|
+
headerProps: {
|
|
66
|
+
mode: '__revision_mode',
|
|
67
|
+
skillName: '__agility',
|
|
68
|
+
onQuitClick: function () {
|
|
69
|
+
// eslint-disable-next-line no-console
|
|
70
|
+
console.log('onQuitClick');
|
|
71
|
+
},
|
|
72
|
+
'aria-label': 'aria-header-wrapper',
|
|
73
|
+
closeButtonAriaLabel: 'aria-close-button'
|
|
74
|
+
},
|
|
75
|
+
slides: state.ui.slides,
|
|
76
|
+
validate: {
|
|
77
|
+
label: '__validate'
|
|
78
|
+
},
|
|
79
|
+
finishedSlides: state.ui.finishedSlides,
|
|
80
|
+
stepItems: state.ui.stepItems,
|
|
81
|
+
reviewStatus: state.ui.reviewStatus,
|
|
82
|
+
correctionPopinProps: correctionPopinProps,
|
|
83
|
+
congratsProps: congratsProps,
|
|
84
|
+
slideValidationResult: state.data.slideValidationResult
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
};
|
|
93
88
|
// Props = StaticProps && Dispatchers
|
|
94
89
|
var App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
|
|
95
90
|
// -----------------------------------------------------------------------------
|
|
96
91
|
var AppReview = function (_a) {
|
|
97
92
|
var options = _a.options;
|
|
98
|
-
var _b =
|
|
93
|
+
var _b = useState(null), store = _b[0], setStore = _b[1];
|
|
94
|
+
var _c = useState(false), appStarted = _c[0], setAppStarted = _c[1];
|
|
99
95
|
useEffect(function () {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return [
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
96
|
+
if (store) {
|
|
97
|
+
store.dispatch(startApp(options));
|
|
98
|
+
setAppStarted(true);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
var _configure = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
+
var _store;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0: return [4 /*yield*/, configureStore()];
|
|
106
|
+
case 1:
|
|
107
|
+
_store = _a.sent();
|
|
108
|
+
setStore(_store);
|
|
109
|
+
return [2 /*return*/];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}); };
|
|
113
|
+
_configure();
|
|
114
|
+
}
|
|
115
|
+
}, [options, store]);
|
|
116
|
+
if (!store || !appStarted)
|
|
116
117
|
return null;
|
|
117
118
|
return (React.createElement(Provider, { store: store },
|
|
118
119
|
React.createElement(App, null)));
|
|
119
120
|
};
|
|
120
|
-
// type Props = {options: AppOptions};
|
|
121
121
|
// -----------------------------------------------------------------------------
|
|
122
122
|
export default AppReview;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import browserEnv from 'browser-env';
|
|
38
|
+
import test from 'ava';
|
|
39
|
+
import React from 'react';
|
|
40
|
+
import { render, fireEvent, act } from '@testing-library/react';
|
|
41
|
+
import { slide } from './fixtures/qcm-slide';
|
|
42
|
+
import AppReview from '.';
|
|
43
|
+
browserEnv({ pretendToBeVisual: true });
|
|
44
|
+
var elementExists = function (foundElements) {
|
|
45
|
+
return foundElements && foundElements[0];
|
|
46
|
+
};
|
|
47
|
+
var sleep = function (msToSleep) {
|
|
48
|
+
return new Promise(function (resolve) {
|
|
49
|
+
setTimeout(resolve, msToSleep);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
var waitForChanges = function (msToWait) {
|
|
53
|
+
if (msToWait === void 0) { msToWait = 3000; }
|
|
54
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
55
|
+
return __generator(this, function (_a) {
|
|
56
|
+
switch (_a.label) {
|
|
57
|
+
case 0: return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
switch (_a.label) {
|
|
60
|
+
case 0: return [4 /*yield*/, sleep(msToWait)];
|
|
61
|
+
case 1:
|
|
62
|
+
_a.sent(); // wait *just* a little longer than the timeout in the component
|
|
63
|
+
return [2 /*return*/];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}); })];
|
|
67
|
+
case 1:
|
|
68
|
+
_a.sent();
|
|
69
|
+
return [2 /*return*/];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
var LIMIT = 5;
|
|
75
|
+
var clickAllSlides = function (t, container, accumulator) {
|
|
76
|
+
if (accumulator === void 0) { accumulator = 0; }
|
|
77
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
+
var validateButton, nextButton;
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
switch (_a.label) {
|
|
81
|
+
case 0:
|
|
82
|
+
if (accumulator === LIMIT)
|
|
83
|
+
return [2 /*return*/];
|
|
84
|
+
if (!(accumulator === 4)) return [3 /*break*/, 2];
|
|
85
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0: return [4 /*yield*/, sleep(1000)];
|
|
89
|
+
case 1:
|
|
90
|
+
_a.sent();
|
|
91
|
+
return [2 /*return*/];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}); })];
|
|
95
|
+
case 1:
|
|
96
|
+
_a.sent();
|
|
97
|
+
_a.label = 2;
|
|
98
|
+
case 2:
|
|
99
|
+
validateButton = container.querySelectorAll("[data-name=\"slide-validate-button-".concat(accumulator, "\"]"));
|
|
100
|
+
t.truthy(elementExists(validateButton));
|
|
101
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
switch (_a.label) {
|
|
104
|
+
case 0: return [4 /*yield*/, fireEvent.click(validateButton[0])];
|
|
105
|
+
case 1:
|
|
106
|
+
_a.sent();
|
|
107
|
+
return [2 /*return*/];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}); })];
|
|
111
|
+
case 3:
|
|
112
|
+
_a.sent();
|
|
113
|
+
nextButton = container.querySelectorAll("[data-name=\"next-question-button-".concat(accumulator, "\"]"));
|
|
114
|
+
t.truthy(elementExists(nextButton));
|
|
115
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
switch (_a.label) {
|
|
118
|
+
case 0: return [4 /*yield*/, fireEvent.click(nextButton[0])];
|
|
119
|
+
case 1:
|
|
120
|
+
_a.sent();
|
|
121
|
+
return [2 /*return*/];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}); })];
|
|
125
|
+
case 4:
|
|
126
|
+
_a.sent();
|
|
127
|
+
return [4 /*yield*/, clickAllSlides(t, container, accumulator + 1)];
|
|
128
|
+
case 5:
|
|
129
|
+
_a.sent();
|
|
130
|
+
return [2 /*return*/];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
var appOptions = {
|
|
136
|
+
token: process.env.API_TEST_TOKEN || '',
|
|
137
|
+
slide: slide
|
|
138
|
+
};
|
|
139
|
+
test('should validate all the slides (all correct scenario)', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
140
|
+
var container, wrapper, stackedSlidesContainer;
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
switch (_a.label) {
|
|
143
|
+
case 0:
|
|
144
|
+
t.plan(13);
|
|
145
|
+
container = render(React.createElement(AppReview, { options: appOptions, key: 0 })).container;
|
|
146
|
+
return [4 /*yield*/, waitForChanges(1000)];
|
|
147
|
+
case 1:
|
|
148
|
+
_a.sent();
|
|
149
|
+
wrapper = container.querySelector('[data-name="slides-revision-container"]');
|
|
150
|
+
t.truthy(wrapper);
|
|
151
|
+
stackedSlidesContainer = wrapper.querySelector('[data-name="stacked-slides-container"]');
|
|
152
|
+
t.truthy(stackedSlidesContainer);
|
|
153
|
+
return [4 /*yield*/, clickAllSlides(t, container)];
|
|
154
|
+
case 2:
|
|
155
|
+
_a.sent();
|
|
156
|
+
t.pass();
|
|
157
|
+
return [2 /*return*/];
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}); });
|
|
@@ -8,6 +8,8 @@ var onStartApp = function (_a) {
|
|
|
8
8
|
return function (next) {
|
|
9
9
|
return function (action) {
|
|
10
10
|
if (action.type === START_APP) {
|
|
11
|
+
// eslint-disable-next-line no-warning-comments
|
|
12
|
+
// TODO: fetchProgression + fetchSlide à partir de la progression passée dans les options de l'app
|
|
11
13
|
var slide = action.payload.slide;
|
|
12
14
|
if (slide) {
|
|
13
15
|
var token = action.payload.token;
|
package/lib/reducers/courses.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
1
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
2
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
3
|
if (ar || !(i in from)) {
|
|
@@ -31,7 +15,7 @@ var reducer = function (state, action) {
|
|
|
31
15
|
if (state === void 0) { state = initialState; }
|
|
32
16
|
switch (action.type) {
|
|
33
17
|
case RECEIVED_COURSE: {
|
|
34
|
-
return __spreadArray(__spreadArray([],
|
|
18
|
+
return __spreadArray(__spreadArray([], state, true), [action.payload], false);
|
|
35
19
|
}
|
|
36
20
|
default:
|
|
37
21
|
return state;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { StoreToken } from '../actions/token';
|
|
2
|
+
import { IsFetching } from '../actions/data/is-fetching';
|
|
3
|
+
import { ValidateSlide } from '../actions/data/validate-slide';
|
|
4
|
+
import { DataState } from '../types/data';
|
|
5
|
+
declare type ApiActions = IsFetching | ValidateSlide | StoreToken;
|
|
6
|
+
declare const data: (state: DataState, action: ApiActions) => DataState;
|
|
7
|
+
export default data;
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import getOr from 'lodash/fp/getOr';
|
|
2
2
|
import noop from 'lodash/fp/noop';
|
|
3
3
|
import set from 'lodash/fp/set';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { STORE_TOKEN } from '../actions/token';
|
|
5
|
+
import { IS_FETCHING_TRUE } from '../actions/data/is-fetching';
|
|
6
|
+
import { VALIDATE_SLIDE } from '../actions/data/validate-slide';
|
|
7
|
+
import { setToken } from './token';
|
|
6
8
|
var defaultState = {
|
|
7
|
-
|
|
9
|
+
isFetching: true,
|
|
10
|
+
slideValidationResult: null,
|
|
11
|
+
token: null
|
|
8
12
|
};
|
|
9
13
|
// eslint-disable-next-line default-param-last
|
|
10
|
-
var
|
|
14
|
+
var data = function (state, action) {
|
|
11
15
|
if (state === void 0) { state = defaultState; }
|
|
12
16
|
switch (action.type) {
|
|
17
|
+
case STORE_TOKEN: {
|
|
18
|
+
return setToken(action.payload, state);
|
|
19
|
+
}
|
|
13
20
|
case VALIDATE_SLIDE: {
|
|
14
|
-
var previousSlideNumber = getOr(-1, '
|
|
21
|
+
var previousSlideNumber = getOr(-1, 'slideValidationResult.slideNumber', state);
|
|
15
22
|
// hard coded for now
|
|
16
|
-
return set(
|
|
23
|
+
return set('slideValidationResult', {
|
|
17
24
|
slideNumber: previousSlideNumber + 1,
|
|
18
25
|
result: 'success',
|
|
19
26
|
// exitNode
|
|
@@ -58,7 +65,7 @@ var api = function (state, action) {
|
|
|
58
65
|
}, state);
|
|
59
66
|
}
|
|
60
67
|
case IS_FETCHING_TRUE: {
|
|
61
|
-
return set('
|
|
68
|
+
return set('isFetching', true, state);
|
|
62
69
|
}
|
|
63
70
|
// case VALIDATE_SLIDE_FAILURE: {
|
|
64
71
|
// return set('entities.isFetching', false, state);
|
|
@@ -67,4 +74,4 @@ var api = function (state, action) {
|
|
|
67
74
|
return state;
|
|
68
75
|
}
|
|
69
76
|
};
|
|
70
|
-
export default
|
|
77
|
+
export default data;
|
|
@@ -2,6 +2,5 @@ import { UpdateFinishedSlides } from '../actions/finished-slides';
|
|
|
2
2
|
import { FinishedSlides } from '../types/finished-slides';
|
|
3
3
|
export declare type State = FinishedSlides;
|
|
4
4
|
export declare const initialState: State;
|
|
5
|
-
declare const reducer: (state:
|
|
5
|
+
declare const reducer: (state: State, action: UpdateFinishedSlides) => State;
|
|
6
6
|
export default reducer;
|
|
7
|
-
//# sourceMappingURL=finished-slides.d.ts.map
|
|
@@ -1,57 +1,40 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
-
};
|
|
12
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
-
if (!m) return o;
|
|
15
|
-
var i = m.call(o), r, ar = [], e;
|
|
16
|
-
try {
|
|
17
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
-
}
|
|
19
|
-
catch (error) { e = { error: error }; }
|
|
20
|
-
finally {
|
|
21
|
-
try {
|
|
22
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
-
}
|
|
24
|
-
finally { if (e) throw e.error; }
|
|
25
|
-
}
|
|
26
|
-
return ar;
|
|
10
|
+
return t;
|
|
27
11
|
};
|
|
12
|
+
import forEach from 'lodash/fp/forEach';
|
|
28
13
|
import { UPDATE_FINISHED_SLIDES } from '../actions/finished-slides';
|
|
29
|
-
|
|
14
|
+
import { slideNumbers } from '../common';
|
|
15
|
+
var _forEach = forEach.convert({
|
|
16
|
+
cap: false
|
|
17
|
+
});
|
|
18
|
+
export var initialState = {
|
|
19
|
+
slideNumbers: slideNumbers
|
|
20
|
+
};
|
|
30
21
|
// -----------------------------------------------------------------------------
|
|
31
22
|
// eslint-disable-next-line default-param-last
|
|
32
23
|
var reducer = function (state, action) {
|
|
33
|
-
var e_1, _a;
|
|
34
24
|
if (state === void 0) { state = initialState; }
|
|
35
25
|
switch (action.type) {
|
|
36
26
|
case UPDATE_FINISHED_SLIDES: {
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
if (state_1_1 && !state_1_1.done && (_a = state_1.return)) _a.call(state_1);
|
|
50
|
-
}
|
|
51
|
-
finally { if (e_1) throw e_1.error; }
|
|
52
|
-
}
|
|
53
|
-
_state.set(slideNumber, value);
|
|
54
|
-
return _state;
|
|
27
|
+
var _slideNumbers = state.slideNumbers, rest = __rest(state, ["slideNumbers"]);
|
|
28
|
+
var _a = action.payload, slideNumber = _a.slideNumber, value = _a.value;
|
|
29
|
+
var _state_1 = {
|
|
30
|
+
slideNumbers: _slideNumbers
|
|
31
|
+
};
|
|
32
|
+
_forEach(function (finishedSlide, index) {
|
|
33
|
+
var previousValue = finishedSlide;
|
|
34
|
+
_state_1[index] = previousValue;
|
|
35
|
+
}, rest);
|
|
36
|
+
_state_1[slideNumber] = value;
|
|
37
|
+
return _state_1;
|
|
55
38
|
}
|
|
56
39
|
default:
|
|
57
40
|
return state;
|
package/lib/reducers/index.d.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
reviewStatus: import("./review-status").State;
|
|
12
|
-
slides: import("../types/slides").Slides;
|
|
13
|
-
stepItems: import("../types/step-items").StepItems;
|
|
14
|
-
token: string;
|
|
2
|
+
ui: import("redux").CombinedState<{
|
|
3
|
+
courses: import("./courses").State;
|
|
4
|
+
finishedSlides: import("../types/finished-slides").FinishedSlides;
|
|
5
|
+
navigation: import("../types/states").NavigationState;
|
|
6
|
+
reviewStatus: import("./review-status").State;
|
|
7
|
+
slides: import("../types/slides").Slides;
|
|
8
|
+
stepItems: import("../types/step-items").StepItems;
|
|
9
|
+
}>;
|
|
10
|
+
data: import("../types/data").DataState;
|
|
15
11
|
}>, import("redux").AnyAction>;
|
|
16
12
|
export default _default;
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/reducers/index.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { combineReducers } from 'redux';
|
|
2
|
-
import
|
|
2
|
+
import data from './data';
|
|
3
3
|
import courses from './courses';
|
|
4
4
|
import finishedSlides from './finished-slides';
|
|
5
5
|
import navigation from './navigation';
|
|
6
6
|
import reviewStatus from './review-status';
|
|
7
7
|
import slides from './slides';
|
|
8
8
|
import stepItems from './step-items';
|
|
9
|
-
|
|
10
|
-
export default combineReducers({
|
|
11
|
-
api: api,
|
|
9
|
+
var ui = combineReducers({
|
|
12
10
|
courses: courses,
|
|
13
11
|
finishedSlides: finishedSlides,
|
|
14
12
|
navigation: navigation,
|
|
15
13
|
reviewStatus: reviewStatus,
|
|
16
14
|
slides: slides,
|
|
17
|
-
stepItems: stepItems
|
|
18
|
-
|
|
15
|
+
stepItems: stepItems
|
|
16
|
+
});
|
|
17
|
+
export default combineReducers({
|
|
18
|
+
ui: ui,
|
|
19
|
+
data: data
|
|
19
20
|
});
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
1
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
2
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
3
|
if (ar || !(i in from)) {
|
|
@@ -33,10 +17,10 @@ var reducer = function (state, action) {
|
|
|
33
17
|
if (state === void 0) { state = initialState; }
|
|
34
18
|
switch (action.type) {
|
|
35
19
|
case NAVIGATE_TO: {
|
|
36
|
-
return __spreadArray(__spreadArray([],
|
|
20
|
+
return __spreadArray(__spreadArray([], state, true), [action.payload], false);
|
|
37
21
|
}
|
|
38
22
|
case NAVIGATE_BACK: {
|
|
39
|
-
var newState = __spreadArray([],
|
|
23
|
+
var newState = __spreadArray([], state, true);
|
|
40
24
|
newState.pop();
|
|
41
25
|
return newState;
|
|
42
26
|
}
|
|
@@ -46,7 +30,7 @@ var reducer = function (state, action) {
|
|
|
46
30
|
};
|
|
47
31
|
// -----------------------------------------------------------------------------
|
|
48
32
|
export var getCurrentViewName = function (appState) {
|
|
49
|
-
return appState.navigation[appState.navigation.length - 1];
|
|
33
|
+
return appState.ui.navigation[appState.ui.navigation.length - 1];
|
|
50
34
|
};
|
|
51
35
|
// -----------------------------------------------------------------------------
|
|
52
36
|
export default reducer;
|
package/lib/reducers/slides.d.ts
CHANGED
|
@@ -2,6 +2,5 @@ import { SlidesAction } from '../actions/slides';
|
|
|
2
2
|
import { Slides } from '../types/slides';
|
|
3
3
|
export declare type State = Slides;
|
|
4
4
|
export declare const initialState: State;
|
|
5
|
-
declare const reducer: (state:
|
|
5
|
+
declare const reducer: (state: State, action: SlidesAction) => State;
|
|
6
6
|
export default reducer;
|
|
7
|
-
//# sourceMappingURL=slides.d.ts.map
|