musora-content-services 2.167.2 → 2.167.3
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/.agent/decisions/2026-07-20-mu2-1724-songs-lessons-counts.md +33 -0
- package/.agent/decisions/2026-07-20-query-builder-tostring.md +37 -0
- package/CHANGELOG.md +8 -0
- package/package.json +2 -1
- package/src/contentTypeConfig.js +1 -0
- package/src/lib/sanity/query.ts +5 -0
- package/src/services/config.js +15 -0
- package/src/services/content/artist.ts +1 -3
- package/src/services/content/counts.ts +47 -0
- package/src/services/content/genre.ts +1 -3
- package/src/services/content/instructor.ts +1 -3
- package/src/services/userActivity.js +2 -0
- package/src/version-info.js +1 -0
- package/.claude/settings.local.json +0 -53
- package/test/initializeTests.js +0 -60
- package/test/integration/awards/award-exclusion-handling.test.ts +0 -275
- package/test/integration/awards/internal/image-utils.test.ts +0 -86
- package/test/integration/content-progress/__mocks__/mocks.ts +0 -104
- package/test/integration/content-progress/contentProgress.test.ts +0 -335
- package/test/integration/content-progress/e2eOfflineProgress.test.ts +0 -352
- package/test/integration/content-progress/e2eProgress.test.ts +0 -612
- package/test/integration/content-progress/getters.test.ts +0 -334
- package/test/integration/content-progress/helpers.test.ts +0 -263
- package/test/integration/content-progress/offlineContentProgress.test.ts +0 -226
- package/test/integration/forums.test.ts +0 -209
- package/test/integration/infrastructure/FetchRequestExecutor.test.ts +0 -88
- package/test/integration/initializeTestDB.ts +0 -80
- package/test/integration/learning-paths.test.ts +0 -854
- package/test/integration/notifications.test.ts +0 -178
- package/test/integration/progress-row/content-card.test.ts +0 -283
- package/test/integration/sync/adapters/idb-errors.test.ts +0 -144
- package/test/integration/sync/adapters/sqlite-errors.test.ts +0 -173
- package/test/integration/sync/fetch.test.ts +0 -224
- package/test/integration/sync/repositories/content-likes.test.ts +0 -99
- package/test/integration/sync/repositories/practices.test.ts +0 -179
- package/test/integration/sync/repositories/progress.test.ts +0 -245
- package/test/integration/sync/repositories/user-award-progress.static.test.ts +0 -68
- package/test/integration/sync/repositories/user-award-progress.test.ts +0 -387
- package/test/integration/sync/store/cross-user-protection.test.ts +0 -217
- package/test/integration/sync/store/store-idb.test.ts +0 -180
- package/test/integration/sync/store/store.test.ts +0 -361
- package/test/integration/user/permissions.test.js +0 -20
- package/test/integration/userActivity.test.ts +0 -102
- package/test/live/README.md +0 -29
- package/test/live/content.test.js +0 -116
- package/test/localStorageMock.js +0 -21
- package/test/log.js +0 -5
- package/test/mockData/award-definitions.js +0 -171
- package/test/mockData/mockData_fetchByRailContentIds_one_content.json +0 -35
- package/test/mockData/mockData_progress_content.json +0 -182
- package/test/mockData/mockData_sanity_progress_content.json +0 -1451
- package/test/mockData/mockData_user_practices.json +0 -9
- package/test/setupConsole.js +0 -6
- package/test/setupNetworkGuard.js +0 -3
- package/test/setupTimers.js +0 -13
- package/test/unit/HttpClient.test.ts +0 -267
- package/test/unit/awards/award-alacarte-observer.test.ts +0 -199
- package/test/unit/awards/award-auto-refresh.test.ts +0 -84
- package/test/unit/awards/award-calculations.test.ts +0 -34
- package/test/unit/awards/award-callbacks.test.ts +0 -144
- package/test/unit/awards/award-certificate-display.test.ts +0 -330
- package/test/unit/awards/award-collection-edge-cases.test.ts +0 -212
- package/test/unit/awards/award-collection-filtering.test.ts +0 -287
- package/test/unit/awards/award-completion-flow.test.ts +0 -306
- package/test/unit/awards/award-multi-lesson.test.ts +0 -243
- package/test/unit/awards/award-observer-integration.test.ts +0 -327
- package/test/unit/awards/award-query-messages.test.ts +0 -448
- package/test/unit/awards/award-user-collection.test.ts +0 -416
- package/test/unit/awards/duplicate-prevention.test.ts +0 -120
- package/test/unit/awards/helpers/completion-mock.ts +0 -56
- package/test/unit/awards/helpers/index.ts +0 -3
- package/test/unit/awards/helpers/mock-setup.ts +0 -79
- package/test/unit/awards/helpers/progress-emitter.ts +0 -45
- package/test/unit/awards/message-generator.test.ts +0 -162
- package/test/unit/content-progress/bubbleTrickle.test.ts +0 -322
- package/test/unit/content-progress/helpers.test.ts +0 -329
- package/test/unit/content-progress/navigateTo.test.ts +0 -392
- package/test/unit/contentLikes.test.ts +0 -62
- package/test/unit/contentMetaData.test.ts +0 -58
- package/test/unit/dataContext.test.ts +0 -38
- package/test/unit/dateUtils.test.ts +0 -188
- package/test/unit/endScreen.test.js +0 -712
- package/test/unit/eventsAPI.test.ts +0 -159
- package/test/unit/imageSRCBuilder.test.ts +0 -37
- package/test/unit/imageSRCVerify.test.ts +0 -155
- package/test/unit/infrastructure/DefaultHeaderProvider.test.ts +0 -39
- package/test/unit/infrastructure/sanity/ContentClient.test.ts +0 -168
- package/test/unit/infrastructure/sanity/DefaultConfigProvider.test.ts +0 -93
- package/test/unit/infrastructure/sanity/FetchQueryExecutor.test.ts +0 -174
- package/test/unit/infrastructure/sanity/SanityClient.test.ts +0 -140
- package/test/unit/lib/__snapshots__/filter.test.ts.snap +0 -5
- package/test/unit/lib/filter.test.ts +0 -1154
- package/test/unit/lib/lastUpdated.test.ts +0 -21
- package/test/unit/lib/query.test.ts +0 -1469
- package/test/unit/lib/sanity/decorators/base.test.ts +0 -368
- package/test/unit/lib/sanity/decorators/navigate-to.test.ts +0 -361
- package/test/unit/lib/sanity/decorators/need-access.test.ts +0 -89
- package/test/unit/lib/sanity/decorators/need-lifetime-upgrade.test.ts +0 -85
- package/test/unit/lib/sanity/decorators/page-type.test.ts +0 -81
- package/test/unit/playerSettings.test.ts +0 -73
- package/test/unit/progress-row/content-card.test.ts +0 -314
- package/test/unit/progress-row/playlist-card.test.ts +0 -104
- package/test/unit/progressRows.test.ts +0 -243
- package/test/unit/recommendations.test.js +0 -47
- package/test/unit/sanityQueryService.test.ts +0 -200
- package/test/unit/search.test.ts +0 -44
- package/test/unit/sentry.test.ts +0 -62
- package/test/unit/services/progress-internal/bubble.test.ts +0 -279
- package/test/unit/services/progress.test.ts +0 -396
- package/test/unit/streakMessage.test.ts +0 -251
- package/test/unit/sync/context.test.ts +0 -51
- package/test/unit/sync/effects/logout-warning.test.ts +0 -158
- package/test/unit/sync/effects/push-failure-notification.test.ts +0 -196
- package/test/unit/sync/errors/sync-errors.test.ts +0 -106
- package/test/unit/sync/errors/validators.test.ts +0 -61
- package/test/unit/sync/helpers/TestModel.ts +0 -44
- package/test/unit/sync/helpers/index.ts +0 -172
- package/test/unit/sync/manager.test.ts +0 -303
- package/test/unit/sync/models/user-award-progress.test.ts +0 -82
- package/test/unit/sync/resolver.test.ts +0 -229
- package/test/unit/sync/retry.test.ts +0 -314
- package/test/unit/sync/run-scope.test.ts +0 -23
- package/test/unit/sync/stale-record-cleanup.test.ts +0 -107
- package/test/unit/sync/store/push-coalescer.test.ts +0 -156
- package/test/unit/sync/store-configs.test.ts +0 -37
- package/test/unit/sync/telemetry/sync-telemetry.test.ts +0 -118
- package/test/unit/sync/utils/event-emitter.test.ts +0 -64
- package/test/unit/sync/utils/throttle.test.ts +0 -245
- package/test/unit/url-builder.test.ts +0 -72
- package/test/unit/user/account.test.ts +0 -66
- package/test/unit/user/permissions.test.js +0 -191
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
import { initializeTestDB } from '../initializeTestDB'
|
|
2
|
-
import {
|
|
3
|
-
contentStatusCompletedManyOffline,
|
|
4
|
-
contentStatusCompletedOffline,
|
|
5
|
-
contentStatusResetOffline,
|
|
6
|
-
contentStatusStartedOffline,
|
|
7
|
-
recordWatchSessionOffline,
|
|
8
|
-
} from '../../../src/services/offline/progress'
|
|
9
|
-
import { flushWatchSession } from '../../../src/services/contentProgress.js'
|
|
10
|
-
import {
|
|
11
|
-
COLLECTION_ID_SELF,
|
|
12
|
-
COLLECTION_TYPE,
|
|
13
|
-
CollectionParameter,
|
|
14
|
-
} from '../../../src/services/sync/models/ContentProgress'
|
|
15
|
-
import db from '../../../src/services/sync/repository-proxy'
|
|
16
|
-
import { clearHierarchies, HierarchyTreeNode } from './__mocks__/mocks'
|
|
17
|
-
|
|
18
|
-
jest.mock('../../../src/services/sanity.js', () => require('./__mocks__/mocks').mockSanity())
|
|
19
|
-
jest.mock('../../../src/services/content-org/learning-paths.ts', () => require('./__mocks__/mocks').mockLearningPaths())
|
|
20
|
-
jest.mock('../../../src/services/awards/internal/content-progress-observer', () => require('./__mocks__/mocks').mockContentProgressObserver())
|
|
21
|
-
jest.mock('../../../src/services/progress-events', () => require('./__mocks__/mocks').mockProgressEvents())
|
|
22
|
-
|
|
23
|
-
jest.mock('../../../src/services/userActivity', () => ({
|
|
24
|
-
trackUserPractice: jest.fn().mockResolvedValue(undefined),
|
|
25
|
-
}))
|
|
26
|
-
|
|
27
|
-
const selfCollection = { type: COLLECTION_TYPE.SELF, id: COLLECTION_ID_SELF }
|
|
28
|
-
const playlistCollection = { type: COLLECTION_TYPE.PLAYLIST, id: 123 }
|
|
29
|
-
const lpCollection = { type: COLLECTION_TYPE.LEARNING_PATH, id: 999 }
|
|
30
|
-
|
|
31
|
-
const testMetadata = { brand: 'test-brand', type: 'test-type', parent_id: 0 }
|
|
32
|
-
|
|
33
|
-
const learningPathsMock = jest.requireMock('../../../src/services/content-org/learning-paths.ts')
|
|
34
|
-
const sanityMock = jest.requireMock('../../../src/services/sanity.js')
|
|
35
|
-
|
|
36
|
-
const ctx = initializeTestDB()
|
|
37
|
-
|
|
38
|
-
beforeEach(() => {
|
|
39
|
-
clearHierarchies()
|
|
40
|
-
learningPathsMock.onLearningPathCompletedActions.mockClear()
|
|
41
|
-
learningPathsMock.getDailySession.mockClear()
|
|
42
|
-
sanityMock.getHierarchy.mockClear()
|
|
43
|
-
sanityMock.getHierarchies.mockClear()
|
|
44
|
-
sanityMock.getSanityDate.mockClear()
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
afterEach(() => {
|
|
48
|
-
expect(sanityMock.getHierarchy).not.toHaveBeenCalled()
|
|
49
|
-
expect(sanityMock.getHierarchies).not.toHaveBeenCalled()
|
|
50
|
-
expect(sanityMock.getSanityDate).not.toHaveBeenCalled()
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
type ExpectedProgress = {
|
|
54
|
-
state?: string
|
|
55
|
-
percent?: number
|
|
56
|
-
collection?: CollectionParameter
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function expectProgress(data: any, expected: ExpectedProgress) {
|
|
60
|
-
const expectedState = expected.state ?? (expected.percent === 100 ? 'completed' : 'started')
|
|
61
|
-
expect(data).not.toBeNull()
|
|
62
|
-
if (expected.state !== undefined) expect(data.state).toBe(expectedState)
|
|
63
|
-
if (expected.percent !== undefined) expect(data.progress_percent).toBe(expected.percent)
|
|
64
|
-
if (expected.collection !== undefined) expect(data.collection_type).toBe(expected.collection.type)
|
|
65
|
-
if (expected.collection !== undefined) expect(data.collection_id).toBe(expected.collection.id)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async function getOne(contentId: number, collection: CollectionParameter = null) {
|
|
69
|
-
const result = await db.contentProgress.getOneProgressByContentId(contentId, collection)
|
|
70
|
-
return result.data
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async function writeOne(contentId: number, progress: number, collection: CollectionParameter = null) {
|
|
74
|
-
await db.contentProgress.recordProgress(contentId, collection, progress, testMetadata, 0, { skipPush: true })
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function buildHierarchy(tree: HierarchyTreeNode) {
|
|
78
|
-
const parents: Record<number, number> = {}
|
|
79
|
-
const children: Record<number, number[]> = {}
|
|
80
|
-
const metadata: Record<number, { type: string; brand: string; parent_id: number }> = {}
|
|
81
|
-
|
|
82
|
-
function walk(node: HierarchyTreeNode, parentId: number) {
|
|
83
|
-
const childIds = (node.children ?? []).map(c => c.id)
|
|
84
|
-
metadata[node.id] = {
|
|
85
|
-
type: node.type ?? 'lesson',
|
|
86
|
-
brand: node.brand ?? 'drumeo',
|
|
87
|
-
parent_id: parentId,
|
|
88
|
-
}
|
|
89
|
-
if (parentId) parents[node.id] = parentId
|
|
90
|
-
if (childIds.length > 0) children[node.id] = childIds
|
|
91
|
-
for (const c of node.children ?? []) walk(c, node.id)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
walk(tree, 0)
|
|
95
|
-
|
|
96
|
-
return { topLevelId: tree.id, parents, children, metadata }
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const flatHierarchy = (contentId: number) => buildHierarchy({ id: contentId, type: 'lesson' })
|
|
100
|
-
|
|
101
|
-
const flatHierarchyForMany = (contentIds: number[]) => ({
|
|
102
|
-
topLevelId: contentIds[0],
|
|
103
|
-
parents: {},
|
|
104
|
-
children: {},
|
|
105
|
-
metadata: Object.fromEntries(contentIds.map(id => [id, { ...testMetadata }])),
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
describe('contentStatusCompletedOffline', () => {
|
|
109
|
-
|
|
110
|
-
describe('a-la-carte collection', () => {
|
|
111
|
-
test('singular a-la-carte lesson', async () => {
|
|
112
|
-
await contentStatusCompletedOffline(500, null, flatHierarchy(500))
|
|
113
|
-
const record = await getOne(500, null)
|
|
114
|
-
|
|
115
|
-
expectProgress(record, { percent: 100, collection: selfCollection })
|
|
116
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledTimes(1)
|
|
117
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledWith('save-content-progress')
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
test('child a-la-carte lesson does NOT bubble to parent', async () => {
|
|
121
|
-
const hierarchy = buildHierarchy({
|
|
122
|
-
id: 1, type: 'course', children: [
|
|
123
|
-
{ id: 100, type: 'lesson' },
|
|
124
|
-
{ id: 200, type: 'lesson' },
|
|
125
|
-
],
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
await contentStatusCompletedOffline(100, null, hierarchy)
|
|
129
|
-
|
|
130
|
-
const child = await getOne(100, null)
|
|
131
|
-
const sibling = await getOne(200, null)
|
|
132
|
-
const parent = await getOne(1, null)
|
|
133
|
-
|
|
134
|
-
expectProgress(child, { percent: 100, collection: selfCollection })
|
|
135
|
-
expect(sibling).toBeNull()
|
|
136
|
-
expect(parent).toBeNull()
|
|
137
|
-
|
|
138
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledTimes(1)
|
|
139
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledWith('save-content-progress')
|
|
140
|
-
})
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
describe('learning path collection', () => {
|
|
144
|
-
test('learning path lesson writes LP record and duplicates to a-la-carte without bubbling', async () => {
|
|
145
|
-
const hierarchy = buildHierarchy({
|
|
146
|
-
id: 999, type: 'learning-path-v2', children: [
|
|
147
|
-
{ id: 100, type: 'lesson' },
|
|
148
|
-
{ id: 300, type: 'lesson' },
|
|
149
|
-
],
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
await contentStatusCompletedOffline(100, lpCollection, hierarchy)
|
|
153
|
-
|
|
154
|
-
const childLP = await getOne(100, lpCollection)
|
|
155
|
-
const lpLP = await getOne(999, lpCollection)
|
|
156
|
-
const childALC = await getOne(100, null)
|
|
157
|
-
const lpALC = await getOne(999, null)
|
|
158
|
-
const siblingALC = await getOne(300, null)
|
|
159
|
-
|
|
160
|
-
expectProgress(childLP, { percent: 100, collection: lpCollection })
|
|
161
|
-
expect(lpLP).toBeNull()
|
|
162
|
-
expectProgress(childALC, { percent: 100, collection: selfCollection })
|
|
163
|
-
expect(lpALC).toBeNull()
|
|
164
|
-
expect(siblingALC).toBeNull()
|
|
165
|
-
|
|
166
|
-
expect(learningPathsMock.onLearningPathCompletedActions).not.toHaveBeenCalled()
|
|
167
|
-
|
|
168
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledWith('save-content-progress')
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
// not possible to complete parents offline, currently
|
|
172
|
-
// test('learning path completion writes LP record but skips onLearningPathCompletedActions (offline)', async () => {})
|
|
173
|
-
})
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
describe('contentStatusCompletedManyOffline', () => {
|
|
177
|
-
test('all ids written in a-la-carte', async () => {
|
|
178
|
-
await contentStatusCompletedManyOffline(
|
|
179
|
-
[50001, 50002, 50003],
|
|
180
|
-
null,
|
|
181
|
-
flatHierarchyForMany([50001, 50002, 50003]),
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
expectProgress(await getOne(50001, null), { percent: 100, collection: selfCollection })
|
|
185
|
-
expectProgress(await getOne(50002, null), { percent: 100, collection: selfCollection })
|
|
186
|
-
expectProgress(await getOne(50003, null), { percent: 100, collection: selfCollection })
|
|
187
|
-
|
|
188
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledWith('save-content-progress')
|
|
189
|
-
})
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
describe('contentStatusStartedOffline', () => {
|
|
193
|
-
test('singular a-la-carte lesson started', async () => {
|
|
194
|
-
await contentStatusStartedOffline(500, null, flatHierarchy(500))
|
|
195
|
-
const record = await getOne(500, null)
|
|
196
|
-
|
|
197
|
-
expectProgress(record, { percent: 0, state: 'started', collection: selfCollection })
|
|
198
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledWith('save-content-progress')
|
|
199
|
-
})
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
describe('contentStatusResetOffline', () => {
|
|
203
|
-
describe('a-la-carte collection', () => {
|
|
204
|
-
test('reset singular a-la-carte lesson', async () => {
|
|
205
|
-
await writeOne(500, 100)
|
|
206
|
-
await contentStatusResetOffline(500)
|
|
207
|
-
|
|
208
|
-
const record = await getOne(500, null)
|
|
209
|
-
|
|
210
|
-
expect(record).toBeNull()
|
|
211
|
-
|
|
212
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledTimes(1)
|
|
213
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledWith('reset-status')
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
test('reset child a-la-carte lesson does NOT touch parent', async () => {
|
|
217
|
-
await writeOne(100, 100)
|
|
218
|
-
await writeOne(200, 100)
|
|
219
|
-
await writeOne(1, 100)
|
|
220
|
-
|
|
221
|
-
await contentStatusResetOffline(100)
|
|
222
|
-
|
|
223
|
-
const child = await getOne(100, null)
|
|
224
|
-
const sibling = await getOne(200, null)
|
|
225
|
-
const parent = await getOne(1, null)
|
|
226
|
-
|
|
227
|
-
expect(child).toBeNull()
|
|
228
|
-
expectProgress(sibling, { percent: 100 })
|
|
229
|
-
expectProgress(parent, { percent: 100 })
|
|
230
|
-
|
|
231
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledTimes(1)
|
|
232
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledWith('reset-status')
|
|
233
|
-
})
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
describe('learning path collection', () => {
|
|
237
|
-
test('reset learning path lesson removes LP record only', async () => {
|
|
238
|
-
await writeOne(100, 100, lpCollection)
|
|
239
|
-
await writeOne(999, 50, lpCollection)
|
|
240
|
-
await writeOne(100, 100)
|
|
241
|
-
await writeOne(50, 50)
|
|
242
|
-
|
|
243
|
-
await contentStatusResetOffline(100, lpCollection)
|
|
244
|
-
|
|
245
|
-
const childLP = await getOne(100, lpCollection)
|
|
246
|
-
const lpLP = await getOne(999, lpCollection)
|
|
247
|
-
const childALC = await getOne(100, null)
|
|
248
|
-
const parentALC = await getOne(50, null)
|
|
249
|
-
|
|
250
|
-
expect(childLP).toBeNull()
|
|
251
|
-
expectProgress(lpLP, { percent: 50 })
|
|
252
|
-
expectProgress(childALC, { percent: 100 })
|
|
253
|
-
expectProgress(parentALC, { percent: 50 })
|
|
254
|
-
|
|
255
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledTimes(1)
|
|
256
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledWith('reset-status')
|
|
257
|
-
})
|
|
258
|
-
})
|
|
259
|
-
})
|
|
260
|
-
|
|
261
|
-
describe('recordWatchSessionOffline', () => {
|
|
262
|
-
|
|
263
|
-
describe('a-la-carte collection', () => {
|
|
264
|
-
test('singular a-la-carte lesson, halfway', async () => {
|
|
265
|
-
await recordWatchSessionOffline(500, 200, 100, 30, flatHierarchy(500))
|
|
266
|
-
|
|
267
|
-
const record = await getOne(500, null)
|
|
268
|
-
expectProgress(record, { percent: 50, collection: selfCollection })
|
|
269
|
-
expect(ctx.pushSpies.contentProgress).not.toHaveBeenCalled()
|
|
270
|
-
})
|
|
271
|
-
|
|
272
|
-
test('singular a-la-carte lesson, watched to end clamps at 99', async () => {
|
|
273
|
-
await recordWatchSessionOffline(500, 200, 200, 60, flatHierarchy(500))
|
|
274
|
-
|
|
275
|
-
const record = await getOne(500, null)
|
|
276
|
-
expectProgress(record, { percent: 99 })
|
|
277
|
-
expect(ctx.pushSpies.contentProgress).not.toHaveBeenCalled()
|
|
278
|
-
})
|
|
279
|
-
|
|
280
|
-
test('child a-la-carte lesson does NOT bubble to parent', async () => {
|
|
281
|
-
const hierarchy = buildHierarchy({
|
|
282
|
-
id: 1, type: 'course', children: [
|
|
283
|
-
{ id: 100, type: 'lesson' },
|
|
284
|
-
{ id: 200, type: 'lesson' },
|
|
285
|
-
],
|
|
286
|
-
})
|
|
287
|
-
|
|
288
|
-
await recordWatchSessionOffline(100, 200, 100, 30, hierarchy)
|
|
289
|
-
|
|
290
|
-
const child = await getOne(100, null)
|
|
291
|
-
const sibling = await getOne(200, null)
|
|
292
|
-
const parent = await getOne(1, null)
|
|
293
|
-
|
|
294
|
-
expectProgress(child, { percent: 50 })
|
|
295
|
-
expect(sibling).toBeNull()
|
|
296
|
-
expect(parent).toBeNull()
|
|
297
|
-
|
|
298
|
-
expect(ctx.pushSpies.contentProgress).not.toHaveBeenCalled()
|
|
299
|
-
})
|
|
300
|
-
|
|
301
|
-
test('flushWatchSession triggers push after offline watch', async () => {
|
|
302
|
-
await recordWatchSessionOffline(500, 200, 100, 30, flatHierarchy(500))
|
|
303
|
-
expect(ctx.pushSpies.contentProgress).not.toHaveBeenCalled()
|
|
304
|
-
|
|
305
|
-
await flushWatchSession()
|
|
306
|
-
expect(ctx.pushSpies.contentProgress).toHaveBeenCalledWith('flush-watch-session')
|
|
307
|
-
})
|
|
308
|
-
})
|
|
309
|
-
|
|
310
|
-
describe('playlist collection', () => {
|
|
311
|
-
test('singular lesson in playlist duplicates progress to a-la-carte', async () => {
|
|
312
|
-
await recordWatchSessionOffline(500, 200, 100, 30, flatHierarchy(500), {
|
|
313
|
-
collection: playlistCollection,
|
|
314
|
-
})
|
|
315
|
-
|
|
316
|
-
const aLaCarte = await getOne(500, null)
|
|
317
|
-
const playlistRec = await getOne(500, playlistCollection)
|
|
318
|
-
|
|
319
|
-
expectProgress(aLaCarte, { percent: 50, collection: selfCollection })
|
|
320
|
-
expect(playlistRec).toBeNull()
|
|
321
|
-
expect(ctx.pushSpies.contentProgress).not.toHaveBeenCalled()
|
|
322
|
-
})
|
|
323
|
-
})
|
|
324
|
-
|
|
325
|
-
describe('learning path collection', () => {
|
|
326
|
-
test('child lesson in LP writes LP record, duplicates to a-la-carte, no bubble', async () => {
|
|
327
|
-
const hierarchy = buildHierarchy({
|
|
328
|
-
id: 999, type: 'learning-path-v2', children: [
|
|
329
|
-
{ id: 100, type: 'lesson' },
|
|
330
|
-
{ id: 300, type: 'lesson' },
|
|
331
|
-
],
|
|
332
|
-
})
|
|
333
|
-
|
|
334
|
-
await recordWatchSessionOffline(100, 200, 100, 30, hierarchy, {
|
|
335
|
-
collection: lpCollection,
|
|
336
|
-
})
|
|
337
|
-
|
|
338
|
-
const childLP = await getOne(100, lpCollection)
|
|
339
|
-
const lpLP = await getOne(999, lpCollection)
|
|
340
|
-
const childALC = await getOne(100, null)
|
|
341
|
-
const lpALC = await getOne(999, null)
|
|
342
|
-
|
|
343
|
-
expectProgress(childLP, { percent: 50, collection: lpCollection })
|
|
344
|
-
expect(lpLP).toBeNull()
|
|
345
|
-
expectProgress(childALC, { percent: 50, collection: selfCollection })
|
|
346
|
-
expect(lpALC).toBeNull()
|
|
347
|
-
|
|
348
|
-
expect(learningPathsMock.onLearningPathCompletedActions).not.toHaveBeenCalled()
|
|
349
|
-
expect(ctx.pushSpies.contentProgress).not.toHaveBeenCalled()
|
|
350
|
-
})
|
|
351
|
-
})
|
|
352
|
-
})
|