musora-content-services 2.152.1 → 2.153.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/.github/workflows/automated-testing.yml +20 -0
  2. package/CHANGELOG.md +15 -0
  3. package/jest.config.js +11 -2
  4. package/package.json +5 -1
  5. package/src/contentTypeConfig.js +13 -14
  6. package/src/infrastructure/http/interfaces/RequestOptions.ts +1 -1
  7. package/src/services/awards/internal/award-definitions.js +3 -3
  8. package/src/services/content-org/guided-courses.ts +1 -1
  9. package/src/services/contentProgress.js +1 -20
  10. package/src/services/dateUtils.js +9 -1
  11. package/src/services/forums/posts.ts +2 -2
  12. package/src/services/reporting/reporting.ts +3 -4
  13. package/src/services/sanity.js +26 -58
  14. package/src/services/sync/adapters/lokijs.ts +5 -2
  15. package/src/services/sync/fetch.ts +2 -14
  16. package/src/services/sync/repositories/base.ts +4 -0
  17. package/src/services/sync/repositories/content-progress.ts +3 -3
  18. package/src/services/sync/store/index.ts +6 -1
  19. package/src/services/sync/strategies/base.ts +1 -1
  20. package/src/services/sync/telemetry/index.ts +1 -1
  21. package/src/services/urlBuilder.ts +1 -0
  22. package/src/services/user/streakCalculator.ts +1 -1
  23. package/test/SKIPPED_TESTS.md +151 -0
  24. package/test/initializeTests.js +2 -3
  25. package/test/{content.test.js → integration/content.test.js} +7 -23
  26. package/test/integration/contentProgress.test.js +73 -0
  27. package/test/{forum.test.js → integration/forum.test.js} +2 -4
  28. package/test/{sanityQueryService.test.js → integration/sanityQueryService.test.js} +143 -291
  29. package/test/{user → integration/user}/permissions.test.js +5 -4
  30. package/test/{learningPaths.test.js → live/learningPaths.test.js} +4 -4
  31. package/test/live/sanityQueryService.test.js +32 -0
  32. package/test/setupConsole.js +6 -0
  33. package/test/setupNetworkGuard.js +3 -0
  34. package/test/{HttpClient.test.js → unit/HttpClient.test.js} +5 -5
  35. package/test/{awards → unit/awards}/award-alacarte-observer.test.js +13 -12
  36. package/test/{awards → unit/awards}/award-auto-refresh.test.js +4 -3
  37. package/test/{awards → unit/awards}/award-calculations.test.js +3 -2
  38. package/test/{awards → unit/awards}/award-certificate-display.test.js +12 -11
  39. package/test/{awards → unit/awards}/award-collection-edge-cases.test.js +12 -11
  40. package/test/{awards → unit/awards}/award-collection-filtering.test.js +12 -11
  41. package/test/{awards → unit/awards}/award-completion-flow.test.js +15 -14
  42. package/test/{awards → unit/awards}/award-exclusion-handling.test.js +20 -19
  43. package/test/{awards → unit/awards}/award-multi-lesson.test.js +14 -13
  44. package/test/{awards → unit/awards}/award-observer-integration.test.js +14 -13
  45. package/test/{awards → unit/awards}/award-query-messages.test.js +30 -21
  46. package/test/{awards → unit/awards}/award-user-collection.test.js +11 -8
  47. package/test/{awards → unit/awards}/duplicate-prevention.test.js +12 -11
  48. package/test/unit/awards/helpers/index.js +3 -0
  49. package/test/{awards → unit/awards}/helpers/mock-setup.js +1 -1
  50. package/test/{awards → unit/awards}/helpers/progress-emitter.js +2 -2
  51. package/test/{awards → unit/awards}/message-generator.test.js +1 -1
  52. package/test/unit/contentLikes.test.js +62 -0
  53. package/test/unit/contentProgress.test.js +75 -0
  54. package/test/{dataContext.test.js → unit/dataContext.test.js} +2 -2
  55. package/test/unit/dateUtils.test.js +188 -0
  56. package/test/{imageSRCBuilder.test.js → unit/imageSRCBuilder.test.js} +2 -2
  57. package/test/{imageSRCVerify.test.js → unit/imageSRCVerify.test.js} +1 -1
  58. package/test/{lib → unit/lib}/filter.test.ts +10 -4
  59. package/test/{lib → unit/lib}/lastUpdated.test.js +6 -6
  60. package/test/{lib → unit/lib}/query.test.ts +1 -1
  61. package/test/{notifications.test.js → unit/notifications.test.js} +51 -39
  62. package/test/{progressRows.test.js → unit/progressRows.test.js} +53 -35
  63. package/test/unit/sanityQueryService.test.js +180 -0
  64. package/test/{streakMessage.test.js → unit/streakMessage.test.js} +18 -27
  65. package/test/unit/sync/adapters/idb-errors.test.ts +144 -0
  66. package/test/unit/sync/adapters/sqlite-errors.test.ts +173 -0
  67. package/test/unit/sync/helpers/TestModel.ts +44 -0
  68. package/test/unit/sync/helpers/index.ts +172 -0
  69. package/test/unit/sync/repositories/content-likes.test.ts +99 -0
  70. package/test/unit/sync/repositories/practices.test.ts +179 -0
  71. package/test/unit/sync/repositories/progress.test.ts +245 -0
  72. package/test/unit/sync/store/store-idb.test.ts +180 -0
  73. package/test/unit/sync/store/store.test.ts +274 -0
  74. package/test/unit/userActivity.test.js +99 -0
  75. package/tsconfig.json +15 -0
  76. package/test/awards/helpers/index.js +0 -3
  77. package/test/contentLikes.test.js +0 -95
  78. package/test/contentProgress.test.js +0 -279
  79. package/test/sync/adapter.ts +0 -9
  80. package/test/sync/initialize-sync-manager.js +0 -88
  81. package/test/sync/models/award-database-integration.test.js +0 -519
  82. package/test/userActivity.test.js +0 -118
  83. /package/test/{awards → unit/awards}/helpers/completion-mock.js +0 -0
  84. /package/test/{lib → unit/lib}/__snapshots__/filter.test.ts.snap +0 -0
