@coorpacademy/app-review 0.5.5 → 0.5.6-alpha.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/index.js +2 -1
- package/es/services/fetch-slides-to-review-by-skill-ref.d.ts +2 -0
- package/es/services/fetch-slides-to-review-by-skill-ref.js +8 -0
- package/es/services/index.js +2 -0
- package/es/test/index.test.js +2 -1
- package/es/test/util/services.mock.js +19 -1
- package/es/types/common.d.ts +5 -0
- package/lib/index.js +2 -1
- package/lib/services/fetch-slides-to-review-by-skill-ref.d.ts +2 -0
- package/lib/services/fetch-slides-to-review-by-skill-ref.js +52 -0
- package/lib/services/index.js +2 -0
- package/lib/test/index.test.js +2 -1
- package/lib/test/util/services.mock.js +19 -1
- package/lib/types/common.d.ts +5 -0
- package/package.json +3 -3
- package/src/index.tsx +2 -1
- package/src/services/fetch-slides-to-review-by-skill-ref.ts +18 -0
- package/src/services/index.ts +2 -0
- package/src/services/test/fetch-slides-to-review-by-skill-ref.test.ts +51 -0
- package/src/test/index.test.tsx +2 -1
- package/src/test/util/services.mock.ts +22 -2
- package/src/types/common.ts +10 -0
package/es/index.js
CHANGED
|
@@ -16,7 +16,8 @@ const ConnectedApp = ({ onQuitClick }) => {
|
|
|
16
16
|
const props = {
|
|
17
17
|
viewName: useSelector((state) => state.ui.navigation[state.ui.navigation.length - 1]),
|
|
18
18
|
slides: useSelector((state) => mapStateToSlidesProps(state, dispatch, onQuitClick)),
|
|
19
|
-
skills: useSelector((state) => mapStateToSkillsProps(state))
|
|
19
|
+
skills: useSelector((state) => mapStateToSkillsProps(state)),
|
|
20
|
+
onboarding: {}
|
|
20
21
|
};
|
|
21
22
|
return React.createElement(AppReviewTemplate, { ...props });
|
|
22
23
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
import { toJSON } from './tools/fetch-responses';
|
|
4
|
+
export const fetchSlidesToReviewBySkillRef = async (url, token, skillRef) => {
|
|
5
|
+
const { user: userId } = decode(token);
|
|
6
|
+
const response = await crossFetch(`${url}/api/v1/review/users/${userId}/skills/${skillRef}/slide?limit=5&offset=0`);
|
|
7
|
+
return toJSON(response);
|
|
8
|
+
};
|
package/es/services/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { fetchCorrection } from './fetch-correction';
|
|
|
2
2
|
import { fetchRank } from './fetch-rank';
|
|
3
3
|
import { fetchSkills } from './fetch-skills';
|
|
4
4
|
import { fetchSlide } from './fetch-slide';
|
|
5
|
+
import { fetchSlidesToReviewBySkillRef } from './fetch-slides-to-review-by-skill-ref';
|
|
5
6
|
import { postAnswer } from './post-answer';
|
|
6
7
|
import { postProgression } from './post-progression';
|
|
7
8
|
export const getServices = () => ({
|
|
@@ -9,6 +10,7 @@ export const getServices = () => ({
|
|
|
9
10
|
fetchRank,
|
|
10
11
|
fetchSkills,
|
|
11
12
|
fetchSlide,
|
|
13
|
+
fetchSlidesToReviewBySkillRef,
|
|
12
14
|
postAnswer,
|
|
13
15
|
postProgression
|
|
14
16
|
});
|
package/es/test/index.test.js
CHANGED
|
@@ -39,7 +39,8 @@ const appOptions = {
|
|
|
39
39
|
token: process.env.API_TEST_TOKEN || '',
|
|
40
40
|
skillRef: 'skill_NJC0jFKoH',
|
|
41
41
|
services,
|
|
42
|
-
onQuitClick: identity
|
|
42
|
+
onQuitClick: identity,
|
|
43
|
+
url: process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006'
|
|
43
44
|
};
|
|
44
45
|
test('should show the loader while the app is fetching the data', async (t) => {
|
|
45
46
|
t.plan(2);
|
|
@@ -413,6 +413,23 @@ export const getChoicesCorrection = (ref, wrongChoice = false) => {
|
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
};
|
|
416
|
+
const fetchSlidesToReviewBySkillRefResponse = [
|
|
417
|
+
{
|
|
418
|
+
slideId: freeTextSlide._id
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
slideId: templateSlide._id
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
slideId: qcmDragSlide._id
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
slideId: qcmGraphicSlide._id
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
slideId: qcmSlide._id
|
|
431
|
+
}
|
|
432
|
+
];
|
|
416
433
|
export const services = {
|
|
417
434
|
fetchSkills: () => Promise.resolve(fetchSkillsResponse),
|
|
418
435
|
fetchSlide: ref => Promise.resolve({ ...getSlideFixture(ref), universalRef: ref, _id: ref }),
|
|
@@ -422,5 +439,6 @@ export const services = {
|
|
|
422
439
|
return Promise.resolve(get(currentSlide, postAnswerResponses));
|
|
423
440
|
},
|
|
424
441
|
fetchCorrection: ref => Promise.resolve(getChoicesCorrection(ref)),
|
|
425
|
-
fetchRank: () => Promise.resolve(fetchRankResponse)
|
|
442
|
+
fetchRank: () => Promise.resolve(fetchRankResponse),
|
|
443
|
+
fetchSlidesToReviewBySkillRef: () => Promise.resolve(fetchSlidesToReviewBySkillRefResponse)
|
|
426
444
|
};
|
package/es/types/common.d.ts
CHANGED
|
@@ -69,6 +69,9 @@ export declare type SlideFromAPI = {
|
|
|
69
69
|
type: 'chapter' | 'course';
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
+
export declare type SlideIdFromAPI = {
|
|
73
|
+
slideId: string;
|
|
74
|
+
};
|
|
72
75
|
export declare type Rank = {
|
|
73
76
|
rank: number;
|
|
74
77
|
};
|
|
@@ -131,6 +134,7 @@ export declare type Services = {
|
|
|
131
134
|
postAnswer(progression: ProgressionFromAPI, token: string, answer: string[]): Promise<ProgressionFromAPI>;
|
|
132
135
|
fetchCorrection(slideRef: string, token: string, progressionId: string, answer: string[]): Promise<CorrectionFromAPI | void>;
|
|
133
136
|
fetchRank(token: string): Promise<Rank>;
|
|
137
|
+
fetchSlidesToReviewBySkillRef(url: string, token: string, skillRef: string): Promise<SlideIdFromAPI[]>;
|
|
134
138
|
};
|
|
135
139
|
export declare type Options = {
|
|
136
140
|
services: Services;
|
|
@@ -140,6 +144,7 @@ export declare type AppOptions = {
|
|
|
140
144
|
skillRef?: string;
|
|
141
145
|
services: Services;
|
|
142
146
|
onQuitClick: Function;
|
|
147
|
+
url: string;
|
|
143
148
|
};
|
|
144
149
|
export declare type JWT = {
|
|
145
150
|
exp: number;
|
package/lib/index.js
CHANGED
|
@@ -28,7 +28,8 @@ var ConnectedApp = function (_a) {
|
|
|
28
28
|
var props = {
|
|
29
29
|
viewName: useSelector(function (state) { return state.ui.navigation[state.ui.navigation.length - 1]; }),
|
|
30
30
|
slides: useSelector(function (state) { return mapStateToSlidesProps(state, dispatch, onQuitClick); }),
|
|
31
|
-
skills: useSelector(function (state) { return mapStateToSkillsProps(state); })
|
|
31
|
+
skills: useSelector(function (state) { return mapStateToSkillsProps(state); }),
|
|
32
|
+
onboarding: {}
|
|
32
33
|
};
|
|
33
34
|
return React.createElement(AppReviewTemplate, __assign({}, props));
|
|
34
35
|
};
|
|
@@ -0,0 +1,52 @@
|
|
|
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 crossFetch from 'cross-fetch';
|
|
38
|
+
import decode from 'jwt-decode';
|
|
39
|
+
import { toJSON } from './tools/fetch-responses';
|
|
40
|
+
export var fetchSlidesToReviewBySkillRef = function (url, token, skillRef) { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
+
var userId, response;
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
switch (_a.label) {
|
|
44
|
+
case 0:
|
|
45
|
+
userId = decode(token).user;
|
|
46
|
+
return [4 /*yield*/, crossFetch("".concat(url, "/api/v1/review/users/").concat(userId, "/skills/").concat(skillRef, "/slide?limit=5&offset=0"))];
|
|
47
|
+
case 1:
|
|
48
|
+
response = _a.sent();
|
|
49
|
+
return [2 /*return*/, toJSON(response)];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}); };
|
package/lib/services/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { fetchCorrection } from './fetch-correction';
|
|
|
2
2
|
import { fetchRank } from './fetch-rank';
|
|
3
3
|
import { fetchSkills } from './fetch-skills';
|
|
4
4
|
import { fetchSlide } from './fetch-slide';
|
|
5
|
+
import { fetchSlidesToReviewBySkillRef } from './fetch-slides-to-review-by-skill-ref';
|
|
5
6
|
import { postAnswer } from './post-answer';
|
|
6
7
|
import { postProgression } from './post-progression';
|
|
7
8
|
export var getServices = function () { return ({
|
|
@@ -9,6 +10,7 @@ export var getServices = function () { return ({
|
|
|
9
10
|
fetchRank: fetchRank,
|
|
10
11
|
fetchSkills: fetchSkills,
|
|
11
12
|
fetchSlide: fetchSlide,
|
|
13
|
+
fetchSlidesToReviewBySkillRef: fetchSlidesToReviewBySkillRef,
|
|
12
14
|
postAnswer: postAnswer,
|
|
13
15
|
postProgression: postProgression
|
|
14
16
|
}); };
|
package/lib/test/index.test.js
CHANGED
|
@@ -134,7 +134,8 @@ var appOptions = {
|
|
|
134
134
|
token: process.env.API_TEST_TOKEN || '',
|
|
135
135
|
skillRef: 'skill_NJC0jFKoH',
|
|
136
136
|
services: services,
|
|
137
|
-
onQuitClick: identity
|
|
137
|
+
onQuitClick: identity,
|
|
138
|
+
url: process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006'
|
|
138
139
|
};
|
|
139
140
|
test('should show the loader while the app is fetching the data', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
140
141
|
var container, loader;
|
|
@@ -417,6 +417,23 @@ export var getChoicesCorrection = function (ref, wrongChoice) {
|
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
};
|
|
420
|
+
var fetchSlidesToReviewBySkillRefResponse = [
|
|
421
|
+
{
|
|
422
|
+
slideId: freeTextSlide._id
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
slideId: templateSlide._id
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
slideId: qcmDragSlide._id
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
slideId: qcmGraphicSlide._id
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
slideId: qcmSlide._id
|
|
435
|
+
}
|
|
436
|
+
];
|
|
420
437
|
export var services = {
|
|
421
438
|
fetchSkills: function () { return Promise.resolve(fetchSkillsResponse); },
|
|
422
439
|
fetchSlide: function (ref) { return Promise.resolve(__assign(__assign({}, getSlideFixture(ref)), { universalRef: ref, _id: ref })); },
|
|
@@ -426,5 +443,6 @@ export var services = {
|
|
|
426
443
|
return Promise.resolve(get(currentSlide, postAnswerResponses));
|
|
427
444
|
},
|
|
428
445
|
fetchCorrection: function (ref) { return Promise.resolve(getChoicesCorrection(ref)); },
|
|
429
|
-
fetchRank: function () { return Promise.resolve(fetchRankResponse); }
|
|
446
|
+
fetchRank: function () { return Promise.resolve(fetchRankResponse); },
|
|
447
|
+
fetchSlidesToReviewBySkillRef: function () { return Promise.resolve(fetchSlidesToReviewBySkillRefResponse); }
|
|
430
448
|
};
|
package/lib/types/common.d.ts
CHANGED
|
@@ -69,6 +69,9 @@ export declare type SlideFromAPI = {
|
|
|
69
69
|
type: 'chapter' | 'course';
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
+
export declare type SlideIdFromAPI = {
|
|
73
|
+
slideId: string;
|
|
74
|
+
};
|
|
72
75
|
export declare type Rank = {
|
|
73
76
|
rank: number;
|
|
74
77
|
};
|
|
@@ -131,6 +134,7 @@ export declare type Services = {
|
|
|
131
134
|
postAnswer(progression: ProgressionFromAPI, token: string, answer: string[]): Promise<ProgressionFromAPI>;
|
|
132
135
|
fetchCorrection(slideRef: string, token: string, progressionId: string, answer: string[]): Promise<CorrectionFromAPI | void>;
|
|
133
136
|
fetchRank(token: string): Promise<Rank>;
|
|
137
|
+
fetchSlidesToReviewBySkillRef(url: string, token: string, skillRef: string): Promise<SlideIdFromAPI[]>;
|
|
134
138
|
};
|
|
135
139
|
export declare type Options = {
|
|
136
140
|
services: Services;
|
|
@@ -140,6 +144,7 @@ export declare type AppOptions = {
|
|
|
140
144
|
skillRef?: string;
|
|
141
145
|
services: Services;
|
|
142
146
|
onQuitClick: Function;
|
|
147
|
+
url: string;
|
|
143
148
|
};
|
|
144
149
|
export declare type JWT = {
|
|
145
150
|
exp: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/app-review",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6-alpha.2+eed634ba0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.15.0"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"./package.json": "./package.json"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@coorpacademy/components": "10.24.
|
|
45
|
+
"@coorpacademy/components": "10.24.5-alpha.2+eed634ba0",
|
|
46
46
|
"@coorpacademy/redux-task": "1.1.6",
|
|
47
47
|
"cross-fetch": "^3.1.5",
|
|
48
48
|
"jwt-decode": "^3.1.2",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"webpack-cli": "^4.10.0",
|
|
78
78
|
"webpack-dev-server": "^4.11.1"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "eed634ba0e2edfffa5b5797dd6251d2e63128bda"
|
|
81
81
|
}
|
package/src/index.tsx
CHANGED
|
@@ -27,7 +27,8 @@ const ConnectedApp = ({onQuitClick}: {onQuitClick: Function}): JSX.Element => {
|
|
|
27
27
|
(state: StoreState) => state.ui.navigation[state.ui.navigation.length - 1]
|
|
28
28
|
),
|
|
29
29
|
slides: useSelector((state: StoreState) => mapStateToSlidesProps(state, dispatch, onQuitClick)),
|
|
30
|
-
skills: useSelector((state: StoreState) => mapStateToSkillsProps(state))
|
|
30
|
+
skills: useSelector((state: StoreState) => mapStateToSkillsProps(state)),
|
|
31
|
+
onboarding: {}
|
|
31
32
|
};
|
|
32
33
|
return <AppReviewTemplate {...props} />;
|
|
33
34
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
|
|
4
|
+
import {JWT, SlideIdFromAPI} from '../types/common';
|
|
5
|
+
import {toJSON} from './tools/fetch-responses';
|
|
6
|
+
|
|
7
|
+
export const fetchSlidesToReviewBySkillRef = async (
|
|
8
|
+
url: string,
|
|
9
|
+
token: string,
|
|
10
|
+
skillRef: string
|
|
11
|
+
): Promise<SlideIdFromAPI[]> => {
|
|
12
|
+
const {user: userId}: JWT = decode(token);
|
|
13
|
+
const response = await crossFetch(
|
|
14
|
+
`${url}/api/v1/review/users/${userId}/skills/${skillRef}/slide?limit=5&offset=0`
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
return toJSON<SlideIdFromAPI[]>(response);
|
|
18
|
+
};
|
package/src/services/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {fetchCorrection} from './fetch-correction';
|
|
|
3
3
|
import {fetchRank} from './fetch-rank';
|
|
4
4
|
import {fetchSkills} from './fetch-skills';
|
|
5
5
|
import {fetchSlide} from './fetch-slide';
|
|
6
|
+
import {fetchSlidesToReviewBySkillRef} from './fetch-slides-to-review-by-skill-ref';
|
|
6
7
|
import {postAnswer} from './post-answer';
|
|
7
8
|
import {postProgression} from './post-progression';
|
|
8
9
|
|
|
@@ -11,6 +12,7 @@ export const getServices = (): Services => ({
|
|
|
11
12
|
fetchRank,
|
|
12
13
|
fetchSkills,
|
|
13
14
|
fetchSlide,
|
|
15
|
+
fetchSlidesToReviewBySkillRef,
|
|
14
16
|
postAnswer,
|
|
15
17
|
postProgression
|
|
16
18
|
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import nock from 'nock';
|
|
3
|
+
import {fetchSlidesToReviewBySkillRef} from '../fetch-slides-to-review-by-skill-ref';
|
|
4
|
+
import {SlideIdFromAPI} from '../../types/common';
|
|
5
|
+
|
|
6
|
+
const url = process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006';
|
|
7
|
+
|
|
8
|
+
const result: SlideIdFromAPI[] = [
|
|
9
|
+
{
|
|
10
|
+
slideId: 'sli_6'
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
slideId: 'sli_7'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
slideId: 'sli_8'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
slideId: 'sli_9'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
slideId: 'sli_10'
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
test.before(() => {
|
|
27
|
+
nock(url)
|
|
28
|
+
.get('/api/v1/review/users/592d830b240b923f00bffba6/skills/_skill-ref/slide?limit=5&offset=0')
|
|
29
|
+
.reply(200, result);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test.after(() => {
|
|
33
|
+
nock.cleanAll();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('should fetch slides id with success', async t => {
|
|
37
|
+
const token = process.env.API_TEST_TOKEN || '';
|
|
38
|
+
const slidesId = await fetchSlidesToReviewBySkillRef(url, token, '_skill-ref');
|
|
39
|
+
t.deepEqual(result, slidesId);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('should reject if a bad token is passed', async t => {
|
|
43
|
+
const badToken = 'token is not a jwt';
|
|
44
|
+
const error = await t.throwsAsync(() =>
|
|
45
|
+
fetchSlidesToReviewBySkillRef(url, badToken, '_skill-ref')
|
|
46
|
+
);
|
|
47
|
+
t.is(
|
|
48
|
+
error?.message,
|
|
49
|
+
"Invalid token specified: Cannot read properties of undefined (reading 'replace')"
|
|
50
|
+
);
|
|
51
|
+
});
|
package/src/test/index.test.tsx
CHANGED
|
@@ -61,7 +61,8 @@ const appOptions: AppOptions = {
|
|
|
61
61
|
token: process.env.API_TEST_TOKEN || '',
|
|
62
62
|
skillRef: 'skill_NJC0jFKoH',
|
|
63
63
|
services,
|
|
64
|
-
onQuitClick: identity
|
|
64
|
+
onQuitClick: identity,
|
|
65
|
+
url: process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006'
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
test('should show the loader while the app is fetching the data', async t => {
|
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
ReviewContent,
|
|
12
12
|
ReviewEngine,
|
|
13
13
|
Services,
|
|
14
|
-
SlideFromAPI
|
|
14
|
+
SlideFromAPI,
|
|
15
|
+
SlideIdFromAPI
|
|
15
16
|
} from '../../types/common';
|
|
16
17
|
|
|
17
18
|
const content: ReviewContent = {
|
|
@@ -432,6 +433,24 @@ export const getChoicesCorrection = (ref: string, wrongChoice = false): Correcti
|
|
|
432
433
|
}
|
|
433
434
|
};
|
|
434
435
|
|
|
436
|
+
const fetchSlidesToReviewBySkillRefResponse: SlideIdFromAPI[] = [
|
|
437
|
+
{
|
|
438
|
+
slideId: freeTextSlide._id
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
slideId: templateSlide._id
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
slideId: qcmDragSlide._id
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
slideId: qcmGraphicSlide._id
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
slideId: qcmSlide._id
|
|
451
|
+
}
|
|
452
|
+
];
|
|
453
|
+
|
|
435
454
|
export const services: Services = {
|
|
436
455
|
fetchSkills: () => Promise.resolve(fetchSkillsResponse),
|
|
437
456
|
fetchSlide: ref => Promise.resolve({...getSlideFixture(ref), universalRef: ref, _id: ref}),
|
|
@@ -441,5 +460,6 @@ export const services: Services = {
|
|
|
441
460
|
return Promise.resolve(get(currentSlide, postAnswerResponses));
|
|
442
461
|
},
|
|
443
462
|
fetchCorrection: ref => Promise.resolve(getChoicesCorrection(ref)),
|
|
444
|
-
fetchRank: () => Promise.resolve(fetchRankResponse)
|
|
463
|
+
fetchRank: () => Promise.resolve(fetchRankResponse),
|
|
464
|
+
fetchSlidesToReviewBySkillRef: () => Promise.resolve(fetchSlidesToReviewBySkillRefResponse)
|
|
445
465
|
};
|
package/src/types/common.ts
CHANGED
|
@@ -82,6 +82,10 @@ export type SlideFromAPI = {
|
|
|
82
82
|
};
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
+
export type SlideIdFromAPI = {
|
|
86
|
+
slideId: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
85
89
|
export type Rank = {
|
|
86
90
|
rank: number;
|
|
87
91
|
};
|
|
@@ -164,6 +168,11 @@ export type Services = {
|
|
|
164
168
|
answer: string[]
|
|
165
169
|
): Promise<CorrectionFromAPI | void>;
|
|
166
170
|
fetchRank(token: string): Promise<Rank>;
|
|
171
|
+
fetchSlidesToReviewBySkillRef(
|
|
172
|
+
url: string,
|
|
173
|
+
token: string,
|
|
174
|
+
skillRef: string
|
|
175
|
+
): Promise<SlideIdFromAPI[]>;
|
|
167
176
|
};
|
|
168
177
|
|
|
169
178
|
export type Options = {
|
|
@@ -175,6 +184,7 @@ export type AppOptions = {
|
|
|
175
184
|
skillRef?: string;
|
|
176
185
|
services: Services;
|
|
177
186
|
onQuitClick: Function;
|
|
187
|
+
url: string;
|
|
178
188
|
};
|
|
179
189
|
|
|
180
190
|
export type JWT = {
|