musora-content-services 1.0.147 → 1.0.150

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.
@@ -9,7 +9,15 @@ const {globalConfig} = require('./config');
9
9
  *
10
10
  * @type {string[]}
11
11
  */
12
- const excludeFromGeneratedIndex = ['fetchUserLikes', 'postContentLiked', 'postContentUnliked'];
12
+ const excludeFromGeneratedIndex = [
13
+ 'fetchUserLikes',
14
+ 'postContentLiked',
15
+ 'postContentUnliked',
16
+ 'postRecordWatchSession',
17
+ 'postContentStarted',
18
+ 'postContentCompleted',
19
+ 'postContentReset'
20
+ ];
13
21
 
14
22
 
15
23
  /**
@@ -238,14 +246,25 @@ async function fetchDataHandler(url, dataVersion, method = "get") {
238
246
  return fetchHandler(url, method, dataVersion);
239
247
  }
240
248
 
241
- export async function fetchHandler(url, method = "get", dataVersion = null) {
249
+ async function postDataHandler(url, data) {
250
+ return fetchHandler(url, 'post', data);
251
+ }
252
+
253
+ export async function fetchHandler(url, method = "get", dataVersion = null, body = null) {
242
254
  let headers = {
243
255
  'Content-Type': 'application/json',
244
256
  'X-CSRF-TOKEN': globalConfig.railcontentConfig.token,
245
257
  };
246
258
  if (dataVersion) headers['Data-Version'] = dataVersion;
259
+ const options = {
260
+ method,
261
+ headers,
262
+ };
263
+ if (body) {
264
+ options.body = JSON.stringify(body);
265
+ }
247
266
  try {
248
- const response = await fetchAbsolute(url, {method, headers});
267
+ const response = await fetchAbsolute(url, options);
249
268
  const result = await response.json();
250
269
  if (result) {
251
270
  return result;
@@ -265,12 +284,40 @@ export async function fetchUserLikes(currentVersion) {
265
284
 
266
285
  export async function postContentLiked(contentId) {
267
286
  let url = `/content/user/likes/like/${contentId}`;
268
- return await fetchHandler(url, "post");
287
+ return await postDataHandler(url);
269
288
  }
270
289
 
271
290
  export async function postContentUnliked(contentId) {
272
291
  let url = `/content/user/likes/unlike/${contentId}`;
273
- return await fetchHandler(url, "post");
292
+ return await postDataHandler(url);
293
+ }
294
+
295
+ export async function fetchContentProgress(currentVersion) {
296
+ let url = `/content/user/progress/all`;
297
+ return fetchDataHandler(url, currentVersion);
298
+ }
299
+
300
+ export async function postRecordWatchSession({
301
+ mediaId,
302
+ mediaType,
303
+ mediaCategory,
304
+ watchPosition,
305
+ totalDuration,
306
+ sessionToken,
307
+ brand,
308
+ contentId = null
309
+ }) {
310
+ let url = `/railtracker/media-playback-session`;
311
+ return postDataHandler(url, {
312
+ mediaId,
313
+ mediaType,
314
+ mediaCategory,
315
+ watchPosition,
316
+ totalDuration,
317
+ sessionToken,
318
+ brand,
319
+ contentId
320
+ });
274
321
  }
275
322
 
276
323
  export async function fetchChallengeMetadata(contentId) {
@@ -323,6 +370,316 @@ export async function postChallengesCommunityNotification(contentId) {
323
370
  return await fetchHandler(url, 'post');
324
371
  }
325
372
 
373
+ /**
374
+ * Fetches user playlists for a specific brand.
375
+ *
376
+ * Allows optional pagination, sorting, and search parameters to control the result set.
377
+ *
378
+ * @param {string} brand - The brand identifier for which playlists are being fetched.
379
+ * @param {number} [params.limit=10] - The maximum number of playlists to return per page (default is 10).
380
+ * @param {number} [params.page=1] - The page number for pagination.
381
+ * @param {string} [params.sort='-created_at'] - The sorting order for the playlists (default is by created_at in descending order).
382
+ * @param {string} [params.searchTerm] - A search term to filter playlists by name.
383
+ *
384
+ * @returns {Promise<Object|null>} - A promise that resolves to the response from the API, containing the user playlists data.
385
+ *
386
+ * @example
387
+ * fetchUserPlaylists('drumeo', { page: 1, sort: 'name', searchTerm: 'rock' })
388
+ * .then(playlists => console.log(playlists))
389
+ * .catch(error => console.error(error));
390
+ */
391
+ export async function fetchUserPlaylists(brand, {page, limit, sort, searchTerm} = {}) {
392
+ let url;
393
+ const limitString = limit ? `&limit=${limit}` : '';
394
+ const pageString = page ? `&page=${page}` : '';
395
+ const sortString = sort ? `&sort=${sort}`:'';
396
+ const searchFilter = searchTerm ? `&term=${searchTerm}`: '';
397
+ url = `/playlists/all?brand=${brand}${limitString}${pageString}${sortString}${searchFilter}`;
398
+ return await fetchHandler(url);
399
+ }
400
+
401
+ /**
402
+ * Duplicates an existing playlist by sending a POST request to the API.
403
+ *
404
+ * This function calls the `/playlists/duplicate` endpoint, where the server replicates the specified playlist,
405
+ * including its items. Optionally, new `name`, `description`, `category`, or `thumbnail_url` parameters can be provided
406
+ * to customize the duplicated playlist. If a new name is not provided, the server appends " (Duplicate)" to the original name.
407
+ *
408
+ * @param {string|number} playlistId - The unique identifier of the playlist to be duplicated.
409
+ * @param {Object} [playlistData] - Optional data to customize the duplicated playlist.
410
+ * @param {string} [playlistData.name] - New name for the duplicated playlist (default is original name + " (Duplicate)").
411
+ * @param {string} [playlistData.description] - New description for the duplicated playlist (defaults to original description).
412
+ * @param {string} [playlistData.category] - New category for the duplicated playlist (defaults to original category).
413
+ * @param {string} [playlistData.thumbnail_url] - New URL for the duplicated playlist thumbnail (defaults to original thumbnail).
414
+ *
415
+ * @returns {Promise<Object>} - A promise that resolves to the duplicated playlist data, or rejects with an error if the duplication fails.
416
+ *
417
+ * The duplicated playlist contains:
418
+ * - `name` (string): Name of the new playlist.
419
+ * - `description` (string|null): Description of the duplicated playlist.
420
+ * - `category` (string|null): Category of the duplicated playlist.
421
+ * - `thumbnail_url` (string|null): URL of the playlist thumbnail.
422
+ * - `items` (Array): A list of items (e.g., songs, tracks) copied from the original playlist.
423
+ *
424
+ * @example
425
+ * duplicatePlaylist(12345, { name: "My New Playlist" })
426
+ * .then(duplicatedPlaylist => console.log(duplicatedPlaylist))
427
+ * .catch(error => console.error('Error duplicating playlist:', error));
428
+ */
429
+ export async function duplicatePlaylist(playlistId, playlistData) {
430
+ let url = `/playlists/duplicate/${playlistId}`;
431
+ return await fetchHandler(url, "post",null, playlistData);
432
+ }
433
+
434
+ /**
435
+ * Deletes a user’s playlist along with all associated items by sending a DELETE request to the API.
436
+ *
437
+ * This function calls the `/playlists/playlist` endpoint, where the server verifies the user’s ownership of the specified playlist.
438
+ * If the user is authorized, it deletes both the playlist and its associated items.
439
+ *
440
+ * @param {string|number} playlistId - The unique identifier of the playlist to be deleted.
441
+ *
442
+ * @returns {Promise<Object>} - A promise that resolves to an object containing:
443
+ * - `success` (boolean): Indicates if the deletion was successful (`true` for success).
444
+ * - `message` (string): Success confirmation message (e.g., "Playlist and associated items deleted successfully").
445
+ *
446
+ * If the user is unauthorized or the playlist does not exist, the promise rejects with an error.
447
+ *
448
+ * @example
449
+ * deletePlaylist(12345)
450
+ * .then(response => {
451
+ * if (response.success) {
452
+ * console.log(response.message);
453
+ * }
454
+ * })
455
+ * .catch(error => console.error('Error deleting playlist:', error));
456
+ */
457
+ export async function deletePlaylist(playlistId) {
458
+ let url = `/playlists/playlist`;
459
+ const payload = { playlist_id: playlistId };
460
+ return await fetchHandler(url, "delete", null, payload);
461
+ }
462
+
463
+ /**
464
+ * Updates a user’s playlist by sending a PUT request with updated data to the API.
465
+ *
466
+ * This function calls the `/playlists/playlist/{playlistId}` endpoint, where the server validates the incoming data
467
+ * and verifies that the authenticated user is the playlist owner. If authorized, it updates the playlist details with the provided data.
468
+ *
469
+ * @param {string|number} playlistId - The unique identifier of the playlist to be updated.
470
+ * @param {Object} updatedData - An object containing the playlist data to update. The possible fields include:
471
+ * - `name` (string): The new name of the playlist (max 255 characters).
472
+ * - `description` (string): A new description for the playlist (max 1000 characters).
473
+ * - `category` (string): The updated category of the playlist (max 255 characters).
474
+ * - `private` (boolean): Whether the playlist is private.
475
+ * - `thumbnail_url` (string): The URL of the playlist thumbnail.
476
+ *
477
+ * @returns {Promise<Object>} - A promise that resolves to an object containing:
478
+ * - `success` (boolean): Indicates if the update was successful (`true` for success).
479
+ * - `message` (string): Success confirmation message if the update is successful.
480
+ * - Other fields containing the updated playlist data.
481
+ *
482
+ * If the user is unauthorized or the data validation fails, the promise rejects with an error.
483
+ *
484
+ * @example
485
+ * updatePlaylist(12345, { name: "My New Playlist Name", description: "Updated description" })
486
+ * .then(response => {
487
+ * if (response.success) {
488
+ * console.log(response.message);
489
+ * }
490
+ * })
491
+ * .catch(error => console.error('Error updating playlist:', error));
492
+ */
493
+ export async function updatePlaylist(playlistId, updatedData) {
494
+ const url = `/playlists/playlist/${playlistId}`;
495
+ return await fetchHandler(url, "PUT", null, updatedData);
496
+ }
497
+
498
+ /**
499
+ * Creates a new user playlist by sending a POST request with playlist data to the API.
500
+ *
501
+ * This function calls the `/playlists/playlist` endpoint, where the server validates the incoming data and associates
502
+ * the new playlist with the authenticated user. The `name` field is required, while other fields are optional.
503
+ *
504
+ * @param {Object} playlistData - An object containing data to create the playlist. The fields include:
505
+ * - `name` (string): The name of the new playlist (required, max 255 characters).
506
+ * - `description` (string): A description of the playlist (optional, max 1000 characters).
507
+ * - `category` (string): The category of the playlist.
508
+ * - `thumbnail_url` (string): The URL of the playlist thumbnail (optional, must be a valid URL).
509
+ * - `private` (boolean): Whether the playlist is private (optional, defaults to true).
510
+ * - `brand` (string): Brand identifier for the playlist.
511
+ *
512
+ * @returns {Promise<Object>} - A promise that resolves to the created playlist data if successful, or an error response if validation fails.
513
+ *
514
+ * The server response includes:
515
+ * - `message`: Success message indicating playlist creation (e.g., "Playlist created successfully").
516
+ * - `playlist`: The data for the created playlist, including the `user_id` of the authenticated user.
517
+ *
518
+ * @example
519
+ * createPlaylist({ name: "My Playlist", description: "A cool playlist", private: true })
520
+ * .then(response => console.log(response.message))
521
+ * .catch(error => console.error('Error creating playlist:', error));
522
+ */
523
+ export async function createPlaylist(playlistData) {
524
+ const url = `/playlists/playlist`;
525
+ return await fetchHandler(url, "POST", null, playlistData);
526
+ }
527
+
528
+ /**
529
+ * Sends a request to "like" a playlist on behalf of the authenticated user.
530
+ *
531
+ * This function calls the `/playlists/playlist/like` endpoint, where the server validates the `playlist_id` and checks
532
+ * if the authenticated user has already liked the playlist. If not, it creates a new "like" entry associated with the playlist.
533
+ *
534
+ * @param {string|number} playlistId - The unique identifier of the playlist to be liked.
535
+ *
536
+ * @returns {Promise<Object>} - A promise that resolves with the response from the API. The response contains:
537
+ * - `success` (boolean): Indicates if the like action was successful (`true` for success).
538
+ * - `message` (string): A success message if the playlist is liked successfully, or a notification if it was already liked.
539
+ * - `like` (Object|null): Details of the created "like" entry if the playlist is newly liked, or null if it was already liked.
540
+ *
541
+ * The `like` object in the response includes:
542
+ * - `playlist_id`: The ID of the liked playlist.
543
+ * - `user_id`: The ID of the user who liked the playlist.
544
+ * - `brand`: The brand associated with the like.
545
+ * - `created_at`: Timestamp of when the like was created.
546
+ *
547
+ * @example
548
+ * likePlaylist(12345)
549
+ * .then(response => {
550
+ * if (response.success) {
551
+ * console.log(response.message);
552
+ * }
553
+ * })
554
+ * .catch(error => console.error('Error liking playlist:', error));
555
+ */
556
+ export async function likePlaylist(playlistId) {
557
+ const url = `/playlists/like`;
558
+ const payload = { playlist_id: playlistId };
559
+ return await fetchHandler(url, "PUT", null, payload);
560
+ }
561
+
562
+ /**
563
+ * Removes a "like" from a playlist for the authenticated user.
564
+ *
565
+ * This function sends a DELETE request to the `/playlists/like` endpoint, where the server validates the `playlist_id`
566
+ * and checks if a like by the authenticated user already exists for the specified playlist. If so, it deletes the like.
567
+ *
568
+ * @param {string|number} playlistId - The unique identifier of the playlist whose like is to be removed.
569
+ *
570
+ * @returns {Promise<Object>} - A promise that resolves with the response from the API. The response contains:
571
+ * - `success` (boolean): Indicates if the removal was successful (`true` for success).
572
+ * - `message` (string): A success message if the playlist like is removed successfully or a notification if the playlist was not previously liked.
573
+ *
574
+ * @example
575
+ * deletePlaylistLike(12345)
576
+ * .then(response => {
577
+ * if (response.success) {
578
+ * console.log(response.message);
579
+ * }
580
+ * })
581
+ * .catch(error => console.error('Error removing playlist like:', error));
582
+ */
583
+ export async function deletePlaylistLike(playlistId) {
584
+ const url = `/playlists/like`;
585
+ const payload = { playlist_id: playlistId };
586
+ return await fetchHandler(url, "DELETE", null, payload);
587
+ }
588
+
589
+ /**
590
+ * Retrieves details of a specific playlist by its ID.
591
+ *
592
+ * This function sends a GET request to the `/playlists/playlist` endpoint with a specified playlist ID.
593
+ * The server validates the user's access to the playlist and returns playlist details if the user is authorized.
594
+ *
595
+ * @param {string|number} playlistId - The unique identifier of the playlist to retrieve.
596
+ *
597
+ * @returns {Promise<Object>} - A promise that resolves to the response from the API, containing:
598
+ * - `data` (Object): The playlist details, or an error message if access is denied or the playlist is not found.
599
+ *
600
+ * @example
601
+ * fetchPlaylist(12345)
602
+ * .then(response => console.log(response.data))
603
+ * .catch(error => console.error('Error fetching playlist:', error));
604
+ */
605
+ export async function fetchPlaylist(playlistId) {
606
+ const url = `/playlists/playlist?playlist_id=${playlistId}`;
607
+ return await fetchHandler(url, "GET");
608
+ }
609
+
610
+ /**
611
+ * Retrieves items within a specified playlist by playlist ID.
612
+ *
613
+ * This function sends a GET request to the `/playlists/playlist-lessons` endpoint to fetch items in the given playlist.
614
+ * The server combines data from the playlist and additional metadata from Sanity to enhance item details.
615
+ *
616
+ * @param {string|number} playlistId - The unique identifier of the playlist whose items are to be fetched.
617
+ *
618
+ * @returns {Promise<Array<Object>>} - A promise that resolves to an array of playlist items
619
+ *
620
+ * @example
621
+ * fetchPlaylistItems(12345)
622
+ * .then(items => console.log(items))
623
+ * .catch(error => console.error('Error fetching playlist items:', error));
624
+ */
625
+ export async function fetchPlaylistItems(playlistId) {
626
+ const url = `/playlists/playlist-lessons?playlist_id=${playlistId}`;
627
+ return await fetchHandler(url, "GET");
628
+ }
629
+
630
+ /**
631
+ * Updates a playlist item with the provided data.
632
+ *
633
+ * @param {Object} updatedData - The data to update the playlist item with.
634
+ * @param {number} updatedData.user_playlist_item_id - The ID of the playlist item to update.
635
+ * @param {number} [updatedData.start_second] - (Optional) The start time in seconds for the item.
636
+ * @param {number} [updatedData.end_second] - (Optional) The end time in seconds for the item.
637
+ * @param {string} [updatedData.playlist_item_name] - (Optional) The new name for the playlist item.
638
+ * @returns {Promise<Object|null>} - A promise that resolves to an object containing:
639
+ * - `success` (boolean): Indicates if the update was successful (`true` for success).
640
+ * - `data` (Object): The updated playlist item data.
641
+ *
642
+ * Resolves to `null` if the request fails.
643
+ * @throws {Error} - Throws an error if the request fails.
644
+ *
645
+ * @example
646
+ * const updatedData = {
647
+ * user_playlist_item_id: 123,
648
+ * start_second: 30,
649
+ * end_second: 120,
650
+ * playlist_item_name: "Updated Playlist Item Name"
651
+ * };
652
+ *
653
+ * updatePlaylistItem(updatedData)
654
+ * .then(response => {
655
+ * if (response.success) {
656
+ * console.log("Playlist item updated successfully:", response.data);
657
+ * }
658
+ * })
659
+ * .catch(error => {
660
+ * console.error("Error updating playlist item:", error);
661
+ * });
662
+ */
663
+ export async function updatePlaylistItem(updatedData) {
664
+ const url = `/playlists/item`;
665
+ return await fetchHandler(url, "POST", null, updatedData);
666
+ }
667
+
668
+ export async function postContentStarted(contentId) {
669
+ let url = `/content/${contentId}/started`;
670
+ return postDataHandler(url);
671
+ }
672
+
673
+ export async function postContentCompleted(contentId) {
674
+ let url = `/content/${contentId}/completed`;
675
+ return postDataHandler(url);
676
+ }
677
+
678
+ export async function postContentReset(contentId) {
679
+ let url = `/content/${contentId}/reset`;
680
+ return postDataHandler(url);
681
+ }
682
+
326
683
 