@@ -43,7 +43,7 @@ class StreakCalculator {
43
43
  }
44
44
 
45
45
  private async fetchAllPractices(): Promise<PracticeData> {
46
- const query = await db.practices.queryAll()
46
+ const query = await db.practices.getAll()
47
47
 
48
48
  return query.data.reduce((acc, practice) => {
49
49
  acc[practice.date] = acc[practice.date] || []
@@ -0,0 +1,151 @@
1
+ # Skipped Tests Reference
2
+
3
+ This document tracks all skipped tests and why they are skipped. Tests are divided into two categories:
4
+
5
+ 1. **Skipped for CI** — were passing but depend on live external services; skipped to enable clean CI runs
6
+ 2. **Previously skipped — failing or unknown** — were already skipped before CI work; many confirmed failing
7
+
8
+ The goal is to eventually move all Category 1 tests into a dedicated integration/live test suite, and to triage Category 2 tests as either fixable or retired.
9
+
10
+ ---
11
+
12
+ ## Category 1: Skipped for CI (were passing, have external dependencies)
13
+
14
+ ### `test/sanityQueryService.test.js` — Sanity CMS
15
+
16
+ All tests in this file call real Sanity GROQ queries via `initializeTestService(true)`.
17
+
18
+ | Test | Dependency |
19
+ |---|---|
20
+ | fetchSongById | Sanity |
21
+ | fetchReturning | Sanity |
22
+ | fetchLeaving | Sanity |
23
+ | fetchComingSoon | Sanity |
24
+ | fetchSanity-WithPostProcess | Sanity |
25
+ | fetchSanityPostProcess | Sanity |
26
+ | fetchByRailContentIds | Sanity |
27
+ | fetchByRailContentIds_Order | Sanity |
28
+ | fetchUpcomingNewReleases | Sanity |
29
+ | fetchLessonContent | Sanity |
30
+ | fetchAllSongsInProgress | Sanity |
31
+ | fetchNewReleases | Sanity |
32
+ | fetchAllWorkouts | Sanity |
33
+ | fetchAllInstructorField | Sanity |
34
+ | fetchAllInstructors | Sanity |
35
+ | fetchAll-CustomFields | Sanity |
36
+ | fetchRelatedLessons | Sanity |
37
+ | fetchRelatedLessons-quick-tips | Sanity |
38
+ | fetchRelatedLessons-in-rhythm | Sanity |
39
+ | getSortOrder | Sanity (describe block requires live auth) |
40
+ | fetchAll-WithProgress | Sanity |
41
+ | fetchAllFilterOptions-WithProgress | Sanity |
42
+ | fetchAll-IncludedFields | Sanity |
43
+ | fetchAll-IncludedFields-rudiment-multiple-gear | Sanity |
44
+ | fetchByReference | Sanity |
45
+ | fetchScheduledReleases | Sanity |
46
+ | fetchAll-GroupBy-Artists | Sanity |
47
+ | fetchAll-GroupBy-Instructors | Sanity |
48
+ | fetchMetadata | Sanity |
49
+ | fetchMetadata-Coach-Lessons | Sanity |
50
+ | invalidContentType | Sanity (describe block requires live auth) |
51
+ | metaDataForLessons | Sanity |
52
+ | metaDataForSongs | Sanity |
53
+ | fetchAllFilterOptionsLessons | Sanity |
54
+ | fetchAllFilterOptionsSongs | Sanity |
55
+ | fetchLiveEvent | Sanity |
56
+ | fetchRelatedLessons-pack-bundle-lessons | Sanity |
57
+ | fetchRelatedLessons-course-parts | Sanity |
58
+ | fetchRelatedLessons-song-tutorial-children | Sanity |
59
+ | fetchMetadata (second) | Sanity |
60
+
61
+ ### `test/content.test.js` — Sanity CMS + Railcontent API
62
+
63
+ | Test | Dependency |
64
+ |---|---|
65
+ | getTabResults-Singles | Sanity + Railcontent |
66
+ | getTabResults-Courses | Sanity + Railcontent |
67
+ | getTabResults-Type-Explore-All | Sanity + Railcontent |
68
+
69
+ ### `test/user/permissions.test.js` — Railcontent API
70
+
71
+ | Test | Dependency |
72
+ |---|---|
73
+ | fetchUserPermissions | Railcontent `fetchUserPermissionsData` |
74
+
75
+ ---
76
+
77
+ ## Category 2: Previously Skipped — Failing or Unknown State
78
+
79
+ These were already skipped before CI work. Status is noted where confirmed.
80
+
81
+ ### `test/sanityQueryService.test.js`
82
+
83
+ | Test | Status | Failure Reason |
84
+ |---|---|---|
85
+ | fetchSongArtistCount | Unknown | — |
86
+ | fetchUpcomingEvents | Unknown | — |
87
+ | fetchLessonContent-PlayAlong-containts-array-of-videos | Unknown | — |
88
+ | fetchAllSortField | Unknown | — |
89
+ | fetchRelatedLessons-child | Unknown | — |
90
+ | fetchPackAll | Unknown | — |
91
+ | fetchAllPacks | Unknown | — |
92
+ | fetchAll-IncludedFields-multiple | Unknown | — |
93
+ | fetchAll-IncludedFields-playalong-multiple | Unknown | — |
94
+ | fetchAll-IncludedFields-coaches-multiple-focus | Unknown | — |
95
+ | fetchAll-IncludedFields-songs-multiple-instrumentless | Unknown | — |
96
+ | fetchAll-GroupBy-Genre | Unknown | — |
97
+ | fetchShowsData | Unknown | — |
98
+ | fetchShowsData-OddTimes | Unknown | — |
99
+ | fetchTopLevelParentId | Unknown | — |
100
+ | fetchHierarchy | Unknown | — |
101
+ | fetchTopLeveldrafts | Failing | Timeout (>5s) |
102
+ | fetchCommentData | Failing | `null.forEach` — Sanity returns null for content IDs |
103
+ | baseConstructor | Unknown | — |
104
+ | withOnlyFilterAvailableStatuses | Unknown | — |
105
+ | withContentStatusAndFutureScheduledContent | Unknown | — |
106
+ | withUserPermissions | Unknown | — |
107
+ | withUserPermissionsForPlusUser | Unknown | — |
108
+ | withPermissionBypass | Unknown | — |
109
+ | withPublishOnRestrictions | Unknown | — |
110
+ | fetchAllFilterOptions | Unknown | — |
111
+ | fetchAllFilterOptions-Rudiment | Unknown | — |
112
+ | fetchAllFilterOptions-PlayAlong | Unknown | — |
113
+ | fetchAllFilterOptions-Coaches | Unknown | — |
114
+ | fetchAllFilterOptions-filter-selected | Failing | `null.meta` — API returns null for filter combination |
115
+ | customBrandTypeExists | Unknown | — |
116
+ | withCommon | Unknown | — |
117
+ | fetchOtherSongVersions | Failing | 0 results — content is drafted/admin-only |
118
+ | fetchLessonsFeaturingThisContent | Failing | 0 results — content is drafted/admin-only |
119
+ | getRecommendedForYou | Failing | `SyncError: Intended user ID does not match` |
120
+ | getRecommendedForYou-SeeAll | Failing | `SyncError: Intended user ID does not match` |
121
+
122
+ ### `test/content.test.js`
123
+
124
+ | Test | Status | Failure Reason |
125
+ |---|---|---|
126
+ | getTabResults-Filters | Failing | Timeout (>5s) |
127
+ | getTabResults-Type-Filter | Failing | `TypeError: null.entity` — Sanity returns null |
128
+ | getContentRows | Unknown |Sanity & pw-recommender |
129
+ | getNewAndUpcoming | Failing | Timeout (>5s) |
130
+ | getScheduleContentRows | Failing | Timeout (>5s) |
131
+ | getSpecificScheduleContentRow | Failing | Timeout (>5s) |
132
+
133
+ ### `test/contentProgress.test.js`
134
+
135
+ | Test | Status | Failure Reason |
136
+ |---|---|---|
137
+ | get-Songs-Tutorials | Unknown | Live Sanity call |
138
+ | get-Songs-Transcriptions | Unknown | Live Sanity call |
139
+ | get-Songs-Play-Alongs | Unknown | Live Sanity call |
140
+
141
+ ### `test/progressRows.test.js`
142
+
143
+ | Test | Status | Failure Reason |
144
+ |---|---|---|
145
+ | check progress rows logic | Failing | Stale mock data — not a live API issue; mock data no longer reflects current data shape |
146
+
147
+ ### `test/learningPaths.test.js`
148
+
149
+ | Test | Status | Failure Reason |
150
+ |---|---|---|
151
+ | learningPathCompletion | Unknown | Uses `initializeTestService(true)` — live API |
@@ -1,7 +1,7 @@
1
1
  import { globalConfig, initializeService } from '../src'
2
2
  import { LocalStorageMock } from './localStorageMock'
3
- import { initializeSyncManager } from './sync/initialize-sync-manager'
4
3
  const railContentModule = require('../src/services/railcontent.js')
4
+ const awardDefsModule = require('../src/services/awards/internal/award-definitions.js')
5
5
  let token = null
6
6
  let userId = process.env.RAILCONTENT_USER_ID ?? null
7
7
 
@@ -51,11 +51,10 @@ export async function initializeTestService(useLive = false, isAdmin = false) {
51
51
  localStorage: new LocalStorageMock(),
52
52
  isMA: true,
53
53
  }
54
+ jest.spyOn(awardDefsModule.awardDefinitions, 'initialize').mockResolvedValue()
54
55
  initializeService(config)
55
56
  // Mock user permissions
56
57
  let permissionsMock = jest.spyOn(railContentModule, 'fetchUserPermissionsData')
57
58
  let permissionsData = { permissions: [108, 91, 92], isAdmin: isAdmin }
58
59
  permissionsMock.mockImplementation(() => permissionsData)
59
-
60
- initializeSyncManager(userId)
61
60
  }
@@ -1,35 +1,19 @@
1
- import { initializeTestService } from './initializeTests.js'
2
- import {getContentRows, getNewAndUpcoming, getScheduleContentRows, getTabResults} from '../src/services/content.js'
1
+ import { initializeTestService } from '../initializeTests.js'
2
+ import {getContentRows, getNewAndUpcoming, getScheduleContentRows, getTabResults} from '../../src/index.js'
3
3
 
4
4
  // Mock fetchContentProgress before other modules load
5
- jest.mock('../src/services/railcontent.js', () => ({
6
- ...jest.requireActual('../src/services/railcontent.js'),
5
+ jest.mock('../../src/services/railcontent.js', () => ({
6
+ ...jest.requireActual('../../src/services/railcontent.js'),
7
7
  fetchContentProgress: jest.fn().mockResolvedValue({ version: 1, data: {} })
8
8
  }))
9
9
 
10
- const railContentModule = require('../src/services/railcontent.js')
10
+ const railContentModule = require('../../src/services/railcontent.js')
11
11
 
12
12
  describe('content', function () {
13
- beforeEach(() => {
14
- initializeTestService()
13
+ beforeAll(async () => {
14
+ await initializeTestService(true)
15
15
  })
16
16
 
17
- // test('getLessonContentRows', async () => {
18
- // const results = await getLessonContentRows()
19
- // console.log(results)
20
- // })
21
-
22
- // test('getTabResults-For-You', async () => {
23
- // const results = await getTabResults('drumeo','lessons','For You')
24
- // console.log(results)
25
- // expect(results.type).toBeDefined()
26
- // expect(results.type).toBe('sections')
27
- // expect(results.data).toBeDefined()
28
- // expect(results.meta).toBeDefined()
29
- // expect(results.meta.filters).toBeDefined()
30
- // expect(results.meta.sort).toBeDefined()
31
- // })
32
-
33
17
  test('getTabResults-Singles', async () => {
34
18
  const results = await getTabResults('drumeo','lessons','Individuals', {selectedFilters:['difficulty,All','difficulty,Beginner'], sort:'-published_on'})
35
19
  console.log(results)
@@ -0,0 +1,73 @@
1
+ import { initializeTestService } from '../initializeTests.js'
2
+ import {getTabResults} from '../../src/index.js';
3
+ import {tutorialsLessonTypes, transcriptionsLessonTypes, playAlongLessonTypes} from "../../src/contentTypeConfig.js";
4
+
5
+ let mockProgressRecords = []
6
+
7
+ jest.mock('../../src/services/sync/repository-proxy.ts', () => {
8
+ const mockFns = {
9
+ contentProgress: {
10
+ getOneProgressByContentId: jest.fn().mockImplementation((contentId) => {
11
+ const record = mockProgressRecords.find(r => r.content_id === contentId)
12
+ return Promise.resolve({ data: record || null })
13
+ }),
14
+ getSomeProgressByContentIds: jest.fn().mockImplementation((contentIds) => {
15
+ const records = mockProgressRecords.filter(r => contentIds.includes(r.content_id))
16
+ return Promise.resolve({ data: records })
17
+ }),
18
+ started: jest.fn().mockImplementation((limit, opts) => {
19
+ const startedIds = mockProgressRecords
20
+ .filter(r => r.state === 'started')
21
+ .sort((a, b) => b.updated_at - a.updated_at)
22
+ .map(r => r.content_id)
23
+ const result = limit ? startedIds.slice(0, limit) : startedIds
24
+ return Promise.resolve(opts?.onlyIds !== false ? result : result.map(id => ({ content_id: id })))
25
+ }),
26
+ startedOrCompleted: jest.fn().mockImplementation(() => {
27
+ const records = mockProgressRecords
28
+ .filter(r => r.state === 'started' || r.state === 'completed')
29
+ .sort((a, b) => b.updated_at - a.updated_at)
30
+ return Promise.resolve({ data: records })
31
+ }),
32
+ },
33
+ practices: {
34
+ queryAll: jest.fn().mockResolvedValue({ data: [] }),
35
+ getAll: jest.fn().mockResolvedValue({ data: [] }),
36
+ },
37
+ }
38
+ return { default: mockFns, ...mockFns }
39
+ })
40
+
41
+ describe('contentProgressDataContext', function () {
42
+ beforeEach(() => {
43
+ initializeTestService()
44
+ mockProgressRecords = [
45
+ { content_id: 234191, state: 'started', progress_percent: 6, updated_at: 1731108082, last_interacted_a_la_carte: 1731108082 },
46
+ { content_id: 233955, state: 'started', progress_percent: 1, updated_at: 1731108083 },
47
+ { content_id: 259426, state: 'completed', progress_percent: 100, updated_at: 1731108085 },
48
+ { content_id: 190417, state: 'started', progress_percent: 6, updated_at: 1731108082 },
49
+ { content_id: 407665, state: 'started', progress_percent: 6, updated_at: 1740120139 },
50
+ { content_id: 412986, state: 'completed', progress_percent: 100, updated_at: 1731108085 },
51
+ ]
52
+ })
53
+
54
+ test.skip('get-Songs-Tutorials', async () => {
55
+ const result = await getTabResults('pianote', 'songs', 'Tutorials')
56
+ expect(result.type).toStrictEqual('catalog')
57
+ expect(result.data).toBeDefined()
58
+ expect(tutorialsLessonTypes).toContain(result.data[0].type)
59
+ })
60
+
61
+ test.skip('get-Songs-Transcriptions', async () => {
62
+ const result = await getTabResults('pianote', 'songs', 'Transcriptions')
63
+ expect(result.type).toStrictEqual('catalog')
64
+ expect(result.data).toBeDefined()
65
+ expect(transcriptionsLessonTypes).toContain(result.data[0].type)
66
+ })
67
+
68
+ test.skip('get-Songs-Play-Alongs', async () => {
69
+ const result = await getTabResults('drumeo', 'songs', 'Play-Alongs', { selectedFilters: ['difficulty,Expert'] })
70
+ expect(playAlongLessonTypes).toContain(result.data[0].type)
71
+ expect(result.data[0].difficulty_string).toStrictEqual('Expert')
72
+ })
73
+ })
@@ -1,6 +1,5 @@
1
- import { initializeTestService } from './initializeTests.js'
2
- import { getLessonContentRows, getTabResults } from '../src/services/content.js'
3
- import {getActiveDiscussions} from "../src/services/forums/forums";
1
+ import { initializeTestService } from '../initializeTests.js'
2
+ import {getActiveDiscussions} from "../../src/services/forums/forums.ts";
4
3
 
5
4
  describe('forum', function () {
6
5
  beforeEach(() => {
@@ -14,5 +13,4 @@ describe('forum', function () {
14
13
  expect(results.meta).toBeDefined()
15
14
  })
16
15
 
17
-
18
16
  })