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
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { initializeTestService } from '../initializeTests.js'
|
|
2
|
-
import { getAllStarted, getAllStartedOrCompleted, getProgressState } from '../../src/services/contentProgress.js'
|
|
3
|
-
|
|
4
|
-
let mockProgressRecords: {
|
|
5
|
-
content_id: number;
|
|
6
|
-
state: string;
|
|
7
|
-
progress_percent: number;
|
|
8
|
-
updated_at: number;
|
|
9
|
-
last_interacted_a_la_carte?: number
|
|
10
|
-
}[] = []
|
|
11
|
-
|
|
12
|
-
jest.mock('../../src/services/sync/repository-proxy', () => {
|
|
13
|
-
const mockFns = {
|
|
14
|
-
contentProgress: {
|
|
15
|
-
getOneProgressByContentId: jest.fn().mockImplementation((contentId) => {
|
|
16
|
-
const record = mockProgressRecords.find(r => r.content_id === contentId)
|
|
17
|
-
return Promise.resolve({ data: record || null })
|
|
18
|
-
}),
|
|
19
|
-
getSomeProgressByContentIds: jest.fn().mockImplementation((contentIds) => {
|
|
20
|
-
const records = mockProgressRecords.filter(r => contentIds.includes(r.content_id))
|
|
21
|
-
return Promise.resolve({ data: records })
|
|
22
|
-
}),
|
|
23
|
-
started: jest.fn().mockImplementation((limit, opts) => {
|
|
24
|
-
const startedIds = mockProgressRecords
|
|
25
|
-
.filter(r => r.state === 'started')
|
|
26
|
-
.sort((a, b) => b.updated_at - a.updated_at)
|
|
27
|
-
.map(r => r.content_id)
|
|
28
|
-
const result = limit ? startedIds.slice(0, limit) : startedIds
|
|
29
|
-
return Promise.resolve(opts?.onlyIds !== false ? result : result.map(id => ({ content_id: id })))
|
|
30
|
-
}),
|
|
31
|
-
startedOrCompleted: jest.fn().mockImplementation(() => {
|
|
32
|
-
const records = mockProgressRecords
|
|
33
|
-
.filter(r => r.state === 'started' || r.state === 'completed')
|
|
34
|
-
.sort((a, b) => b.updated_at - a.updated_at)
|
|
35
|
-
return Promise.resolve({ data: records })
|
|
36
|
-
}),
|
|
37
|
-
},
|
|
38
|
-
practices: {
|
|
39
|
-
queryAll: jest.fn().mockResolvedValue({ data: [] }),
|
|
40
|
-
getAll: jest.fn().mockResolvedValue({ data: [] }),
|
|
41
|
-
},
|
|
42
|
-
}
|
|
43
|
-
return { default: mockFns, ...mockFns }
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
describe('contentProgressDataContext', function () {
|
|
47
|
-
beforeEach(() => {
|
|
48
|
-
initializeTestService()
|
|
49
|
-
mockProgressRecords = [
|
|
50
|
-
{ content_id: 234191, state: 'started', progress_percent: 6, updated_at: 1731108082, last_interacted_a_la_carte: 1731108082 },
|
|
51
|
-
{ content_id: 233955, state: 'started', progress_percent: 1, updated_at: 1731108083 },
|
|
52
|
-
{ content_id: 259426, state: 'completed', progress_percent: 100, updated_at: 1731108085 },
|
|
53
|
-
{ content_id: 190417, state: 'started', progress_percent: 6, updated_at: 1731108082 },
|
|
54
|
-
{ content_id: 407665, state: 'started', progress_percent: 6, updated_at: 1740120139 },
|
|
55
|
-
{ content_id: 412986, state: 'completed', progress_percent: 100, updated_at: 1731108085 },
|
|
56
|
-
]
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
test('getProgressState', async () => {
|
|
60
|
-
let result = await getProgressState(234191)
|
|
61
|
-
expect(result).toBe('started')
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
test('getProgressState_notExists', async () => {
|
|
65
|
-
let result = await getProgressState(111111)
|
|
66
|
-
expect(result).toBe('')
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
test('getAllStarted', async () => {
|
|
70
|
-
let result = await getAllStarted()
|
|
71
|
-
expect(result).toStrictEqual([407665, 233955, 234191, 190417])
|
|
72
|
-
|
|
73
|
-
result = await getAllStarted(1)
|
|
74
|
-
expect(result).toStrictEqual([407665])
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
test('getAllStartedOrCompleted', async () => {
|
|
78
|
-
let result = await getAllStartedOrCompleted()
|
|
79
|
-
expect(result).toStrictEqual([407665, 259426, 412986, 233955, 234191, 190417])
|
|
80
|
-
})
|
|
81
|
-
})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|