@memberjunction/actions-bizapps-lms 5.3.1 → 5.4.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +16 -0
- package/LEARNWORLDS_SIDECAR_PLAN.md +845 -0
- package/dist/base/base-lms.action.d.ts +26 -4
- package/dist/base/base-lms.action.d.ts.map +1 -1
- package/dist/base/base-lms.action.js +73 -17
- package/dist/base/base-lms.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/attach-tags.action.d.ts +26 -0
- package/dist/providers/learnworlds/actions/attach-tags.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/attach-tags.action.js +79 -0
- package/dist/providers/learnworlds/actions/attach-tags.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/create-user.action.d.ts +24 -1
- package/dist/providers/learnworlds/actions/create-user.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/create-user.action.js +166 -142
- package/dist/providers/learnworlds/actions/create-user.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/detach-tags.action.d.ts +26 -0
- package/dist/providers/learnworlds/actions/detach-tags.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/detach-tags.action.js +79 -0
- package/dist/providers/learnworlds/actions/detach-tags.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/enroll-user.action.d.ts +31 -3
- package/dist/providers/learnworlds/actions/enroll-user.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/enroll-user.action.js +179 -125
- package/dist/providers/learnworlds/actions/enroll-user.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-bulk-data.action.d.ts +79 -0
- package/dist/providers/learnworlds/actions/get-bulk-data.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/get-bulk-data.action.js +359 -0
- package/dist/providers/learnworlds/actions/get-bulk-data.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/get-bundles.action.d.ts +34 -0
- package/dist/providers/learnworlds/actions/get-bundles.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/get-bundles.action.js +107 -0
- package/dist/providers/learnworlds/actions/get-bundles.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/get-certificates.action.d.ts +33 -2
- package/dist/providers/learnworlds/actions/get-certificates.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-certificates.action.js +311 -244
- package/dist/providers/learnworlds/actions/get-certificates.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-course-analytics.action.d.ts +14 -14
- package/dist/providers/learnworlds/actions/get-course-analytics.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-course-analytics.action.js +234 -226
- package/dist/providers/learnworlds/actions/get-course-analytics.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-course-details.action.d.ts +42 -6
- package/dist/providers/learnworlds/actions/get-course-details.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-course-details.action.js +182 -148
- package/dist/providers/learnworlds/actions/get-course-details.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-courses.action.d.ts +29 -82
- package/dist/providers/learnworlds/actions/get-courses.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-courses.action.js +188 -207
- package/dist/providers/learnworlds/actions/get-courses.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-quiz-results.action.d.ts +22 -2
- package/dist/providers/learnworlds/actions/get-quiz-results.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-quiz-results.action.js +316 -294
- package/dist/providers/learnworlds/actions/get-quiz-results.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-user-details.action.d.ts +23 -59
- package/dist/providers/learnworlds/actions/get-user-details.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-user-details.action.js +113 -114
- package/dist/providers/learnworlds/actions/get-user-details.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-user-enrollments.action.d.ts +43 -5
- package/dist/providers/learnworlds/actions/get-user-enrollments.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-user-enrollments.action.js +191 -147
- package/dist/providers/learnworlds/actions/get-user-enrollments.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-user-progress.action.d.ts +21 -92
- package/dist/providers/learnworlds/actions/get-user-progress.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-user-progress.action.js +145 -166
- package/dist/providers/learnworlds/actions/get-user-progress.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-users.action.d.ts +14 -28
- package/dist/providers/learnworlds/actions/get-users.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-users.action.js +122 -143
- package/dist/providers/learnworlds/actions/get-users.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/index.d.ts +7 -0
- package/dist/providers/learnworlds/actions/index.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/index.js +7 -0
- package/dist/providers/learnworlds/actions/index.js.map +1 -1
- package/dist/providers/learnworlds/actions/onboard-learner.action.d.ts +53 -0
- package/dist/providers/learnworlds/actions/onboard-learner.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/onboard-learner.action.js +236 -0
- package/dist/providers/learnworlds/actions/onboard-learner.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/sso-login.action.d.ts +35 -0
- package/dist/providers/learnworlds/actions/sso-login.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/sso-login.action.js +101 -0
- package/dist/providers/learnworlds/actions/sso-login.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/update-user-progress.action.d.ts +12 -1
- package/dist/providers/learnworlds/actions/update-user-progress.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/update-user-progress.action.js +167 -210
- package/dist/providers/learnworlds/actions/update-user-progress.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/update-user.action.d.ts +39 -0
- package/dist/providers/learnworlds/actions/update-user.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/update-user.action.js +168 -0
- package/dist/providers/learnworlds/actions/update-user.action.js.map +1 -0
- package/dist/providers/learnworlds/index.d.ts +1 -0
- package/dist/providers/learnworlds/index.d.ts.map +1 -1
- package/dist/providers/learnworlds/index.js +2 -0
- package/dist/providers/learnworlds/index.js.map +1 -1
- package/dist/providers/learnworlds/interfaces/bundle.types.d.ts +16 -0
- package/dist/providers/learnworlds/interfaces/bundle.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/bundle.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/bundle.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/certificate.types.d.ts +66 -0
- package/dist/providers/learnworlds/interfaces/certificate.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/certificate.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/certificate.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/common.types.d.ts +221 -0
- package/dist/providers/learnworlds/interfaces/common.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/common.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/common.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/course.types.d.ts +393 -0
- package/dist/providers/learnworlds/interfaces/course.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/course.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/course.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/enrollment.types.d.ts +165 -0
- package/dist/providers/learnworlds/interfaces/enrollment.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/enrollment.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/enrollment.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/index.d.ts +12 -0
- package/dist/providers/learnworlds/interfaces/index.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/index.js +13 -0
- package/dist/providers/learnworlds/interfaces/index.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/onboarding.types.d.ts +39 -0
- package/dist/providers/learnworlds/interfaces/onboarding.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/onboarding.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/onboarding.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/quiz.types.d.ts +108 -0
- package/dist/providers/learnworlds/interfaces/quiz.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/quiz.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/quiz.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/sso.types.d.ts +18 -0
- package/dist/providers/learnworlds/interfaces/sso.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/sso.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/sso.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/sync.types.d.ts +44 -0
- package/dist/providers/learnworlds/interfaces/sync.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/sync.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/sync.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/tag.types.d.ts +17 -0
- package/dist/providers/learnworlds/interfaces/tag.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/tag.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/tag.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/user.types.d.ts +198 -0
- package/dist/providers/learnworlds/interfaces/user.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/user.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/user.types.js.map +1 -0
- package/dist/providers/learnworlds/learnworlds-base.action.d.ts +111 -7
- package/dist/providers/learnworlds/learnworlds-base.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/learnworlds-base.action.js +293 -56
- package/dist/providers/learnworlds/learnworlds-base.action.js.map +1 -1
- package/package.json +8 -7
- package/src/__tests__/attach-tags.action.test.ts +137 -0
- package/src/__tests__/create-user.action.test.ts +311 -0
- package/src/__tests__/detach-tags.action.test.ts +136 -0
- package/src/__tests__/enroll-user.action.test.ts +283 -0
- package/src/__tests__/get-bulk-data.action.test.ts +649 -0
- package/src/__tests__/get-bundles.action.test.ts +215 -0
- package/src/__tests__/lms.test.ts +275 -184
- package/src/__tests__/onboard-learner.action.test.ts +455 -0
- package/src/__tests__/sso-login.action.test.ts +256 -0
- package/src/__tests__/update-user.action.test.ts +350 -0
- package/src/base/base-lms.action.ts +226 -163
- package/src/providers/learnworlds/actions/attach-tags.action.ts +90 -0
- package/src/providers/learnworlds/actions/create-user.action.ts +291 -235
- package/src/providers/learnworlds/actions/detach-tags.action.ts +90 -0
- package/src/providers/learnworlds/actions/enroll-user.action.ts +326 -220
- package/src/providers/learnworlds/actions/get-bulk-data.action.ts +438 -0
- package/src/providers/learnworlds/actions/get-bundles.action.ts +139 -0
- package/src/providers/learnworlds/actions/get-certificates.action.ts +499 -309
- package/src/providers/learnworlds/actions/get-course-analytics.action.ts +470 -337
- package/src/providers/learnworlds/actions/get-course-details.action.ts +395 -249
- package/src/providers/learnworlds/actions/get-courses.action.ts +508 -565
- package/src/providers/learnworlds/actions/get-quiz-results.action.ts +606 -381
- package/src/providers/learnworlds/actions/get-user-details.action.ts +335 -349
- package/src/providers/learnworlds/actions/get-user-enrollments.action.ts +328 -228
- package/src/providers/learnworlds/actions/get-user-progress.action.ts +522 -571
- package/src/providers/learnworlds/actions/get-users.action.ts +231 -282
- package/src/providers/learnworlds/actions/index.ts +8 -1
- package/src/providers/learnworlds/actions/onboard-learner.action.ts +286 -0
- package/src/providers/learnworlds/actions/sso-login.action.ts +116 -0
- package/src/providers/learnworlds/actions/update-user-progress.action.ts +301 -263
- package/src/providers/learnworlds/actions/update-user.action.ts +181 -0
- package/src/providers/learnworlds/index.ts +4 -1
- package/src/providers/learnworlds/interfaces/bundle.types.ts +17 -0
- package/src/providers/learnworlds/interfaces/certificate.types.ts +69 -0
- package/src/providers/learnworlds/interfaces/common.types.ts +233 -0
- package/src/providers/learnworlds/interfaces/course.types.ts +411 -0
- package/src/providers/learnworlds/interfaces/enrollment.types.ts +176 -0
- package/src/providers/learnworlds/interfaces/index.ts +12 -0
- package/src/providers/learnworlds/interfaces/onboarding.types.ts +41 -0
- package/src/providers/learnworlds/interfaces/quiz.types.ts +118 -0
- package/src/providers/learnworlds/interfaces/sso.types.ts +19 -0
- package/src/providers/learnworlds/interfaces/sync.types.ts +46 -0
- package/src/providers/learnworlds/interfaces/tag.types.ts +18 -0
- package/src/providers/learnworlds/interfaces/user.types.ts +204 -0
- package/src/providers/learnworlds/learnworlds-base.action.ts +468 -210
- package/tsconfig.json +1 -1
- package/dist/__tests__/lms.test.d.ts +0 -2
- package/dist/__tests__/lms.test.d.ts.map +0 -1
- package/dist/__tests__/lms.test.js +0 -232
- package/dist/__tests__/lms.test.js.map +0 -1
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
|
|
3
|
+
// Mock dependencies (same pattern as lms.test.ts)
|
|
4
|
+
vi.mock('@memberjunction/actions', () => ({
|
|
5
|
+
BaseAction: class BaseAction {
|
|
6
|
+
protected async InternalRunAction(): Promise<unknown> {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
vi.mock('@memberjunction/global', () => ({
|
|
13
|
+
RegisterClass: () => (target: unknown) => target,
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
vi.mock('@memberjunction/core', () => ({
|
|
17
|
+
UserInfo: class UserInfo {},
|
|
18
|
+
Metadata: vi.fn(),
|
|
19
|
+
RunView: vi.fn().mockImplementation(() => ({
|
|
20
|
+
RunView: vi.fn().mockResolvedValue({ Success: true, Results: [] }),
|
|
21
|
+
})),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
vi.mock('@memberjunction/core-entities', () => ({
|
|
25
|
+
MJCompanyIntegrationEntity: class MJCompanyIntegrationEntity {
|
|
26
|
+
CompanyID: string = '';
|
|
27
|
+
APIKey: string | null = null;
|
|
28
|
+
AccessToken: string | null = null;
|
|
29
|
+
ExternalSystemID: string | null = null;
|
|
30
|
+
CustomAttribute1: string | null = null;
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
vi.mock('@memberjunction/actions-base', () => ({
|
|
35
|
+
ActionParam: class ActionParam {
|
|
36
|
+
Name: string = '';
|
|
37
|
+
Value: unknown = null;
|
|
38
|
+
Type: string = 'Input';
|
|
39
|
+
},
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
import { UserInfo } from '@memberjunction/core';
|
|
43
|
+
import { GetBundlesAction } from '../providers/learnworlds/actions/get-bundles.action';
|
|
44
|
+
import { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
45
|
+
import { LearnWorldsBundle } from '../providers/learnworlds/interfaces';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Helper to create a mock UserInfo for test context
|
|
49
|
+
*/
|
|
50
|
+
function createMockContextUser(): UserInfo {
|
|
51
|
+
return { ID: 'test-user-id', Name: 'Test User', Email: 'test@example.com' } as unknown as UserInfo;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Helper to build a raw LW API bundle object matching the LWApiBundle interface
|
|
56
|
+
*/
|
|
57
|
+
function createRawApiBundle(overrides: Record<string, unknown> = {}): Record<string, unknown> {
|
|
58
|
+
return {
|
|
59
|
+
id: 'bundle-1',
|
|
60
|
+
title: 'Starter Bundle',
|
|
61
|
+
description: 'A great bundle',
|
|
62
|
+
price: 49.99,
|
|
63
|
+
currency: 'USD',
|
|
64
|
+
courses: ['course-1', 'course-2'],
|
|
65
|
+
is_active: true,
|
|
66
|
+
created_at: '2024-06-15T10:00:00Z',
|
|
67
|
+
updated_at: '2024-06-20T12:00:00Z',
|
|
68
|
+
thumbnail_url: 'https://example.com/thumb.jpg',
|
|
69
|
+
total_courses: 2,
|
|
70
|
+
total_enrollments: 150,
|
|
71
|
+
...overrides,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
describe('GetBundlesAction', () => {
|
|
76
|
+
let action: GetBundlesAction;
|
|
77
|
+
let contextUser: UserInfo;
|
|
78
|
+
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
action = new GetBundlesAction();
|
|
81
|
+
contextUser = createMockContextUser();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('GetBundles() typed method', () => {
|
|
85
|
+
it('should get bundles successfully', async () => {
|
|
86
|
+
const rawBundle = createRawApiBundle();
|
|
87
|
+
vi.spyOn(action as never, 'makeLearnWorldsPaginatedRequest').mockResolvedValue([rawBundle] as never);
|
|
88
|
+
|
|
89
|
+
const result = await action.GetBundles({ CompanyID: 'comp-1' }, contextUser);
|
|
90
|
+
|
|
91
|
+
expect(result.TotalCount).toBe(1);
|
|
92
|
+
expect(result.Bundles).toHaveLength(1);
|
|
93
|
+
|
|
94
|
+
const bundle: LearnWorldsBundle = result.Bundles[0];
|
|
95
|
+
expect(bundle.id).toBe('bundle-1');
|
|
96
|
+
expect(bundle.title).toBe('Starter Bundle');
|
|
97
|
+
expect(bundle.description).toBe('A great bundle');
|
|
98
|
+
expect(bundle.price).toBe(49.99);
|
|
99
|
+
expect(bundle.currency).toBe('USD');
|
|
100
|
+
expect(bundle.courses).toEqual(['course-1', 'course-2']);
|
|
101
|
+
expect(bundle.isActive).toBe(true);
|
|
102
|
+
expect(bundle.totalCourses).toBe(2);
|
|
103
|
+
expect(bundle.totalEnrollments).toBe(150);
|
|
104
|
+
expect(bundle.thumbnailUrl).toBe('https://example.com/thumb.jpg');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should handle empty results', async () => {
|
|
108
|
+
vi.spyOn(action as never, 'makeLearnWorldsPaginatedRequest').mockResolvedValue([] as never);
|
|
109
|
+
|
|
110
|
+
const result = await action.GetBundles({ CompanyID: 'comp-1', SearchText: 'nonexistent' }, contextUser);
|
|
111
|
+
|
|
112
|
+
expect(result.TotalCount).toBe(0);
|
|
113
|
+
expect(result.Bundles).toEqual([]);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should map bundles with _id fallback', async () => {
|
|
117
|
+
const rawBundle = createRawApiBundle({ id: undefined, _id: 'alt-bundle-id' });
|
|
118
|
+
vi.spyOn(action as never, 'makeLearnWorldsPaginatedRequest').mockResolvedValue([rawBundle] as never);
|
|
119
|
+
|
|
120
|
+
const result = await action.GetBundles({ CompanyID: 'comp-1' }, contextUser);
|
|
121
|
+
|
|
122
|
+
expect(result.Bundles[0].id).toBe('alt-bundle-id');
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('should default isActive to true when is_active is not false', async () => {
|
|
126
|
+
const rawBundle = createRawApiBundle({ is_active: undefined });
|
|
127
|
+
vi.spyOn(action as never, 'makeLearnWorldsPaginatedRequest').mockResolvedValue([rawBundle] as never);
|
|
128
|
+
|
|
129
|
+
const result = await action.GetBundles({ CompanyID: 'comp-1' }, contextUser);
|
|
130
|
+
|
|
131
|
+
expect(result.Bundles[0].isActive).toBe(true);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('should compute totalCourses from courses array when total_courses is missing', async () => {
|
|
135
|
+
const rawBundle = createRawApiBundle({ total_courses: undefined, courses: ['c1', 'c2', 'c3'] });
|
|
136
|
+
vi.spyOn(action as never, 'makeLearnWorldsPaginatedRequest').mockResolvedValue([rawBundle] as never);
|
|
137
|
+
|
|
138
|
+
const result = await action.GetBundles({ CompanyID: 'comp-1' }, contextUser);
|
|
139
|
+
|
|
140
|
+
expect(result.Bundles[0].totalCourses).toBe(3);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('should use students_count as fallback for totalEnrollments', async () => {
|
|
144
|
+
const rawBundle = createRawApiBundle({ total_enrollments: undefined, students_count: 42 });
|
|
145
|
+
vi.spyOn(action as never, 'makeLearnWorldsPaginatedRequest').mockResolvedValue([rawBundle] as never);
|
|
146
|
+
|
|
147
|
+
const result = await action.GetBundles({ CompanyID: 'comp-1' }, contextUser);
|
|
148
|
+
|
|
149
|
+
expect(result.Bundles[0].totalEnrollments).toBe(42);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
describe('InternalRunAction()', () => {
|
|
154
|
+
it('should return success when GetBundles succeeds', async () => {
|
|
155
|
+
const mockBundles: LearnWorldsBundle[] = [
|
|
156
|
+
{
|
|
157
|
+
id: 'bundle-1',
|
|
158
|
+
title: 'Bundle A',
|
|
159
|
+
courses: ['c1'],
|
|
160
|
+
isActive: true,
|
|
161
|
+
createdAt: '2024-01-01T00:00:00.000Z',
|
|
162
|
+
updatedAt: '2024-01-02T00:00:00.000Z',
|
|
163
|
+
totalCourses: 1,
|
|
164
|
+
totalEnrollments: 10,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: 'bundle-2',
|
|
168
|
+
title: 'Bundle B',
|
|
169
|
+
courses: ['c2', 'c3'],
|
|
170
|
+
isActive: true,
|
|
171
|
+
createdAt: '2024-02-01T00:00:00.000Z',
|
|
172
|
+
updatedAt: '2024-02-02T00:00:00.000Z',
|
|
173
|
+
totalCourses: 2,
|
|
174
|
+
totalEnrollments: 20,
|
|
175
|
+
},
|
|
176
|
+
];
|
|
177
|
+
|
|
178
|
+
vi.spyOn(action, 'GetBundles').mockResolvedValue({
|
|
179
|
+
Bundles: mockBundles,
|
|
180
|
+
TotalCount: 2,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const runParams: RunActionParams = {
|
|
184
|
+
Params: [
|
|
185
|
+
{ Name: 'CompanyID', Type: 'Input', Value: 'comp-1' },
|
|
186
|
+
{ Name: 'SearchText', Type: 'Input', Value: undefined },
|
|
187
|
+
{ Name: 'MaxResults', Type: 'Input', Value: undefined },
|
|
188
|
+
],
|
|
189
|
+
ContextUser: contextUser,
|
|
190
|
+
} as unknown as RunActionParams;
|
|
191
|
+
|
|
192
|
+
const result = (await action['InternalRunAction'](runParams)) as ActionResultSimple;
|
|
193
|
+
|
|
194
|
+
expect(result.Success).toBe(true);
|
|
195
|
+
expect(result.ResultCode).toBe('SUCCESS');
|
|
196
|
+
expect(result.Message).toContain('Successfully retrieved 2 bundle(s)');
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('should return error result when GetBundles throws', async () => {
|
|
200
|
+
vi.spyOn(action, 'GetBundles').mockRejectedValue(new Error('API connection failed'));
|
|
201
|
+
|
|
202
|
+
const runParams: RunActionParams = {
|
|
203
|
+
Params: [{ Name: 'CompanyID', Type: 'Input', Value: 'comp-1' }],
|
|
204
|
+
ContextUser: contextUser,
|
|
205
|
+
} as unknown as RunActionParams;
|
|
206
|
+
|
|
207
|
+
const result = (await action['InternalRunAction'](runParams)) as ActionResultSimple;
|
|
208
|
+
|
|
209
|
+
expect(result.Success).toBe(false);
|
|
210
|
+
expect(result.ResultCode).toBe('ERROR');
|
|
211
|
+
expect(result.Message).toContain('Error retrieving bundles');
|
|
212
|
+
expect(result.Message).toContain('API connection failed');
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
});
|