musora-content-services 1.2.3 → 1.2.5
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/CHANGELOG.md +4 -0
- package/README.md +0 -0
- package/babel.config.cjs +0 -0
- package/docs/config.js.html +8 -11
- package/docs/index.html +2 -2
- package/docs/module-Config.html +29 -5
- package/docs/module-Railcontent-Services.html +376 -38
- package/docs/module-Sanity-Services.html +1132 -3781
- package/docs/railcontent.js.html +54 -9
- package/docs/sanity.js.html +172 -343
- package/jest.config.js +0 -0
- package/package.json +1 -1
- package/src/contentMetaData.js +1 -0
- package/src/contentTypeConfig.js +18 -6
- package/src/filterBuilder.js +0 -0
- package/src/index.d.ts +0 -28
- package/src/index.js +0 -28
- package/src/services/config.js +0 -0
- package/src/services/contentLikes.js +0 -0
- package/src/services/contentProgress.js +1 -1
- package/src/services/dataContext.js +0 -0
- package/src/services/lastUpdated.js +0 -0
- package/src/services/railcontent.js +0 -0
- package/src/services/sanity.js +1 -286
- package/src/services/userPermissions.js +0 -0
- package/test/contentLikes.test.js +0 -0
- package/test/initializeTests.js +0 -0
- package/test/lastUpdated.test.js +0 -0
- package/test/live/contentProgressLive.test.js +0 -0
- package/test/live/railcontentLive.test.js +0 -0
- package/test/localStorageMock.js +0 -0
- package/test/log.js +0 -0
- package/test/sanityQueryService.test.js +0 -99
- package/test/userPermissions.test.js +0 -0
- package/.yarnrc.yml +0 -1
package/src/services/sanity.js
CHANGED
|
@@ -183,107 +183,6 @@ export async function fetchRelatedSongs(brand, songId) {
|
|
|
183
183
|
return fetchSanity(query, false);
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
/**
|
|
187
|
-
* Fetch all songs for a specific brand with pagination and search options.
|
|
188
|
-
* @param {string} brand - The brand for which to fetch songs.
|
|
189
|
-
* @param {Object} params - Parameters for pagination, filtering, and sorting.
|
|
190
|
-
* @param {number} [params.page=1] - The page number for pagination.
|
|
191
|
-
* @param {number} [params.limit=10] - The number of songs per page.
|
|
192
|
-
* @param {string} [params.searchTerm=""] - The search term to filter songs by title or artist.
|
|
193
|
-
* @param {string} [params.sort="-published_on"] - The field to sort the songs by.
|
|
194
|
-
* @param {Array<string>} [params.includedFields=[]] - The fields to include in the query.
|
|
195
|
-
* @param {string} [params.groupBy=""] - The field to group the results by.
|
|
196
|
-
* @returns {Promise<Object|null>} - The fetched song data or null if not found.
|
|
197
|
-
*
|
|
198
|
-
* @example
|
|
199
|
-
* fetchAllSongs('drumeo', {
|
|
200
|
-
* page: 2,
|
|
201
|
-
* limit: 20,
|
|
202
|
-
* searchTerm: 'rock',
|
|
203
|
-
* sort: 'published_on',
|
|
204
|
-
* includedFields: ['difficulty', 'style'],
|
|
205
|
-
* groupBy: 'artist'
|
|
206
|
-
* })
|
|
207
|
-
* .then(result => console.log(result))
|
|
208
|
-
* .catch(error => console.error(error));
|
|
209
|
-
*/
|
|
210
|
-
export async function fetchAllSongs(brand, {
|
|
211
|
-
page = 1,
|
|
212
|
-
limit = 10,
|
|
213
|
-
searchTerm = "",
|
|
214
|
-
sort = "-published_on",
|
|
215
|
-
includedFields = [],
|
|
216
|
-
groupBy = ""
|
|
217
|
-
}) {
|
|
218
|
-
return fetchAll(brand, 'song', {page, limit, searchTerm, sort, includedFields, groupBy});
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Fetch filter options for a specific brand.
|
|
223
|
-
*
|
|
224
|
-
* @param {string} brand - The brand for which to fetch filter options.
|
|
225
|
-
* @returns {Promise<Object|null>} - A promise that resolves to an object containing filter options or null if not found.
|
|
226
|
-
*
|
|
227
|
-
* @example
|
|
228
|
-
* fetchSongFilterOptions('drumeo')
|
|
229
|
-
* .then(options => console.log(options))
|
|
230
|
-
* .catch(error => console.error(error));
|
|
231
|
-
*/
|
|
232
|
-
export async function fetchSongFilterOptions(brand) {
|
|
233
|
-
const query = `
|
|
234
|
-
{
|
|
235
|
-
"difficulty": [
|
|
236
|
-
{"type": "Introductory", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Introductory"]._id)},
|
|
237
|
-
{"type": "Beginner", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Beginner"]._id)},
|
|
238
|
-
{"type": "Intermediate", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Intermediate"]._id)},
|
|
239
|
-
{"type": "Advanced", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Advanced"]._id)},
|
|
240
|
-
{"type": "Expert", "count": count(*[_type == 'song' && brand == '${brand}' && difficulty_string == "Expert"]._id)}
|
|
241
|
-
],
|
|
242
|
-
"genre": *[_type == 'genre' && 'song' in filter_types] {
|
|
243
|
-
"type": name,
|
|
244
|
-
"count": count(*[_type == 'song' && brand == '${brand}' && references(^._id)]._id)
|
|
245
|
-
},
|
|
246
|
-
"instrumentless": [
|
|
247
|
-
{"type": "Full Song Only", "count": count(*[_type == 'song' && brand == '${brand}' && instrumentless == false]._id)},
|
|
248
|
-
{"type": "Instrument Removed", "count": count(*[_type == 'song' && brand == '${brand}' && instrumentless == true]._id)}
|
|
249
|
-
]
|
|
250
|
-
}`;
|
|
251
|
-
|
|
252
|
-
return fetchSanity(query, true);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Fetch the total count of songs for a specific brand.
|
|
257
|
-
* @param {string} brand - The brand for which to fetch the song count.
|
|
258
|
-
* @returns {Promise<number|null>} - The total count of songs or null if an error occurs.
|
|
259
|
-
*/
|
|
260
|
-
export async function fetchSongCount(brand) {
|
|
261
|
-
const query = `count(*[_type == 'song' && brand == "${brand}"])`;
|
|
262
|
-
return fetchSanity(query, true, {processNeedAccess: false});
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Fetch the latest workouts for a specific brand, including completion status and progress.
|
|
267
|
-
* This function retrieves up to five of the latest workout content for a given brand, sorted in descending order by their publication date.
|
|
268
|
-
* It also includes completion status and progress percentage for each workout by fetching additional data about user progress.
|
|
269
|
-
*
|
|
270
|
-
* @param {string} brand - The brand for which to fetch workouts (e.g., 'drumeo', 'pianote').
|
|
271
|
-
* @returns {Promise<Array<Object>|null>} - A promise that resolves to an array of workout data objects with additional properties for completion status and progress percentage,
|
|
272
|
-
* or null if no workouts are found.
|
|
273
|
-
*
|
|
274
|
-
* @example
|
|
275
|
-
* fetchWorkouts('drumeo')
|
|
276
|
-
* .then(workouts => console.log(workouts))
|
|
277
|
-
* .catch(error => console.error(error));
|
|
278
|
-
*/
|
|
279
|
-
export async function fetchWorkouts(brand) {
|
|
280
|
-
const fields = getFieldsForContentType('workout');
|
|
281
|
-
const query = `*[_type == 'workout' && brand == '${brand}'] [0...5] {
|
|
282
|
-
${fields.toString()}
|
|
283
|
-
} | order(published_on desc)[0...5]`
|
|
284
|
-
return fetchSanity(query, true);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
186
|
/**
|
|
288
187
|
* Fetch the latest new releases for a specific brand.
|
|
289
188
|
* @param {string} brand - The brand for which to fetch new releases.
|
|
@@ -546,7 +445,6 @@ export async function fetchAll(brand, type, {
|
|
|
546
445
|
if (customResults) {
|
|
547
446
|
return customResults;
|
|
548
447
|
}
|
|
549
|
-
|
|
550
448
|
let config = contentTypeConfig[type] ?? {};
|
|
551
449
|
let additionalFields = config?.fields ?? [];
|
|
552
450
|
let isGroupByOneToOne = (groupBy ? config?.relationships?.[groupBy]?.isOneToOne : false) ?? false;
|
|
@@ -564,7 +462,7 @@ export async function fetchAll(brand, type, {
|
|
|
564
462
|
} else if(type === 'pack'){
|
|
565
463
|
typeFilter = `&& (_type == 'pack' || _type == 'semester-pack')`;
|
|
566
464
|
} else {
|
|
567
|
-
typeFilter = type ? `&& _type == '${type}'` : "";
|
|
465
|
+
typeFilter = type ? `&& _type == '${type}'` : progress === 'in progress' || progress === 'completed' ? " && (_type != 'challenge-part' && _type != 'challenge')" : "";
|
|
568
466
|
}
|
|
569
467
|
|
|
570
468
|
// Construct the search filter
|
|
@@ -917,60 +815,6 @@ export async function fetchAllFilterOptions(
|
|
|
917
815
|
return includeTabs ? {...results, tabs, catalogName} : results;
|
|
918
816
|
}
|
|
919
817
|
|
|
920
|
-
|
|
921
|
-
/**
|
|
922
|
-
* Fetch children content by Railcontent ID.
|
|
923
|
-
* @param {string} railcontentId - The Railcontent ID of the parent content.
|
|
924
|
-
* @param {string} [contentType] - The content type the IDs to add needed fields to the response.
|
|
925
|
-
* @returns {Promise<Array<Object>|null>} - The fetched children content data or [] if not found.
|
|
926
|
-
*/
|
|
927
|
-
export async function fetchChildren(railcontentId, contentType) {
|
|
928
|
-
const query = `*[railcontent_id == ${railcontentId}]{
|
|
929
|
-
title,
|
|
930
|
-
|
|
931
|
-
'children': child[]->{
|
|
932
|
-
${getFieldsForContentType(contentType)}
|
|
933
|
-
},
|
|
934
|
-
}[0..1]`;
|
|
935
|
-
let parent = await fetchSanity(query, false);
|
|
936
|
-
return parent['children'] ?? [];
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
/**
|
|
940
|
-
*
|
|
941
|
-
* @param railcontentId - railcontent id of the child
|
|
942
|
-
* @returns {Promise<Array<string>|null>} - The fetched parent content data or [] if not found
|
|
943
|
-
*/
|
|
944
|
-
export async function fetchParentByRailContentId(railcontentId) {
|
|
945
|
-
const query = `*[railcontent_id == ${railcontentId}]{
|
|
946
|
-
'parents': array::unique([
|
|
947
|
-
...(*[references(^._id)]{
|
|
948
|
-
${getFieldsForContentType()}
|
|
949
|
-
})
|
|
950
|
-
])
|
|
951
|
-
}[0...1]`;
|
|
952
|
-
let child = await fetchSanity(query, false);
|
|
953
|
-
return child['parents'][0] ?? [];
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
/**
|
|
957
|
-
* Fetch the Methods (learning-paths) for a specific brand.
|
|
958
|
-
* @param {string} brand - The brand for which to fetch methods.
|
|
959
|
-
* @returns {Promise<Object|null>} - The fetched methods data or null if not found.
|
|
960
|
-
*/
|
|
961
|
-
export async function fetchMethods(brand) {
|
|
962
|
-
const query = `*[_type == 'learning-path' && brand == '${brand}'] {
|
|
963
|
-
parent_content_data,
|
|
964
|
-
"breadcrumbs_data": parent_content_data[] {
|
|
965
|
-
"id": id,
|
|
966
|
-
"title": *[railcontent_id == ^.id][0].title,
|
|
967
|
-
"url": *[railcontent_id == ^.id][0].web_url_path
|
|
968
|
-
} | order(length(url)),
|
|
969
|
-
${getFieldsForContentType()}
|
|
970
|
-
} | order(published_on asc)`
|
|
971
|
-
return fetchSanity(query, true);
|
|
972
|
-
}
|
|
973
|
-
|
|
974
818
|
/**
|
|
975
819
|
* Fetch the Foundations 2019.
|
|
976
820
|
* @param {string} slug - The slug of the method.
|
|
@@ -1069,19 +913,6 @@ export async function fetchMethodChildren(railcontentId) {
|
|
|
1069
913
|
return fetchSanity(query, true);
|
|
1070
914
|
}
|
|
1071
915
|
|
|
1072
|
-
/**
|
|
1073
|
-
* Fetch the next lesson for a specific method by Railcontent ID.
|
|
1074
|
-
* @param {string} railcontentId - The Railcontent ID of the current lesson.
|
|
1075
|
-
* @param {string} methodId - The RailcontentID of the method
|
|
1076
|
-
* @returns {Promise<Object|null>} - The fetched next lesson data or null if not found.
|
|
1077
|
-
*/
|
|
1078
|
-
export async function fetchMethodNextLesson(railcontentId, methodId) {
|
|
1079
|
-
const sortedChildren = await fetchMethodChildrenIds(methodId);
|
|
1080
|
-
const index = sortedChildren.indexOf(railcontentId);
|
|
1081
|
-
const childIndex = sortedChildren[index + 1];
|
|
1082
|
-
return childIndex ? await fetchByRailContentId(childIndex) : null;
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
916
|
/**
|
|
1086
917
|
* Fetch the next lesson for a specific method by Railcontent ID.
|
|
1087
918
|
* @param {string} railcontentId - The Railcontent ID of the current lesson.
|
|
@@ -1302,30 +1133,6 @@ export async function fetchRelatedLessons(railContentId, brand) {
|
|
|
1302
1133
|
return fetchSanity(query, false);
|
|
1303
1134
|
}
|
|
1304
1135
|
|
|
1305
|
-
/**
|
|
1306
|
-
* Fetch related method lessons for a specific lesson by RailContent ID and type.
|
|
1307
|
-
* @param {string} railContentId - The RailContent ID of the current lesson.
|
|
1308
|
-
* @param {string} brand - The current brand.
|
|
1309
|
-
* @returns {Promise<Array<Object>|null>} - The fetched related lessons
|
|
1310
|
-
*/
|
|
1311
|
-
export async function fetchRelatedMethodLessons(railContentId, brand) {
|
|
1312
|
-
const query = `*[railcontent_id == ${railContentId} && brand == "${brand}"]{
|
|
1313
|
-
"id":_id,
|
|
1314
|
-
"related_lessons": *[references(^._id)][0].child[]->{
|
|
1315
|
-
"id": railcontent_id,
|
|
1316
|
-
"type": _type,
|
|
1317
|
-
title,
|
|
1318
|
-
"description": description[0].children[0].text, // Extraer texto plano
|
|
1319
|
-
"thumbnail_url": thumbnail.asset->url,
|
|
1320
|
-
"url": web_url_path,
|
|
1321
|
-
difficulty,
|
|
1322
|
-
difficulty_string,
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
}`
|
|
1326
|
-
return fetchSanity(query, false);
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
1136
|
/**
|
|
1330
1137
|
* Fetch all packs.
|
|
1331
1138
|
* @param {string} brand - The brand for which to fetch packs.
|
|
@@ -1415,20 +1222,6 @@ export async function fetchLiveEvent(brand) {
|
|
|
1415
1222
|
return await fetchSanity(query, false, {processNeedAccess: false});
|
|
1416
1223
|
}
|
|
1417
1224
|
|
|
1418
|
-
/**
|
|
1419
|
-
* Fetch all children of a specific pack by Railcontent ID.
|
|
1420
|
-
* @param {string} railcontentId - The Railcontent ID of the pack.
|
|
1421
|
-
* @returns {Promise<Array<Object>|null>} - The fetched pack children data or null if not found.
|
|
1422
|
-
*
|
|
1423
|
-
* @example
|
|
1424
|
-
* fetchPackChildren('pack123')
|
|
1425
|
-
* .then(children => console.log(children))
|
|
1426
|
-
* .catch(error => console.error(error));
|
|
1427
|
-
*/
|
|
1428
|
-
export async function fetchPackChildren(railcontentId) {
|
|
1429
|
-
return fetchChildren(railcontentId, 'pack-children');
|
|
1430
|
-
}
|
|
1431
|
-
|
|
1432
1225
|
/**
|
|
1433
1226
|
* Fetch the data needed for the Pack Overview screen.
|
|
1434
1227
|
* @param {number} id - The Railcontent ID of the pack
|
|
@@ -1446,24 +1239,6 @@ export async function fetchPackData(id) {
|
|
|
1446
1239
|
return fetchSanity(query, false);
|
|
1447
1240
|
}
|
|
1448
1241
|
|
|
1449
|
-
/**
|
|
1450
|
-
* Fetch the data needed for the Challenge Overview screen.
|
|
1451
|
-
* @param {string} id - The Railcontent ID of the course
|
|
1452
|
-
* @returns {Promise<Object|null>} - The challenge information and lessons or null if not found.
|
|
1453
|
-
*
|
|
1454
|
-
* @example
|
|
1455
|
-
* fetchChallengeOverview('challenge123')
|
|
1456
|
-
* .then(challenge => console.log(challenge))
|
|
1457
|
-
* .catch(error => console.error(error));
|
|
1458
|
-
*/
|
|
1459
|
-
export async function fetchChallengeOverview(id) {
|
|
1460
|
-
// WIP
|
|
1461
|
-
const query = `*[railcontent_id == ${id}]{
|
|
1462
|
-
${getFieldsForContentType("challenge")}
|
|
1463
|
-
} [0...1]`;
|
|
1464
|
-
return fetchSanity(query, false);
|
|
1465
|
-
}
|
|
1466
|
-
|
|
1467
1242
|
/**
|
|
1468
1243
|
* Fetch the data needed for the coach screen.
|
|
1469
1244
|
* @param {string} brand - The brand for which to fetch coach lessons
|
|
@@ -1511,20 +1286,6 @@ export async function fetchCoachLessons(brand, id, {
|
|
|
1511
1286
|
return fetchSanity(query, true);
|
|
1512
1287
|
}
|
|
1513
1288
|
|
|
1514
|
-
/**
|
|
1515
|
-
* Fetch the data needed for the Course Overview screen.
|
|
1516
|
-
* @param {string} id - The Railcontent ID of the course
|
|
1517
|
-
* @returns {Promise<Object|null>} - The course information and lessons or null if not found.
|
|
1518
|
-
*
|
|
1519
|
-
* @example
|
|
1520
|
-
* fetchCourseOverview('course123')
|
|
1521
|
-
* .then(course => console.log(course))
|
|
1522
|
-
* .catch(error => console.error(error));
|
|
1523
|
-
*/
|
|
1524
|
-
export async function fetchCourseOverview(id) {
|
|
1525
|
-
return fetchByRailContentId(id, 'course');
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
1289
|
/**
|
|
1529
1290
|
* Fetch the data needed for the Course Overview screen.
|
|
1530
1291
|
* @param {string} id - The Railcontent ID of the course
|
|
@@ -1780,26 +1541,6 @@ function populateHierarchyLookups(currentLevel, data, parentId) {
|
|
|
1780
1541
|
|
|
1781
1542
|
}
|
|
1782
1543
|
|
|
1783
|
-
/**
|
|
1784
|
-
* Fetch assignments for content
|
|
1785
|
-
*
|
|
1786
|
-
* @param {integer} contentId - List of ids get data for
|
|
1787
|
-
* @returns {Promise<array|null>} - A promise that resolves to an array containing the data
|
|
1788
|
-
*/
|
|
1789
|
-
export async function fetchAssignments(contentId) {
|
|
1790
|
-
const fields = `"id": railcontent_id,"assignments":assignment[]{"id": railcontent_id}`;
|
|
1791
|
-
const query = await buildQuery(`railcontent_id == ${contentId}`,
|
|
1792
|
-
{bypassPermissions: true},
|
|
1793
|
-
fields,
|
|
1794
|
-
{end: 100});
|
|
1795
|
-
let data = await fetchSanity(query, false);
|
|
1796
|
-
let mapped = [];
|
|
1797
|
-
data.assignments.forEach(function (content) {
|
|
1798
|
-
mapped.push(content.id);
|
|
1799
|
-
});
|
|
1800
|
-
return mapped;
|
|
1801
|
-
}
|
|
1802
|
-
|
|
1803
1544
|
/**
|
|
1804
1545
|
* Fetch data for comment mod page
|
|
1805
1546
|
*
|
|
@@ -1949,32 +1690,6 @@ function doesUserNeedAccessToContent(result, userPermissions, isAdmin) {
|
|
|
1949
1690
|
return true;
|
|
1950
1691
|
}
|
|
1951
1692
|
|
|
1952
|
-
/**
|
|
1953
|
-
* Fetch CatalogueMetadata from Sanity. This information may be duplicated in the contentTypeConfig.js.
|
|
1954
|
-
* It's an ongoing discussion (Aug 2024), but it's been included here if necessary
|
|
1955
|
-
*
|
|
1956
|
-
* @param {string} contentType - name of the contentype to pull
|
|
1957
|
-
* @returns {Promise<Object|null>} - A promise that resolves to the fetched data or null if an error occurs or no results are found.
|
|
1958
|
-
*
|
|
1959
|
-
* @example
|
|
1960
|
-
*
|
|
1961
|
-
* fetchCatalogMetadata('song')
|
|
1962
|
-
* .then(data => console.log(data))
|
|
1963
|
-
* .catch(error => console.error(error));
|
|
1964
|
-
*/
|
|
1965
|
-
export async function fetchCatalogMetadata(contentType) {
|
|
1966
|
-
const query = `*[_type == 'CatalogMetadata']{
|
|
1967
|
-
catalog_type,
|
|
1968
|
-
brand,
|
|
1969
|
-
groq_results,
|
|
1970
|
-
groq_search_fields,
|
|
1971
|
-
meta_data_groq,
|
|
1972
|
-
modal_text,
|
|
1973
|
-
sort_by,
|
|
1974
|
-
}`
|
|
1975
|
-
return fetchSanity(query, false, {processNeedAccess: false});
|
|
1976
|
-
}
|
|
1977
|
-
|
|
1978
1693
|
/**
|
|
1979
1694
|
* Fetch shows data for a brand.
|
|
1980
1695
|
*
|
|
File without changes
|
|
File without changes
|
package/test/initializeTests.js
CHANGED
|
File without changes
|
package/test/lastUpdated.test.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/localStorageMock.js
CHANGED
|
File without changes
|
package/test/log.js
CHANGED
|
File without changes
|
|
@@ -2,7 +2,6 @@ import {getFieldsForContentType} from "../src/contentTypeConfig";
|
|
|
2
2
|
const railContentModule = require('../src/services/railcontent.js')
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
fetchAssignments,
|
|
6
5
|
fetchCommentModContentData,
|
|
7
6
|
fetchMethodPreviousNextLesson,
|
|
8
7
|
fetchSanity
|
|
@@ -17,9 +16,6 @@ const {
|
|
|
17
16
|
fetchArtists,
|
|
18
17
|
fetchSongArtistCount,
|
|
19
18
|
fetchRelatedSongs,
|
|
20
|
-
fetchAllSongs,
|
|
21
|
-
fetchSongFilterOptions,
|
|
22
|
-
fetchSongCount,
|
|
23
19
|
fetchNewReleases,
|
|
24
20
|
fetchUpcomingEvents,
|
|
25
21
|
fetchByRailContentId,
|
|
@@ -28,17 +24,12 @@ const {
|
|
|
28
24
|
fetchAllOld,
|
|
29
25
|
fetchAllFilterOptions,
|
|
30
26
|
fetchFoundation,
|
|
31
|
-
fetchMethods,
|
|
32
27
|
fetchMethod,
|
|
33
28
|
fetchRelatedLessons,
|
|
34
29
|
fetchAllPacks,
|
|
35
30
|
fetchPackAll,
|
|
36
31
|
fetchLessonContent,
|
|
37
|
-
fetchCourseOverview,
|
|
38
|
-
fetchChildren,
|
|
39
|
-
fetchParentByRailContentId,
|
|
40
32
|
fetchLiveEvent,
|
|
41
|
-
fetchChallengeOverview,
|
|
42
33
|
fetchCoachLessons,
|
|
43
34
|
fetchByReference,
|
|
44
35
|
fetchScheduledReleases,
|
|
@@ -110,14 +101,6 @@ describe('Sanity Queries', function () {
|
|
|
110
101
|
expect(response.id).toBe(id);
|
|
111
102
|
});
|
|
112
103
|
|
|
113
|
-
test('fetchChallengeOverview', async () => {
|
|
114
|
-
const id = 402197;
|
|
115
|
-
const response = await fetchChallengeOverview(id);
|
|
116
|
-
expect(response.lessons).toBeDefined();
|
|
117
|
-
expect(response.id).toBe(id);
|
|
118
|
-
|
|
119
|
-
});
|
|
120
|
-
|
|
121
104
|
test('fetchByRailContentIds', async () => {
|
|
122
105
|
const id = 380094;
|
|
123
106
|
const id2 = 402204;
|
|
@@ -155,27 +138,6 @@ describe('Sanity Queries', function () {
|
|
|
155
138
|
expect(response.id).toBe(id);
|
|
156
139
|
});
|
|
157
140
|
|
|
158
|
-
|
|
159
|
-
test('fetchCourseOverview', async () => {
|
|
160
|
-
const id = 310414;
|
|
161
|
-
const response = await fetchCourseOverview(id);
|
|
162
|
-
expect(response.id).toBe(id);
|
|
163
|
-
expect(response.type).toBe('course');
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
test('fetchSongCount', async () => {
|
|
167
|
-
const response = await fetchSongCount('drumeo');
|
|
168
|
-
expect(response).toBeGreaterThan(1000);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
test('fetchAllSongs', async () => {
|
|
172
|
-
const response = await fetchAllSongs('drumeo', {});
|
|
173
|
-
log(response);
|
|
174
|
-
expect(response.entity[0].soundslice).toBeDefined();
|
|
175
|
-
expect(response.entity[0].artist_name).toBeDefined();
|
|
176
|
-
expect(response.entity[0].instrumentless).toBeDefined();
|
|
177
|
-
});
|
|
178
|
-
|
|
179
141
|
test('fetchAllSongsInProgress', async () => {
|
|
180
142
|
var mock = jest.spyOn(dataContext, 'fetchData');
|
|
181
143
|
var json = JSON.parse(`{"version":1,"config":{"key":1,"enabled":1,"checkInterval":1,"refreshInterval":2},"data":{"412941":{"s":"started","p":6,"t":20,"u":1731108082}}}`);
|
|
@@ -205,21 +167,6 @@ describe('Sanity Queries', function () {
|
|
|
205
167
|
// expect(response.entity[0].id).not.toBe(231622);
|
|
206
168
|
// });
|
|
207
169
|
|
|
208
|
-
test('fetchSongFilterOptions', async () => {
|
|
209
|
-
const response = await fetchSongFilterOptions('drumeo', {});
|
|
210
|
-
log(response);
|
|
211
|
-
expect(response.genre).toBeDefined();
|
|
212
|
-
expect(response.difficulty).toBeDefined();
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
test('fetchAllSongsGroupByArtist', async () => {
|
|
216
|
-
const response = await fetchAllSongs('drumeo', {groupBy: "artist"});
|
|
217
|
-
expect(response.entity[0].lessons[0].soundslice).toBeDefined();
|
|
218
|
-
expect(response.entity[0].lessons[0].artist_name).toBeDefined();
|
|
219
|
-
expect(response.entity[0].lessons[0].instrumentless).toBeDefined();
|
|
220
|
-
}, 100000);
|
|
221
|
-
|
|
222
|
-
|
|
223
170
|
test('fetchNewReleases', async () => {
|
|
224
171
|
const response = await fetchNewReleases('drumeo');
|
|
225
172
|
log(response);
|
|
@@ -361,29 +308,6 @@ describe('Sanity Queries', function () {
|
|
|
361
308
|
)).toBe(true);
|
|
362
309
|
}, 10000);
|
|
363
310
|
|
|
364
|
-
test('fetchChildren', async () => {
|
|
365
|
-
// complement test to fetchParentByRailContentId
|
|
366
|
-
const id = 191338; ////https://web-staging-one.musora.com/admin/studio/publishing/structure/play-along;play-along_191338
|
|
367
|
-
const expectedChildID = 191492;
|
|
368
|
-
const response = await fetchChildren(id);
|
|
369
|
-
log('num children', response.length);
|
|
370
|
-
log(response);
|
|
371
|
-
|
|
372
|
-
expect(response.length > 0).toBeTruthy();
|
|
373
|
-
const foundExpectedChild = response.some((child) => {
|
|
374
|
-
return child['id'] = expectedChildID;
|
|
375
|
-
});
|
|
376
|
-
expect(foundExpectedChild).toBeTruthy();
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
test('fetchParentByRailContentId', async () => {
|
|
380
|
-
// complement test to fetchChildren
|
|
381
|
-
const childId = 191492; // child of https://web-staging-one.musora.com/admin/studio/publishing/structure/play-along;play-along_191338
|
|
382
|
-
const expectedParent = 191338;
|
|
383
|
-
const response = await fetchParentByRailContentId(childId);
|
|
384
|
-
expect(response['id']).toBe(expectedParent);
|
|
385
|
-
});
|
|
386
|
-
|
|
387
311
|
test('getSortOrder', () => {
|
|
388
312
|
let sort = getSortOrder()
|
|
389
313
|
expect(sort).toBe('published_on desc');
|
|
@@ -404,13 +328,6 @@ describe('Sanity Queries', function () {
|
|
|
404
328
|
expect(response.levels.length).toBeGreaterThan(0);
|
|
405
329
|
});
|
|
406
330
|
|
|
407
|
-
test('fetchMethods', async () => {
|
|
408
|
-
const response = await fetchMethods('drumeo');
|
|
409
|
-
log(response);
|
|
410
|
-
expect(response.length).toBeGreaterThan(0);
|
|
411
|
-
expect(response[0].type).toBe('learning-path');
|
|
412
|
-
});
|
|
413
|
-
|
|
414
331
|
test('fetchAll-WithProgress', async () => {
|
|
415
332
|
const ids = [410213, 410215];
|
|
416
333
|
let response = await fetchAll('drumeo', 'song', {
|
|
@@ -571,16 +488,6 @@ describe('Sanity Queries', function () {
|
|
|
571
488
|
expect(response.tabs.length).toBeGreaterThan(0);
|
|
572
489
|
});
|
|
573
490
|
|
|
574
|
-
test('fetchChallengesV2Fields', async () => {
|
|
575
|
-
const id = 402197;
|
|
576
|
-
const response = await fetchChallengeOverview(id);
|
|
577
|
-
log(response);
|
|
578
|
-
expect(response.award).toBeDefined();
|
|
579
|
-
expect(response.award_custom_text).toBeDefined();
|
|
580
|
-
expect(response.lessons[0].is_always_unlocked_for_challenge).toBeDefined();
|
|
581
|
-
expect(response.lessons[0].is_bonus_content_for_challenge).toBeDefined();
|
|
582
|
-
});
|
|
583
|
-
|
|
584
491
|
test('fetchShowsData-OddTimes', async () => {
|
|
585
492
|
const response = await fetchShowsData('drumeo');
|
|
586
493
|
log(response);
|
|
@@ -690,12 +597,6 @@ describe('Sanity Queries', function () {
|
|
|
690
597
|
expect(data[241251].parentTitle).toBe("Gear");
|
|
691
598
|
expect(data[241252].title).toBe("Setting Up Your Pedals & Throne");
|
|
692
599
|
});
|
|
693
|
-
|
|
694
|
-
test('fetchAssignments', async()=>{
|
|
695
|
-
let data = await fetchAssignments(241250);
|
|
696
|
-
expect(data).toContain(241676);
|
|
697
|
-
});
|
|
698
|
-
|
|
699
600
|
});
|
|
700
601
|
|
|
701
602
|
describe('Filter Builder', function () {
|
|
File without changes
|
package/.yarnrc.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
nodeLinker: node-modules
|