327
684
 
328
685
  function fetchAbsolute(url, params) {
@@ -332,4 +689,4 @@ function fetchAbsolute(url, params) {
332
689
  }
333
690
  }
334
691
  return fetch(url, params);
335
- }
692
+ }
@@ -904,6 +904,9 @@ export async function fetchNextPreviousLesson(railcontentId) {
904
904
  */
905
905
  export async function fetchLessonContent(railContentId) {
906
906
  const filterParams = {};
907
+ // Format changes made to the `fields` object may also need to be reflected in Musora-web-platform SanityGateway.php $fields object
908
+ // Currently only for challenges and challenge lessons
909
+ // If you're unsure, message Adrian, or just add them.
907
910
  const fields = `title,
908
911
  published_on,
909
912
  "type":_type,
@@ -1359,6 +1362,77 @@ export async function fetchGenreLessons(brand, name, contentType, {
1359
1362
  return fetchSanity(query, true);
1360
1363
  }
1361
1364
 
1365
+ export async function fetchTopLevelParentId(railcontentId) {
1366
+ const query = `*[railcontent_id == ${railcontentId}]{
1367
+ railcontent_id,
1368
+ 'parents': *[^._id in child[]._ref && !(_id in path('drafts.**'))]{
1369
+ railcontent_id,
1370
+ 'parents': *[^._id in child[]._ref && !(_id in path('drafts.**'))]{
1371
+ railcontent_id,
1372
+ 'parents': *[^._id in child[]._ref && !(_id in path('drafts.**'))]{
1373
+ railcontent_id,
1374
+ 'parents': *[^._id in child[]._ref && !(_id in path('drafts.**'))]{
1375
+ railcontent_id,
1376
+ }
1377
+ }
1378
+ }
1379
+ }
1380
+ }`;
1381
+ let response = await fetchSanity(query, false, {processNeedAccess: false});
1382
+ if (!response) return null;
1383
+ let currentLevel = response;
1384
+ for (let i = 0; i < 4; i++) {
1385
+ if (currentLevel['parents'].length > 0) {
1386
+ currentLevel = currentLevel['parents'][0];
1387
+ } else {
1388
+ return currentLevel['railcontent_id'];
1389
+ }
1390
+ }
1391
+ return null;
1392
+ }
1393
+
1394
+ export async function fetchHierarchy(railcontentId) {
1395
+ let topLevelId = await fetchTopLevelParentId(railcontentId);
1396
+ const query = `*[railcontent_id == ${topLevelId}]{
1397
+ railcontent_id,
1398
+ 'children': child[]->{
1399
+ railcontent_id,
1400
+ 'children': child[]->{
1401
+ railcontent_id,
1402
+ 'children': child[]->{
1403
+ railcontent_id,
1404
+ 'children': child[]->{
1405
+ railcontent_id,
1406
+ }
1407
+ }
1408
+ }
1409
+ }
1410
+ }`;
1411
+ let response = await fetchSanity(query, false, {processNeedAccess: false});
1412
+ if (!response) return null;
1413
+ let data = {
1414
+ parents: {},
1415
+ children: {}
1416
+ };
1417
+ populateHierarchyLookups(response, data, null);
1418
+ return data;
1419
+ }
1420
+
1421
+ function populateHierarchyLookups(currentLevel, data, parentId) {
1422
+ let contentId = currentLevel['railcontent_id'];
1423
+ let children = currentLevel['children'];
1424
+ data.parents[contentId] = parentId;
1425
+ if (children) {
1426
+ data.children[contentId] = children.map(child => child['railcontent_id']);
1427
+ for (let i = 0; i < children.length; i++) {
1428
+ populateHierarchyLookups(children[i], data, contentId);
1429
+ }
1430
+ } else {
1431
+ data.children[contentId] = [];
1432
+ }
1433
+ }
1434
+
1435
+
1362
1436
 
1363
1437
  /**
1364
1438
  *
@@ -4,7 +4,7 @@ import {initializeService} from "../src";
4
4
 
5
5
  const railContentModule = require('../src/services/railcontent.js')
6
6
 
7
- describe('commentLikesDataContext', function () {
7
+ describe('contentLikesDataContext', function () {
8
8
  let mock = null;
9
9
  const testVersion = 1;
10
10
 
@@ -0,0 +1,56 @@
1
+ import {getProgressPercentage, dataContext, recordWatchSession} from "../src/services/contentProgress";
2
+ import {initializeTestService} from "./sanityQueryService.test";
3
+
4
+ const railContentModule = require('../src/services/railcontent.js')
5
+
6
+ describe('contentProgressDataContext', function () {
7
+ let mock = null;
8
+ const testVersion = 1;
9
+
10
+ beforeEach(() => {
11
+ initializeTestService();
12
+ mock = jest.spyOn(dataContext, 'fetchData');
13
+ var json = JSON.parse(`{"version":${testVersion},"data":{"234191":{"s":"started","p":6,"t":20},"233955":{"s":"started","p":1}}}`);
14
+ mock.mockImplementation(() => json);
15
+
16
+ });
17
+
18
+ test('getProgressPercentage', async () => {
19
+ let result = await getProgressPercentage(234191);
20
+ expect(result).toBe(6);
21
+ });
22
+
23
+ test('getProgressPercentage_notExists', async () => {
24
+ let result = await getProgressPercentage(111111);
25
+ expect(result).toBe(0);
26
+ });
27
+
28
+ test('progressBubbling', async () => {
29
+ let mock2 = jest.spyOn(railContentModule, 'postRecordWatchSession');
30
+ let serverVersion = 2;
31
+ mock2.mockImplementation(() => JSON.parse(`{"version": ${serverVersion}}`));
32
+ let progress = await getProgressPercentage(241250); //force load context
33
+
34
+ let result = await recordWatchSession({watchPositionSeconds: 50, totalDurationSeconds: 100, contentId: 241250});
35
+ serverVersion++;
36
+ await recordWatchSession({watchPositionSeconds: 50, totalDurationSeconds: 100, contentId: 241251});
37
+ serverVersion++;
38
+ await recordWatchSession({watchPositionSeconds: 50, totalDurationSeconds: 100, contentId: 241252});
39
+ serverVersion++;
40
+ await recordWatchSession({watchPositionSeconds: 100, totalDurationSeconds: 100, contentId: 241260});
41
+ serverVersion++;
42
+ await recordWatchSession({watchPositionSeconds: 100, totalDurationSeconds: 100, contentId: 241261});
43
+ serverVersion++;
44
+ progress = await getProgressPercentage(241250); //force load context
45
+
46
+ expect(progress).toBe(50);
47
+ let progress241249 = await getProgressPercentage(241249);
48
+ expect(progress241249).toBe(15);
49
+ let progress241248 = await getProgressPercentage(241248);
50
+ expect(progress241248).toBe(7);
51
+ let progress241247 = await getProgressPercentage(241247);
52
+ expect(progress241247).toBe(1);
53
+
54
+ });
55
+
56
+ });