musora-content-services 2.158.2 → 2.159.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.
- package/.claude/settings.local.json +12 -0
- package/.github/workflows/automated-testing.yml +21 -1
- package/CHANGELOG.md +15 -0
- package/README.md +21 -2
- package/jest.config.js +1 -4
- package/jest.integration.config.js +6 -0
- package/jest.live.config.js +1 -5
- package/package.json +5 -2
- package/src/contentTypeConfig.js +8 -5
- package/src/index.d.ts +2 -6
- package/src/index.js +2 -6
- package/src/services/content-org/learning-paths.ts +44 -39
- package/src/services/contentAggregator.js +1 -1
- package/src/services/contentProgress.js +216 -207
- package/src/services/offline/progress.ts +107 -27
- package/src/services/sanity.js +55 -64
- package/src/services/sync/models/ContentProgress.ts +50 -34
- package/src/services/sync/repositories/content-progress.ts +105 -92
- package/test/{unit → integration}/awards/award-exclusion-handling.test.ts +2 -2
- package/test/integration/content-progress/__mocks__/mocks.ts +104 -0
- package/test/integration/content-progress/contentProgress.test.ts +335 -0
- package/test/integration/content-progress/e2eOfflineProgress.test.ts +352 -0
- package/test/integration/content-progress/e2eProgress.test.ts +612 -0
- package/test/integration/content-progress/getters.test.ts +334 -0
- package/test/integration/content-progress/helpers.test.ts +263 -0
- package/test/integration/content-progress/offlineContentProgress.test.ts +226 -0
- package/test/integration/forums.test.ts +209 -0
- package/test/integration/initializeTestDB.ts +80 -0
- package/test/{unit → integration}/sync/fetch.test.ts +1 -1
- package/test/{unit → integration}/sync/repositories/content-likes.test.ts +1 -1
- package/test/{unit → integration}/sync/repositories/practices.test.ts +1 -1
- package/test/{unit → integration}/sync/repositories/progress.test.ts +1 -1
- package/test/{unit → integration}/sync/repositories/user-award-progress.test.ts +1 -1
- package/test/{unit → integration}/sync/store/cross-user-protection.test.ts +2 -2
- package/test/{unit → integration}/sync/store/store-idb.test.ts +2 -2
- package/test/{unit → integration}/sync/store/store.test.ts +2 -2
- package/test/unit/content-progress/bubbleTrickle.test.ts +322 -0
- package/test/unit/content-progress/helpers.test.ts +329 -0
- package/test/unit/content-progress/navigateTo.test.ts +381 -0
- package/test/unit/contentMetaData.test.ts +58 -0
- package/tools/generate-index.cjs +6 -3
- package/test/SKIPPED_TESTS.md +0 -151
- package/test/integration/content.test.js +0 -107
- package/test/integration/contentProgress.test.js +0 -73
- package/test/integration/forum.test.js +0 -16
- package/test/integration/sanityQueryService.test.js +0 -681
- package/test/unit/contentProgress.test.ts +0 -81
- /package/test/{unit → integration}/awards/internal/image-utils.test.ts +0 -0
- /package/test/{unit → integration}/infrastructure/FetchRequestExecutor.test.ts +0 -0
- /package/test/{unit → integration}/notifications.test.ts +0 -0
- /package/test/{unit → integration}/sync/adapters/idb-errors.test.ts +0 -0
- /package/test/{unit → integration}/sync/adapters/sqlite-errors.test.ts +0 -0
- /package/test/{unit → integration}/sync/repositories/user-award-progress.static.test.ts +0 -0
- /package/test/{unit → integration}/userActivity.test.ts +0 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { initializeTestService } from '../../initializeTests.js'
|
|
2
|
+
import {
|
|
3
|
+
buildNavigateTo,
|
|
4
|
+
findIncompleteLesson,
|
|
5
|
+
getNavigateTo,
|
|
6
|
+
getNavigateToForMethod,
|
|
7
|
+
} from '../../../src/services/contentProgress.js'
|
|
8
|
+
import { COLLECTION_TYPE } from '../../../src/services/sync/models/ContentProgress'
|
|
9
|
+
|
|
10
|
+
let mockProgressRecords: any[] = []
|
|
11
|
+
let mockLastInteracted: number | null = null
|
|
12
|
+
|
|
13
|
+
jest.mock('../../../src/services/sync/repository-proxy', () => {
|
|
14
|
+
const mockFns = {
|
|
15
|
+
contentProgress: {
|
|
16
|
+
getOneProgressByContentId: jest.fn().mockImplementation((contentId) => {
|
|
17
|
+
const record = mockProgressRecords.find(r => r.content_id === contentId)
|
|
18
|
+
return Promise.resolve({ data: record || null })
|
|
19
|
+
}),
|
|
20
|
+
getSomeProgressByContentIds: jest.fn().mockImplementation((contentIds) => {
|
|
21
|
+
const records = mockProgressRecords.filter(r => contentIds.includes(r.content_id))
|
|
22
|
+
return Promise.resolve({ data: records })
|
|
23
|
+
}),
|
|
24
|
+
mostRecentlyUpdatedId: jest.fn().mockImplementation(() => {
|
|
25
|
+
return Promise.resolve({ data: mockLastInteracted })
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
practices: {
|
|
29
|
+
queryAll: jest.fn().mockResolvedValue({ data: [] }),
|
|
30
|
+
getAll: jest.fn().mockResolvedValue({ data: [] }),
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
return { default: mockFns, ...mockFns }
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
jest.mock('../../../src/services/content-org/learning-paths', () => ({
|
|
37
|
+
getDailySession: jest.fn().mockResolvedValue(null),
|
|
38
|
+
onLearningPathCompletedActions: jest.fn().mockResolvedValue(undefined),
|
|
39
|
+
}))
|
|
40
|
+
|
|
41
|
+
jest.mock('../../../src/services/sanity.js', () => ({
|
|
42
|
+
getHierarchy: jest.fn().mockResolvedValue({ metadata: {}, parents: {}, children: {} }),
|
|
43
|
+
getHierarchies: jest.fn().mockResolvedValue({ metadata: {}, parents: {}, children: {} }),
|
|
44
|
+
getSanityDate: jest.fn((date: Date) => date.toISOString()),
|
|
45
|
+
}))
|
|
46
|
+
|
|
47
|
+
const { getDailySession } = jest.requireMock('../../../src/services/content-org/learning-paths')
|
|
48
|
+
|
|
49
|
+
const child = (id: number, type = 'lesson') => ({
|
|
50
|
+
id,
|
|
51
|
+
brand: 'drumeo',
|
|
52
|
+
thumbnail: '',
|
|
53
|
+
type,
|
|
54
|
+
published_on: null,
|
|
55
|
+
status: 'published',
|
|
56
|
+
children: null as any,
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
beforeEach(() => {
|
|
60
|
+
jest.clearAllMocks()
|
|
61
|
+
initializeTestService()
|
|
62
|
+
mockProgressRecords = []
|
|
63
|
+
mockLastInteracted = null
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
// ─── buildNavigateTo ──────────────────────────────────────────────────────────
|
|
67
|
+
|
|
68
|
+
describe('buildNavigateTo', () => {
|
|
69
|
+
test('null content returns null', () => {
|
|
70
|
+
expect(buildNavigateTo(null)).toBeNull()
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test('valid content returns correct shape', () => {
|
|
74
|
+
const content = {
|
|
75
|
+
id: 101,
|
|
76
|
+
brand: 'drumeo',
|
|
77
|
+
thumbnail: 'thumb.jpg',
|
|
78
|
+
type: 'lesson',
|
|
79
|
+
published_on: '2024-01-01',
|
|
80
|
+
status: 'published',
|
|
81
|
+
}
|
|
82
|
+
const result = buildNavigateTo(content)
|
|
83
|
+
expect(result).toEqual({
|
|
84
|
+
brand: 'drumeo',
|
|
85
|
+
thumbnail: 'thumb.jpg',
|
|
86
|
+
id: 101,
|
|
87
|
+
type: 'lesson',
|
|
88
|
+
published_on: '2024-01-01',
|
|
89
|
+
status: 'published',
|
|
90
|
+
child: null,
|
|
91
|
+
collection: null,
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
test('missing fields fall back to defaults', () => {
|
|
96
|
+
const result = buildNavigateTo({ id: 5 })
|
|
97
|
+
expect(result).toMatchObject({
|
|
98
|
+
brand: '',
|
|
99
|
+
thumbnail: '',
|
|
100
|
+
id: 5,
|
|
101
|
+
type: '',
|
|
102
|
+
published_on: null,
|
|
103
|
+
status: '',
|
|
104
|
+
child: null,
|
|
105
|
+
collection: null,
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
test('child and collection args pass through', () => {
|
|
110
|
+
const childObj = {
|
|
111
|
+
id: 200,
|
|
112
|
+
brand: 'drumeo',
|
|
113
|
+
thumbnail: '',
|
|
114
|
+
type: 'lesson',
|
|
115
|
+
published_on: null,
|
|
116
|
+
status: 'published',
|
|
117
|
+
}
|
|
118
|
+
const collection = { type: COLLECTION_TYPE.LEARNING_PATH, id: 999 }
|
|
119
|
+
const result = buildNavigateTo({ id: 100 }, childObj, collection)
|
|
120
|
+
expect(result?.child).toBe(childObj)
|
|
121
|
+
expect(result?.collection).toBe(collection)
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
// ─── findIncompleteLesson ─────────────────────────────────────────────────────
|
|
126
|
+
|
|
127
|
+
describe('findIncompleteLesson', () => {
|
|
128
|
+
describe('course type', () => {
|
|
129
|
+
test('finds first incomplete after currentContentId', () => {
|
|
130
|
+
const progresses = new Map([
|
|
131
|
+
[101, 'completed'],
|
|
132
|
+
[102, 'completed'],
|
|
133
|
+
[103, 'started'],
|
|
134
|
+
[104, ''],
|
|
135
|
+
])
|
|
136
|
+
expect(findIncompleteLesson(progresses, 102, 'course')).toBe(103)
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
// todo(BEHSTP-325): add a test "returns currentContentId if it's incomplete"
|
|
140
|
+
|
|
141
|
+
test('wraps to first when all after current are completed, even if some before are incomplete', () => {
|
|
142
|
+
const progresses = new Map([
|
|
143
|
+
[101, 'completed'],
|
|
144
|
+
[102, 'started'],
|
|
145
|
+
[103, 'completed'],
|
|
146
|
+
[104, 'completed'],
|
|
147
|
+
])
|
|
148
|
+
expect(findIncompleteLesson(progresses, 103, 'course')).toBe(101)
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
test('returns null when currentContentId not in ids', () => {
|
|
152
|
+
const progresses = new Map([
|
|
153
|
+
[101, 'started'],
|
|
154
|
+
[102, 'completed'],
|
|
155
|
+
])
|
|
156
|
+
expect(findIncompleteLesson(progresses, 999, 'course')).toBeNull()
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
describe('guided-course type', () => {
|
|
161
|
+
test('finds first incomplete regardless of position', () => {
|
|
162
|
+
const progresses = new Map([
|
|
163
|
+
[101, 'completed'],
|
|
164
|
+
[102, ''],
|
|
165
|
+
[103, 'started'],
|
|
166
|
+
])
|
|
167
|
+
expect(findIncompleteLesson(progresses, 103, 'guided-course')).toBe(102)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
test('returns first id when all completed', () => {
|
|
171
|
+
const progresses = new Map([
|
|
172
|
+
[101, 'completed'],
|
|
173
|
+
[102, 'completed'],
|
|
174
|
+
[103, 'completed'],
|
|
175
|
+
])
|
|
176
|
+
expect(findIncompleteLesson(progresses, 102, 'guided-course')).toBe(101)
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
describe('learning-path-v2 type', () => {
|
|
181
|
+
test('finds first incomplete regardless of position', () => {
|
|
182
|
+
const progresses = new Map([
|
|
183
|
+
[101, 'completed'],
|
|
184
|
+
[102, ''],
|
|
185
|
+
[103, 'started'],
|
|
186
|
+
])
|
|
187
|
+
expect(findIncompleteLesson(progresses, 103, 'learning-path-v2')).toBe(102)
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
test('returns first id when all completed', () => {
|
|
191
|
+
const progresses = new Map([
|
|
192
|
+
[101, 'completed'],
|
|
193
|
+
[102, 'completed'],
|
|
194
|
+
[103, 'completed'],
|
|
195
|
+
])
|
|
196
|
+
expect(findIncompleteLesson(progresses, 102, 'learning-path-v2')).toBe(101)
|
|
197
|
+
})
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
describe('Map vs Object input', () => {
|
|
201
|
+
test('works with Map input', () => {
|
|
202
|
+
const progresses = new Map([
|
|
203
|
+
[101, 'completed'],
|
|
204
|
+
[102, ''],
|
|
205
|
+
])
|
|
206
|
+
expect(findIncompleteLesson(progresses, 101, 'course')).toBe(102)
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
test('works with Object input', () => {
|
|
210
|
+
const progresses = { 101: 'completed', 102: '' }
|
|
211
|
+
expect(findIncompleteLesson(progresses, 101, 'course')).toBe(102)
|
|
212
|
+
})
|
|
213
|
+
})
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
// ─── getNavigateTo ────────────────────────────────────────────────────────────
|
|
217
|
+
|
|
218
|
+
describe('getNavigateTo', () => {
|
|
219
|
+
test('null entry in data array skipped', async () => {
|
|
220
|
+
const result = await getNavigateTo([null as any, { id: 1, type: 'lesson', children: [] }])
|
|
221
|
+
expect(result[1]).toBeNull()
|
|
222
|
+
expect(Object.keys(result)).not.toContain('null')
|
|
223
|
+
expect(Object.keys(result)).not.toContain('undefined')
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
test('non-navigable type returns null', async () => {
|
|
227
|
+
const result = await getNavigateTo([{ id: 1, type: 'lesson', children: [child(101)] }])
|
|
228
|
+
expect(result[1]).toBeNull()
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
test('null children returns null', async () => {
|
|
232
|
+
const result = await getNavigateTo([{ id: 1, type: 'course', children: null }])
|
|
233
|
+
expect(result[1]).toBeNull()
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
test('empty children after filtering nulls returns null', async () => {
|
|
237
|
+
const result = await getNavigateTo([{ id: 1, type: 'course', children: [null, null] }])
|
|
238
|
+
expect(result[1]).toBeNull()
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
test('content not started navigates to first child', async () => {
|
|
242
|
+
const result = await getNavigateTo([{ id: 1, type: 'course', children: [child(101), child(102)] }])
|
|
243
|
+
expect(result[1]).toMatchObject({ id: 101 })
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
test('course started lastInteracted started navigates to lastInteracted child', async () => {
|
|
247
|
+
mockProgressRecords = [
|
|
248
|
+
{ content_id: 1, state: 'started', progress_percent: 50, updated_at: 1000 },
|
|
249
|
+
{ content_id: 101, state: 'started', progress_percent: 100, updated_at: 900 },
|
|
250
|
+
{ content_id: 102, state: 'started', progress_percent: 30, updated_at: 1000 },
|
|
251
|
+
]
|
|
252
|
+
mockLastInteracted = 101
|
|
253
|
+
const result = await getNavigateTo([{ id: 1, type: 'course', children: [child(101), child(102)] }])
|
|
254
|
+
expect(result[1]).toMatchObject({ id: 101 })
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
test('course started lastInteracted completed navigates to first incomplete after lastInteracted', async () => {
|
|
258
|
+
mockProgressRecords = [
|
|
259
|
+
{ content_id: 1, state: 'started', progress_percent: 60, updated_at: 1000 },
|
|
260
|
+
{ content_id: 101, state: 'completed', progress_percent: 100, updated_at: 900 },
|
|
261
|
+
{ content_id: 102, state: 'completed', progress_percent: 100, updated_at: 1000 },
|
|
262
|
+
{ content_id: 103, state: 'started', progress_percent: 20, updated_at: 800 },
|
|
263
|
+
]
|
|
264
|
+
mockLastInteracted = 101
|
|
265
|
+
const result = await getNavigateTo([{ id: 1, type: 'course', children: [child(101), child(102), child(103)] }])
|
|
266
|
+
expect(result[1]).toMatchObject({ id: 103 })
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
test('course started all children completed wraps to first child', async () => {
|
|
270
|
+
mockProgressRecords = [
|
|
271
|
+
{ content_id: 1, state: 'started', progress_percent: 100, updated_at: 1000 },
|
|
272
|
+
{ content_id: 101, state: 'completed', progress_percent: 100, updated_at: 900 },
|
|
273
|
+
{ content_id: 102, state: 'completed', progress_percent: 100, updated_at: 1000 },
|
|
274
|
+
]
|
|
275
|
+
mockLastInteracted = 102
|
|
276
|
+
const result = await getNavigateTo([{ id: 1, type: 'course', children: [child(101), child(102)] }])
|
|
277
|
+
expect(result[1]).toMatchObject({ id: 101 })
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
test('guided-course started navigates to first incomplete child', async () => {
|
|
281
|
+
mockProgressRecords = [
|
|
282
|
+
{ content_id: 1, state: 'started', progress_percent: 50, updated_at: 1000 },
|
|
283
|
+
{ content_id: 101, state: 'completed', progress_percent: 100, updated_at: 900 },
|
|
284
|
+
]
|
|
285
|
+
mockLastInteracted = 101
|
|
286
|
+
const result = await getNavigateTo([{
|
|
287
|
+
id: 1,
|
|
288
|
+
type: 'guided-course',
|
|
289
|
+
children: [child(101), child(102), child(103)],
|
|
290
|
+
}])
|
|
291
|
+
expect(result[1]).toMatchObject({ id: 102 })
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
describe.each(['course', 'skill-pack', 'song-tutorial'])('course-flow type %s', (type) => {
|
|
295
|
+
test('lastInteracted completed → first incomplete after lastInteracted', async () => {
|
|
296
|
+
mockProgressRecords = [
|
|
297
|
+
{ content_id: 1, state: 'started', progress_percent: 50, updated_at: 1000 },
|
|
298
|
+
{ content_id: 101, state: '', progress_percent: 0, updated_at: 0 },
|
|
299
|
+
{ content_id: 102, state: 'completed', progress_percent: 100, updated_at: 1000 },
|
|
300
|
+
{ content_id: 103, state: '', progress_percent: 0, updated_at: 0 },
|
|
301
|
+
]
|
|
302
|
+
mockLastInteracted = 102
|
|
303
|
+
const result = await getNavigateTo([{ id: 1, type, children: [child(101), child(102), child(103)] }])
|
|
304
|
+
expect(result[1]).toMatchObject({ id: 103 })
|
|
305
|
+
})
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
describe.each(['guided-course', COLLECTION_TYPE.LEARNING_PATH])('guided-course-flow type %s', (type) => {
|
|
309
|
+
test('finds first incomplete regardless of lastInteracted position', async () => {
|
|
310
|
+
mockProgressRecords = [
|
|
311
|
+
{ content_id: 1, state: 'started', progress_percent: 50, updated_at: 1000 },
|
|
312
|
+
{ content_id: 101, state: '', progress_percent: 0, updated_at: 0 },
|
|
313
|
+
{ content_id: 102, state: 'completed', progress_percent: 100, updated_at: 1000 },
|
|
314
|
+
{ content_id: 103, state: '', progress_percent: 0, updated_at: 0 },
|
|
315
|
+
]
|
|
316
|
+
mockLastInteracted = 102
|
|
317
|
+
const result = await getNavigateTo([{ id: 1, type, children: [child(101), child(102), child(103)] }])
|
|
318
|
+
expect(result[1]).toMatchObject({ id: 101 })
|
|
319
|
+
})
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
// need more tests to support other types and potentially other logic branches.
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
// ─── getNavigateToForMethod ───────────────────────────────────────────────────
|
|
326
|
+
|
|
327
|
+
describe('getNavigateToForMethod', () => {
|
|
328
|
+
const lpContent = (id: number, children: any[]) => ({
|
|
329
|
+
id,
|
|
330
|
+
brand: 'drumeo',
|
|
331
|
+
thumbnail: '',
|
|
332
|
+
type: COLLECTION_TYPE.LEARNING_PATH,
|
|
333
|
+
published_on: null,
|
|
334
|
+
status: 'published',
|
|
335
|
+
children,
|
|
336
|
+
record_id: `${id}:${COLLECTION_TYPE.LEARNING_PATH}:${id}`,
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
const nonLpContent = (id: number) => ({
|
|
340
|
+
id,
|
|
341
|
+
brand: 'drumeo',
|
|
342
|
+
thumbnail: '',
|
|
343
|
+
type: 'course',
|
|
344
|
+
published_on: null,
|
|
345
|
+
status: 'published',
|
|
346
|
+
children: [child(201), child(202)],
|
|
347
|
+
record_id: `${id}:self:0`,
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
test('non-LP content type returns null', async () => {
|
|
351
|
+
const result = await getNavigateToForMethod([nonLpContent(1)])
|
|
352
|
+
expect(result[1]).toBeNull()
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
test('LP type with no daily session navigates to first incomplete child', async () => {
|
|
356
|
+
getDailySession.mockResolvedValueOnce(null)
|
|
357
|
+
const result = await getNavigateToForMethod([lpContent(10, [child(301), child(302), child(303)])])
|
|
358
|
+
expect(result[10]).toMatchObject({ id: 301 })
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
test('LP type with active learning path and daily session navigates using daily session', async () => {
|
|
362
|
+
mockProgressRecords = [
|
|
363
|
+
{ content_id: 301, state: 'completed', progress_percent: 100, updated_at: 900 },
|
|
364
|
+
]
|
|
365
|
+
getDailySession.mockResolvedValueOnce({
|
|
366
|
+
active_learning_path_id: 10,
|
|
367
|
+
daily_session: [{ content_ids: [301, 302] }],
|
|
368
|
+
})
|
|
369
|
+
const result = await getNavigateToForMethod([lpContent(10, [child(300), child(301), child(302)])])
|
|
370
|
+
expect(result[10]).toMatchObject({ id: 302 })
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
test('null content entries skipped', async () => {
|
|
374
|
+
getDailySession.mockResolvedValueOnce(null)
|
|
375
|
+
const validContent = lpContent(10, [child(301)])
|
|
376
|
+
const result = await getNavigateToForMethod([validContent, null as any])
|
|
377
|
+
expect(Object.keys(result)).toContain('10')
|
|
378
|
+
expect(Object.keys(result)).not.toContain('null')
|
|
379
|
+
expect(Object.keys(result)).not.toContain('undefined')
|
|
380
|
+
})
|
|
381
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { processMetadata } from '@/contentMetaData'
|
|
2
|
+
|
|
3
|
+
describe('processMetadata', () => {
|
|
4
|
+
test('returns null for unknown brand and type', () => {
|
|
5
|
+
expect(processMetadata('unknown', 'unknown')).toBeNull()
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
test('returns null for unknown type on known brand', () => {
|
|
9
|
+
expect(processMetadata('drumeo', 'unknown-type')).toBeNull()
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('returns expected shape for known brand and type', () => {
|
|
13
|
+
const result = processMetadata('drumeo', 'lessons')
|
|
14
|
+
|
|
15
|
+
expect(result).not.toBeNull()
|
|
16
|
+
expect(result.type).toBe('lessons')
|
|
17
|
+
expect(result.name).toBeDefined()
|
|
18
|
+
expect(result.sort).toBeDefined()
|
|
19
|
+
expect(result.tabs).toBeDefined()
|
|
20
|
+
expect(Array.isArray(result.tabs)).toBe(true)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test('does not include filters when withFilters is false', () => {
|
|
24
|
+
const result = processMetadata('drumeo', 'lessons')
|
|
25
|
+
|
|
26
|
+
expect(result.filters).toBeUndefined()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test('includes filters when withFilters is true', () => {
|
|
30
|
+
const result = processMetadata('drumeo', 'lessons', true)
|
|
31
|
+
|
|
32
|
+
expect(result.filters).toBeDefined()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test('brand-specific filters differ between brands for the same type', () => {
|
|
36
|
+
const drumeo = processMetadata('drumeo', 'lessons', true)
|
|
37
|
+
const pianote = processMetadata('pianote', 'lessons', true)
|
|
38
|
+
|
|
39
|
+
expect(JSON.stringify(drumeo.filters)).not.toBe(JSON.stringify(pianote.filters))
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
test('shared structure is consistent across brands for the same type', () => {
|
|
43
|
+
const drumeo = processMetadata('drumeo', 'lessons')
|
|
44
|
+
const pianote = processMetadata('pianote', 'lessons')
|
|
45
|
+
|
|
46
|
+
expect(drumeo.type).toBe(pianote.type)
|
|
47
|
+
expect(drumeo.name).toBe(pianote.name)
|
|
48
|
+
expect(JSON.stringify(drumeo.tabs)).toBe(JSON.stringify(pianote.tabs))
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
test('songs tabs are brand-specific based on song types config', () => {
|
|
52
|
+
const result = processMetadata('drumeo', 'songs')
|
|
53
|
+
|
|
54
|
+
expect(result).not.toBeNull()
|
|
55
|
+
expect(result.tabs.length).toBeGreaterThan(0)
|
|
56
|
+
expect(result.tabs[0].name).toBe('For You')
|
|
57
|
+
})
|
|
58
|
+
})
|
package/tools/generate-index.cjs
CHANGED
|
@@ -52,11 +52,14 @@ function extractExportedFunctions(filePath) {
|
|
|
52
52
|
* @returns {string[]}
|
|
53
53
|
*/
|
|
54
54
|
function getExclusionList(fileContent) {
|
|
55
|
-
const excludeRegex = /const\s+excludeFromGeneratedIndex\s*=\s*\[(
|
|
55
|
+
const excludeRegex = /const\s+excludeFromGeneratedIndex\s*=\s*\[([\s\S]*?)\]/
|
|
56
56
|
const excludeMatch = fileContent.match(excludeRegex)
|
|
57
57
|
let excludedFunctions = []
|
|
58
58
|
if (excludeMatch) {
|
|
59
|
-
excludedFunctions = excludeMatch[1]
|
|
59
|
+
excludedFunctions = excludeMatch[1]
|
|
60
|
+
.split(',')
|
|
61
|
+
.map((name) => name.trim().replace(/['"`]/g, ''))
|
|
62
|
+
.filter(Boolean)
|
|
60
63
|
}
|
|
61
64
|
return excludedFunctions
|
|
62
65
|
}
|
|
@@ -80,7 +83,7 @@ treeElements.forEach((treeNode) => {
|
|
|
80
83
|
addFunctionsToFileExports(filePath, treeNode)
|
|
81
84
|
} else if (fs.lstatSync(filePath).isDirectory()) {
|
|
82
85
|
|
|
83
|
-
// Check for
|
|
86
|
+
// Check for .= file to skip this directory
|
|
84
87
|
if (fs.existsSync(path.join(filePath, '.indexignore'))) {
|
|
85
88
|
console.log(`Skipping directory: ${treeNode} due to .indexignore`)
|
|
86
89
|
return
|
package/test/SKIPPED_TESTS.md
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
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 |
|