richie-education 3.1.3-dev12 → 3.1.3-dev17
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/js/api/joanie.ts +8 -8
- package/js/components/ContractFrame/OrganizationContractFrame.spec.tsx +12 -11
- package/js/components/ContractFrame/OrganizationContractFrame.tsx +4 -4
- package/js/components/CourseGlimpse/utils.ts +28 -22
- package/js/components/CourseGlimpseList/utils.ts +2 -2
- package/js/components/PurchaseButton/index.tsx +3 -3
- package/js/components/SaleTunnel/GenericSaleTunnel.tsx +3 -3
- package/js/components/SaleTunnel/SaleTunnelInformation/index.tsx +5 -3
- package/js/components/SaleTunnel/index.full-process.spec.tsx +3 -3
- package/js/components/SaleTunnel/index.spec.tsx +76 -63
- package/js/components/SaleTunnel/index.tsx +2 -2
- package/js/components/TeacherDashboardCourseList/index.spec.tsx +3 -3
- package/js/components/TeacherDashboardCourseList/index.tsx +2 -2
- package/js/hooks/useContractArchive/index.ts +3 -3
- package/js/hooks/useCourseProductUnion/index.spec.tsx +16 -16
- package/js/hooks/useCourseProductUnion/index.ts +7 -7
- package/js/hooks/useCourseProducts.ts +4 -4
- package/js/hooks/useDefaultOrganizationId/index.tsx +4 -4
- package/js/hooks/useOffering/index.ts +32 -0
- package/js/hooks/useTeacherCoursesSearch/index.tsx +4 -4
- package/js/hooks/useTeacherPendingContractsCount/index.ts +4 -4
- package/js/pages/DashboardCourses/index.spec.tsx +17 -14
- package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardContracts/index.spec.tsx +11 -8
- package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardContracts/index.tsx +6 -3
- package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.spec.tsx +11 -11
- package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.timer.spec.tsx +10 -10
- package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.tsx +4 -4
- package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.spec.tsx +5 -5
- package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.tsx +8 -8
- package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.spec.tsx +6 -6
- package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.tsx +4 -4
- package/js/pages/TeacherDashboardContractsLayout/hooks/useCheckContractArchiveExists/index.spec.tsx +7 -7
- package/js/pages/TeacherDashboardContractsLayout/hooks/useCheckContractArchiveExists/index.tsx +5 -5
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage.spec.ts +21 -21
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage.ts +19 -13
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.spec.tsx +11 -11
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.tsx +6 -6
- package/js/pages/TeacherDashboardContractsLayout/hooks/useHasContractToDownload/index.tsx +6 -3
- package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractFilters/index.spec.tsx +16 -16
- package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractFilters/index.tsx +4 -4
- package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractsToSign.tsx +7 -4
- package/js/pages/TeacherDashboardCourseLearnersLayout/hooks/useCourseLearnersFilters/index.spec.tsx +21 -21
- package/js/pages/TeacherDashboardCourseLearnersLayout/hooks/useCourseLearnersFilters/index.ts +5 -5
- package/js/pages/TeacherDashboardCourseLearnersLayout/index.spec.tsx +55 -55
- package/js/pages/TeacherDashboardCourseLearnersLayout/index.tsx +1 -1
- package/js/pages/TeacherDashboardCoursesLoader/index.spec.tsx +11 -11
- package/js/pages/TeacherDashboardOrganizationCourseLoader/index.spec.tsx +11 -11
- package/js/pages/TeacherDashboardTraining/TeacherDashboardTrainingLoader.tsx +7 -7
- package/js/pages/TeacherDashboardTraining/index.spec.tsx +25 -25
- package/js/pages/TeacherDashboardTraining/index.tsx +16 -12
- package/js/types/Joanie.ts +27 -20
- package/js/utils/test/factories/joanie.ts +14 -11
- package/js/utils/test/mockCourseProductWithOrder.ts +4 -4
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.spec.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.tsx +3 -3
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.useUnionResource.cache.spec.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/Order/Installment/index.tsx +4 -4
- package/js/widgets/Dashboard/components/DashboardItem/stories.mock.ts +1 -1
- package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.spec.tsx +23 -23
- package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.tsx +4 -4
- package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/index.spec.tsx +20 -17
- package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/index.tsx +22 -16
- package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/utils.ts +4 -4
- package/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.tsx +3 -3
- package/js/widgets/Dashboard/utils/teacherDashboardPaths.tsx +4 -4
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/CourseProductItemFooter/index.tsx +14 -14
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.spec.tsx +105 -75
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.stories.tsx +6 -4
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.tsx +27 -20
- package/js/widgets/SyllabusCourseRunsList/index.spec.tsx +8 -8
- package/package.json +1 -1
- package/js/hooks/useOffer/index.ts +0 -32
|
@@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
|
|
|
4
4
|
import queryString from 'query-string';
|
|
5
5
|
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
|
|
6
6
|
import {
|
|
7
|
-
|
|
7
|
+
OfferingFactory,
|
|
8
8
|
NestedCourseOrderFactory,
|
|
9
9
|
OrganizationFactory,
|
|
10
10
|
} from 'utils/test/factories/joanie';
|
|
@@ -49,44 +49,44 @@ describe('pages/TeacherDashboardCourseLearnersLayout', () => {
|
|
|
49
49
|
organizationFilterShouldBeDisplayed: true,
|
|
50
50
|
},
|
|
51
51
|
])('$expectedLabel', async ({ nbOrganization, organizationFilterShouldBeDisplayed }) => {
|
|
52
|
-
const
|
|
52
|
+
const offering = OfferingFactory().one();
|
|
53
53
|
const organizationList = OrganizationFactory().many(nbOrganization);
|
|
54
54
|
fetchMock.get(
|
|
55
|
-
`https://joanie.endpoint/api/v1.0/organizations/?
|
|
55
|
+
`https://joanie.endpoint/api/v1.0/organizations/?offering_id=${offering.id}`,
|
|
56
56
|
organizationList,
|
|
57
57
|
);
|
|
58
58
|
|
|
59
59
|
// Course sidebar query
|
|
60
|
-
fetchMock.get(`https://joanie.endpoint/api/v1.0/
|
|
60
|
+
fetchMock.get(`https://joanie.endpoint/api/v1.0/offerings/${offering.id}/`, {});
|
|
61
61
|
|
|
62
62
|
// First request before finding default organizationId
|
|
63
63
|
const courseOrderListQueryParams = {
|
|
64
|
-
|
|
64
|
+
offering_id: offering.id,
|
|
65
65
|
page: 1,
|
|
66
66
|
page_size: PER_PAGE.courseLearnerList,
|
|
67
67
|
};
|
|
68
68
|
fetchMock.get(
|
|
69
|
-
`https://joanie.endpoint/api/v1.0/courses/${
|
|
69
|
+
`https://joanie.endpoint/api/v1.0/courses/${offering.course.id}/orders/?${queryString.stringify(courseOrderListQueryParams, { sort: false })}`,
|
|
70
70
|
[],
|
|
71
71
|
);
|
|
72
72
|
|
|
73
73
|
if (organizationList.length > 0) {
|
|
74
74
|
// Course sidebar query
|
|
75
75
|
fetchMock.get(
|
|
76
|
-
`https://joanie.endpoint/api/v1.0/organizations/${organizationList[0].id}/contracts/?
|
|
76
|
+
`https://joanie.endpoint/api/v1.0/organizations/${organizationList[0].id}/contracts/?offering_id=${offering.id}&signature_state=half_signed&page=1&page_size=${PER_PAGE.teacherContractList}`,
|
|
77
77
|
[],
|
|
78
78
|
);
|
|
79
79
|
|
|
80
80
|
// Second request when default organizationId is fetched
|
|
81
81
|
fetchMock.get(
|
|
82
|
-
`https://joanie.endpoint/api/v1.0/courses/${
|
|
82
|
+
`https://joanie.endpoint/api/v1.0/courses/${offering.course.id}/orders/?${queryString.stringify({ organization_id: organizationList[0].id, ...courseOrderListQueryParams }, { sort: false })}`,
|
|
83
83
|
[],
|
|
84
84
|
);
|
|
85
85
|
}
|
|
86
86
|
render(<TeacherDashboardCourseLearnersLayout />, {
|
|
87
87
|
routerOptions: {
|
|
88
|
-
path: '/:courseId/:
|
|
89
|
-
initialEntries: [`/${
|
|
88
|
+
path: '/:courseId/:offeringId',
|
|
89
|
+
initialEntries: [`/${offering.course.id}/${offering.id}`],
|
|
90
90
|
},
|
|
91
91
|
});
|
|
92
92
|
|
|
@@ -109,42 +109,42 @@ describe('pages/TeacherDashboardCourseLearnersLayout', () => {
|
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
it('should call onFiltersChange on organization filter change', async () => {
|
|
112
|
-
const
|
|
112
|
+
const offering = OfferingFactory().one();
|
|
113
113
|
const defaultOrganization = OrganizationFactory().one();
|
|
114
114
|
const otherOrganization = OrganizationFactory().one();
|
|
115
115
|
const organizationList = [defaultOrganization, otherOrganization];
|
|
116
116
|
|
|
117
117
|
// Course sidebar queries
|
|
118
118
|
fetchMock.get(
|
|
119
|
-
`https://joanie.endpoint/api/v1.0/organizations/${defaultOrganization.id}/contracts/?
|
|
119
|
+
`https://joanie.endpoint/api/v1.0/organizations/${defaultOrganization.id}/contracts/?offering_id=${offering.id}&signature_state=half_signed&page=1&page_size=${PER_PAGE.teacherContractList}`,
|
|
120
120
|
[],
|
|
121
121
|
);
|
|
122
|
-
fetchMock.get(`https://joanie.endpoint/api/v1.0/
|
|
122
|
+
fetchMock.get(`https://joanie.endpoint/api/v1.0/offerings/${offering.id}/`, {});
|
|
123
123
|
|
|
124
124
|
fetchMock.get(
|
|
125
|
-
`https://joanie.endpoint/api/v1.0/organizations/?
|
|
125
|
+
`https://joanie.endpoint/api/v1.0/organizations/?offering_id=${offering.id}`,
|
|
126
126
|
organizationList,
|
|
127
127
|
);
|
|
128
128
|
// First request before finding default organizationId
|
|
129
129
|
const courseOrderListQueryParams = {
|
|
130
|
-
|
|
130
|
+
offering_id: offering.id,
|
|
131
131
|
page: 1,
|
|
132
132
|
page_size: PER_PAGE.courseLearnerList,
|
|
133
133
|
};
|
|
134
134
|
fetchMock.get(
|
|
135
|
-
`https://joanie.endpoint/api/v1.0/courses/${
|
|
135
|
+
`https://joanie.endpoint/api/v1.0/courses/${offering.course.id}/orders/?${queryString.stringify(courseOrderListQueryParams, { sort: false })}`,
|
|
136
136
|
[],
|
|
137
137
|
);
|
|
138
138
|
// Second request when default organizationId is fetched
|
|
139
139
|
fetchMock.get(
|
|
140
|
-
`https://joanie.endpoint/api/v1.0/courses/${
|
|
140
|
+
`https://joanie.endpoint/api/v1.0/courses/${offering.course.id}/orders/?${queryString.stringify({ organization_id: defaultOrganization.id, ...courseOrderListQueryParams }, { sort: false })}`,
|
|
141
141
|
[],
|
|
142
142
|
);
|
|
143
143
|
|
|
144
144
|
render(<TeacherDashboardCourseLearnersLayout />, {
|
|
145
145
|
routerOptions: {
|
|
146
|
-
path: '/:courseId/:
|
|
147
|
-
initialEntries: [`/${
|
|
146
|
+
path: '/:courseId/:offeringId',
|
|
147
|
+
initialEntries: [`/${offering.course.id}/${offering.id}`],
|
|
148
148
|
},
|
|
149
149
|
});
|
|
150
150
|
|
|
@@ -158,57 +158,57 @@ describe('pages/TeacherDashboardCourseLearnersLayout', () => {
|
|
|
158
158
|
const optionToSelect = screen.getByRole('option', { name: organizationList[1].title });
|
|
159
159
|
|
|
160
160
|
fetchMock.get(
|
|
161
|
-
`https://joanie.endpoint/api/v1.0/courses/${
|
|
161
|
+
`https://joanie.endpoint/api/v1.0/courses/${offering.course.id}/orders/?${queryString.stringify({ organization_id: otherOrganization.id, ...courseOrderListQueryParams }, { sort: false })}`,
|
|
162
162
|
[],
|
|
163
163
|
);
|
|
164
164
|
await user.click(optionToSelect);
|
|
165
165
|
// onload default value is undefine and is onFiltersChange called once
|
|
166
166
|
expect(
|
|
167
167
|
fetchMock.called(
|
|
168
|
-
`https://joanie.endpoint/api/v1.0/courses/${
|
|
168
|
+
`https://joanie.endpoint/api/v1.0/courses/${offering.course.id}/orders/?${queryString.stringify({ organization_id: otherOrganization.id, ...courseOrderListQueryParams }, { sort: false })}`,
|
|
169
169
|
),
|
|
170
170
|
).toBe(true);
|
|
171
171
|
});
|
|
172
172
|
|
|
173
|
-
it('should render a list of course learners for
|
|
173
|
+
it('should render a list of course learners for an offering', async () => {
|
|
174
174
|
const defaultOrganization = OrganizationFactory().one();
|
|
175
175
|
const otherOrganization = OrganizationFactory().one();
|
|
176
176
|
const organizationList = [defaultOrganization, otherOrganization];
|
|
177
|
-
const
|
|
177
|
+
const offering = OfferingFactory().one();
|
|
178
178
|
const courseOrderList = NestedCourseOrderFactory().many(3);
|
|
179
179
|
|
|
180
180
|
// Course sidebar queries
|
|
181
181
|
fetchMock.get(
|
|
182
|
-
`https://joanie.endpoint/api/v1.0/organizations/${defaultOrganization.id}/contracts/?
|
|
182
|
+
`https://joanie.endpoint/api/v1.0/organizations/${defaultOrganization.id}/contracts/?offering_id=${offering.id}&signature_state=half_signed&page=1&page_size=${PER_PAGE.teacherContractList}`,
|
|
183
183
|
[],
|
|
184
184
|
);
|
|
185
|
-
fetchMock.get(`https://joanie.endpoint/api/v1.0/
|
|
185
|
+
fetchMock.get(`https://joanie.endpoint/api/v1.0/offerings/${offering.id}/`, {});
|
|
186
186
|
|
|
187
187
|
fetchMock.get(
|
|
188
|
-
`https://joanie.endpoint/api/v1.0/organizations/?
|
|
188
|
+
`https://joanie.endpoint/api/v1.0/organizations/?offering_id=${offering.id}`,
|
|
189
189
|
organizationList,
|
|
190
190
|
);
|
|
191
191
|
|
|
192
192
|
// First request before finding default organizationId
|
|
193
193
|
const courseOrderListQueryParams = {
|
|
194
|
-
|
|
194
|
+
offering_id: offering.id,
|
|
195
195
|
page: 1,
|
|
196
196
|
page_size: PER_PAGE.courseLearnerList,
|
|
197
197
|
};
|
|
198
198
|
fetchMock.get(
|
|
199
|
-
`https://joanie.endpoint/api/v1.0/courses/${
|
|
199
|
+
`https://joanie.endpoint/api/v1.0/courses/${offering.course.id}/orders/?${queryString.stringify(courseOrderListQueryParams, { sort: false })}`,
|
|
200
200
|
courseOrderList,
|
|
201
201
|
);
|
|
202
202
|
// Second request when default organizationId is fetched
|
|
203
203
|
fetchMock.get(
|
|
204
|
-
`https://joanie.endpoint/api/v1.0/courses/${
|
|
204
|
+
`https://joanie.endpoint/api/v1.0/courses/${offering.course.id}/orders/?${queryString.stringify({ organization_id: defaultOrganization.id, ...courseOrderListQueryParams }, { sort: false })}`,
|
|
205
205
|
courseOrderList,
|
|
206
206
|
);
|
|
207
207
|
|
|
208
208
|
render(<TeacherDashboardCourseLearnersLayout />, {
|
|
209
209
|
routerOptions: {
|
|
210
|
-
path: '/:courseId/:
|
|
211
|
-
initialEntries: [`/${
|
|
210
|
+
path: '/:courseId/:offeringId',
|
|
211
|
+
initialEntries: [`/${offering.course.id}/${offering.id}`],
|
|
212
212
|
},
|
|
213
213
|
});
|
|
214
214
|
|
|
@@ -230,39 +230,39 @@ describe('pages/TeacherDashboardCourseLearnersLayout', () => {
|
|
|
230
230
|
|
|
231
231
|
it('should render a list of course learners for an organization', async () => {
|
|
232
232
|
const organization = OrganizationFactory().one();
|
|
233
|
-
const
|
|
233
|
+
const offering = OfferingFactory().one();
|
|
234
234
|
const courseOrderList = NestedCourseOrderFactory().many(3);
|
|
235
235
|
|
|
236
236
|
// Course sidebar queries
|
|
237
237
|
fetchMock.get(
|
|
238
|
-
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/contracts/?
|
|
238
|
+
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/contracts/?offering_id=${offering.id}&signature_state=half_signed&page=1&page_size=${PER_PAGE.teacherContractList}`,
|
|
239
239
|
[],
|
|
240
240
|
);
|
|
241
241
|
fetchMock.get(
|
|
242
|
-
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/
|
|
242
|
+
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/offerings/${offering.id}/`,
|
|
243
243
|
{},
|
|
244
244
|
);
|
|
245
245
|
|
|
246
246
|
// before default organization's fetched, we query all organization to decide if we should display organization filter or not.
|
|
247
|
-
fetchMock.get(`https://joanie.endpoint/api/v1.0/organizations/?
|
|
247
|
+
fetchMock.get(`https://joanie.endpoint/api/v1.0/organizations/?offering_id=${offering.id}`, [
|
|
248
248
|
organization,
|
|
249
249
|
]);
|
|
250
250
|
|
|
251
251
|
const courseOrderListQueryParams = {
|
|
252
252
|
organization_id: organization.id,
|
|
253
|
-
|
|
253
|
+
offering_id: offering.id,
|
|
254
254
|
page: 1,
|
|
255
255
|
page_size: PER_PAGE.courseLearnerList,
|
|
256
256
|
};
|
|
257
257
|
fetchMock.get(
|
|
258
|
-
`https://joanie.endpoint/api/v1.0/courses/${
|
|
258
|
+
`https://joanie.endpoint/api/v1.0/courses/${offering.course.id}/orders/?${queryString.stringify(courseOrderListQueryParams, { sort: false })}`,
|
|
259
259
|
courseOrderList,
|
|
260
260
|
);
|
|
261
261
|
|
|
262
262
|
render(<TeacherDashboardCourseLearnersLayout />, {
|
|
263
263
|
routerOptions: {
|
|
264
|
-
path: '/:organizationId/:courseId/:
|
|
265
|
-
initialEntries: [`/${organization.id}/${
|
|
264
|
+
path: '/:organizationId/:courseId/:offeringId',
|
|
265
|
+
initialEntries: [`/${organization.id}/${offering.course.id}/${offering.id}`],
|
|
266
266
|
},
|
|
267
267
|
});
|
|
268
268
|
|
|
@@ -282,38 +282,38 @@ describe('pages/TeacherDashboardCourseLearnersLayout', () => {
|
|
|
282
282
|
|
|
283
283
|
it('should render an empty table if there are no course learners', async () => {
|
|
284
284
|
const organization = OrganizationFactory().one();
|
|
285
|
-
const
|
|
285
|
+
const offering = OfferingFactory().one();
|
|
286
286
|
|
|
287
287
|
// Course sidebar queries
|
|
288
288
|
fetchMock.get(
|
|
289
|
-
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/contracts/?
|
|
289
|
+
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/contracts/?offering_id=${offering.id}&signature_state=half_signed&page=1&page_size=${PER_PAGE.teacherContractList}`,
|
|
290
290
|
[],
|
|
291
291
|
);
|
|
292
292
|
fetchMock.get(
|
|
293
|
-
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/
|
|
293
|
+
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/offerings/${offering.id}/`,
|
|
294
294
|
{},
|
|
295
295
|
);
|
|
296
296
|
|
|
297
297
|
// before default organization's fetched, we query all organization to decide if we should display organization filter or not.
|
|
298
|
-
fetchMock.get(`https://joanie.endpoint/api/v1.0/organizations/?
|
|
298
|
+
fetchMock.get(`https://joanie.endpoint/api/v1.0/organizations/?offering_id=${offering.id}`, [
|
|
299
299
|
organization,
|
|
300
300
|
]);
|
|
301
301
|
|
|
302
302
|
const courseOrderListQueryParams = {
|
|
303
303
|
organization_id: organization.id,
|
|
304
|
-
|
|
304
|
+
offering_id: offering.id,
|
|
305
305
|
page: 1,
|
|
306
306
|
page_size: PER_PAGE.courseLearnerList,
|
|
307
307
|
};
|
|
308
308
|
fetchMock.get(
|
|
309
|
-
`https://joanie.endpoint/api/v1.0/courses/${
|
|
309
|
+
`https://joanie.endpoint/api/v1.0/courses/${offering.course.id}/orders/?${queryString.stringify(courseOrderListQueryParams, { sort: false })}`,
|
|
310
310
|
[],
|
|
311
311
|
);
|
|
312
312
|
|
|
313
313
|
render(<TeacherDashboardCourseLearnersLayout />, {
|
|
314
314
|
routerOptions: {
|
|
315
|
-
path: '/:organizationId/:courseId/:
|
|
316
|
-
initialEntries: [`/${organization.id}/${
|
|
315
|
+
path: '/:organizationId/:courseId/:offeringId',
|
|
316
|
+
initialEntries: [`/${organization.id}/${offering.course.id}/${offering.id}`],
|
|
317
317
|
},
|
|
318
318
|
});
|
|
319
319
|
|
|
@@ -326,38 +326,38 @@ describe('pages/TeacherDashboardCourseLearnersLayout', () => {
|
|
|
326
326
|
|
|
327
327
|
it('should render an error banner if an error occured during course learners fetching', async () => {
|
|
328
328
|
const organization = OrganizationFactory().one();
|
|
329
|
-
const
|
|
329
|
+
const offering = OfferingFactory().one();
|
|
330
330
|
|
|
331
331
|
// Course sidebar queries
|
|
332
332
|
fetchMock.get(
|
|
333
|
-
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/contracts/?
|
|
333
|
+
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/contracts/?offering_id=${offering.id}&signature_state=half_signed&page=1&page_size=${PER_PAGE.teacherContractList}`,
|
|
334
334
|
[],
|
|
335
335
|
);
|
|
336
336
|
fetchMock.get(
|
|
337
|
-
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/
|
|
337
|
+
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/offerings/${offering.id}/`,
|
|
338
338
|
{},
|
|
339
339
|
);
|
|
340
340
|
|
|
341
341
|
// before default organization's fetched, we query all organization to decide if we should display organization filter or not.
|
|
342
|
-
fetchMock.get(`https://joanie.endpoint/api/v1.0/organizations/?
|
|
342
|
+
fetchMock.get(`https://joanie.endpoint/api/v1.0/organizations/?offering_id=${offering.id}`, [
|
|
343
343
|
organization,
|
|
344
344
|
]);
|
|
345
345
|
|
|
346
346
|
const courseOrderListQueryParams = {
|
|
347
347
|
organization_id: organization.id,
|
|
348
|
-
|
|
348
|
+
offering_id: offering.id,
|
|
349
349
|
page: 1,
|
|
350
350
|
page_size: PER_PAGE.courseLearnerList,
|
|
351
351
|
};
|
|
352
352
|
fetchMock.get(
|
|
353
|
-
`https://joanie.endpoint/api/v1.0/courses/${
|
|
353
|
+
`https://joanie.endpoint/api/v1.0/courses/${offering.course.id}/orders/?${queryString.stringify(courseOrderListQueryParams, { sort: false })}`,
|
|
354
354
|
new Response('', { status: HttpStatusCode.NOT_FOUND }),
|
|
355
355
|
);
|
|
356
356
|
|
|
357
357
|
render(<TeacherDashboardCourseLearnersLayout />, {
|
|
358
358
|
routerOptions: {
|
|
359
|
-
path: '/:organizationId/:courseId/:
|
|
360
|
-
initialEntries: [`/${organization.id}/${
|
|
359
|
+
path: '/:organizationId/:courseId/:offeringId',
|
|
360
|
+
initialEntries: [`/${organization.id}/${offering.course.id}/${offering.id}`],
|
|
361
361
|
},
|
|
362
362
|
});
|
|
363
363
|
|
|
@@ -65,7 +65,7 @@ export const TeacherDashboardCourseLearnersLayout = () => {
|
|
|
65
65
|
const {
|
|
66
66
|
items: organizations,
|
|
67
67
|
states: { isFetched: isOrganizationFetched },
|
|
68
|
-
} = useOrganizations({
|
|
68
|
+
} = useOrganizations({ offering_id: filters.offering_id });
|
|
69
69
|
const {
|
|
70
70
|
items: courseOrders,
|
|
71
71
|
meta,
|
|
@@ -2,7 +2,7 @@ import { screen, waitFor } from '@testing-library/react';
|
|
|
2
2
|
import fetchMock from 'fetch-mock';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
|
|
5
|
-
import { CourseListItemFactory,
|
|
5
|
+
import { CourseListItemFactory, OfferingFactory } from 'utils/test/factories/joanie';
|
|
6
6
|
import { expectNoSpinner } from 'utils/test/expectSpinner';
|
|
7
7
|
import { mockPaginatedResponse } from 'utils/test/mockPaginatedResponse';
|
|
8
8
|
import { PER_PAGE } from 'settings';
|
|
@@ -48,19 +48,19 @@ describe('components/TeacherDashboardCoursesLoader', () => {
|
|
|
48
48
|
mockPaginatedResponse(CourseListItemFactory().many(15), 15, false),
|
|
49
49
|
);
|
|
50
50
|
fetchMock.get(
|
|
51
|
-
`https://joanie.endpoint/api/v1.0/
|
|
52
|
-
mockPaginatedResponse(
|
|
51
|
+
`https://joanie.endpoint/api/v1.0/offerings/?product_type=credential&page=1&page_size=${perPage}`,
|
|
52
|
+
mockPaginatedResponse(OfferingFactory().many(15), 15, false),
|
|
53
53
|
);
|
|
54
54
|
|
|
55
55
|
render(<TeacherDashboardCoursesLoader />);
|
|
56
56
|
await expectNoSpinner('Loading courses...');
|
|
57
57
|
|
|
58
58
|
nbApiCalls += 1; // course api call
|
|
59
|
-
nbApiCalls += 1; //
|
|
59
|
+
nbApiCalls += 1; // offerings api call
|
|
60
60
|
const calledUrls = fetchMock.calls().map((call) => call[0]);
|
|
61
61
|
expect(calledUrls).toHaveLength(nbApiCalls);
|
|
62
62
|
expect(calledUrls).toContain(
|
|
63
|
-
`https://joanie.endpoint/api/v1.0/
|
|
63
|
+
`https://joanie.endpoint/api/v1.0/offerings/?product_type=credential&page=1&page_size=${perPage}`,
|
|
64
64
|
);
|
|
65
65
|
|
|
66
66
|
// section titles
|
|
@@ -80,8 +80,8 @@ describe('components/TeacherDashboardCoursesLoader', () => {
|
|
|
80
80
|
mockPaginatedResponse(CourseListItemFactory().many(15), 15, false),
|
|
81
81
|
);
|
|
82
82
|
fetchMock.get(
|
|
83
|
-
`https://joanie.endpoint/api/v1.0/
|
|
84
|
-
mockPaginatedResponse(
|
|
83
|
+
`https://joanie.endpoint/api/v1.0/offerings/?product_type=credential&page=1&page_size=${perPage}`,
|
|
84
|
+
mockPaginatedResponse(OfferingFactory().many(15), 15, false),
|
|
85
85
|
);
|
|
86
86
|
|
|
87
87
|
render(<TeacherDashboardCoursesLoader />);
|
|
@@ -93,22 +93,22 @@ describe('components/TeacherDashboardCoursesLoader', () => {
|
|
|
93
93
|
mockPaginatedResponse(CourseListItemFactory().many(5), 5, false),
|
|
94
94
|
);
|
|
95
95
|
fetchMock.get(
|
|
96
|
-
`https://joanie.endpoint/api/v1.0/
|
|
97
|
-
mockPaginatedResponse(
|
|
96
|
+
`https://joanie.endpoint/api/v1.0/offerings/?query=text+query&product_type=credential&page=1&page_size=${perPage}`,
|
|
97
|
+
mockPaginatedResponse(OfferingFactory().many(5), 5, false),
|
|
98
98
|
);
|
|
99
99
|
const user = userEvent.setup();
|
|
100
100
|
await user.type(screen.getByRole('textbox', { name: /Search/ }), 'text query');
|
|
101
101
|
await user.click(screen.getByRole('button', { name: /Search/ }));
|
|
102
102
|
|
|
103
103
|
nbApiCalls = 1; // course api call
|
|
104
|
-
nbApiCalls += 1; //
|
|
104
|
+
nbApiCalls += 1; // offerings api call
|
|
105
105
|
const calledUrls = fetchMock.calls().map((call) => call[0]);
|
|
106
106
|
expect(calledUrls).toHaveLength(nbApiCalls);
|
|
107
107
|
expect(calledUrls).toContain(
|
|
108
108
|
`https://joanie.endpoint/api/v1.0/courses/?query=text+query&has_listed_course_runs=true&page=1&page_size=${perPage}`,
|
|
109
109
|
);
|
|
110
110
|
expect(calledUrls).toContain(
|
|
111
|
-
`https://joanie.endpoint/api/v1.0/
|
|
111
|
+
`https://joanie.endpoint/api/v1.0/offerings/?query=text+query&product_type=credential&page=1&page_size=${perPage}`,
|
|
112
112
|
);
|
|
113
113
|
|
|
114
114
|
await waitFor(() => {
|
|
@@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
|
|
|
4
4
|
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
|
|
5
5
|
import {
|
|
6
6
|
CourseListItemFactory,
|
|
7
|
-
|
|
7
|
+
OfferingFactory,
|
|
8
8
|
OrganizationFactory,
|
|
9
9
|
} from 'utils/test/factories/joanie';
|
|
10
10
|
import { expectNoSpinner } from 'utils/test/expectSpinner';
|
|
@@ -59,8 +59,8 @@ describe('components/TeacherDashboardOrganizationCourseLoader', () => {
|
|
|
59
59
|
mockPaginatedResponse(CourseListItemFactory().many(15), 15, false),
|
|
60
60
|
);
|
|
61
61
|
fetchMock.get(
|
|
62
|
-
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/
|
|
63
|
-
mockPaginatedResponse(
|
|
62
|
+
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/offerings/?product_type=credential&page=1&page_size=${perPage}`,
|
|
63
|
+
mockPaginatedResponse(OfferingFactory().many(15), 15, false),
|
|
64
64
|
);
|
|
65
65
|
fetchMock.get(
|
|
66
66
|
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/contracts/?signature_state=half_signed&page=1`,
|
|
@@ -76,7 +76,7 @@ describe('components/TeacherDashboardOrganizationCourseLoader', () => {
|
|
|
76
76
|
await expectNoSpinner('Loading courses...');
|
|
77
77
|
|
|
78
78
|
nbApiCalls += 1; // course api call
|
|
79
|
-
nbApiCalls += 1; //
|
|
79
|
+
nbApiCalls += 1; // offerings api call
|
|
80
80
|
nbApiCalls += 1; // contracts api call
|
|
81
81
|
const calledUrls = fetchMock.calls().map((call) => call[0]);
|
|
82
82
|
expect(calledUrls).toHaveLength(nbApiCalls);
|
|
@@ -84,7 +84,7 @@ describe('components/TeacherDashboardOrganizationCourseLoader', () => {
|
|
|
84
84
|
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/courses/?has_listed_course_runs=true&page=1&page_size=${perPage}`,
|
|
85
85
|
);
|
|
86
86
|
expect(calledUrls).toContain(
|
|
87
|
-
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/
|
|
87
|
+
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/offerings/?product_type=credential&page=1&page_size=${perPage}`,
|
|
88
88
|
);
|
|
89
89
|
await expectNoSpinner('Loading organization...');
|
|
90
90
|
|
|
@@ -117,8 +117,8 @@ describe('components/TeacherDashboardOrganizationCourseLoader', () => {
|
|
|
117
117
|
mockPaginatedResponse(CourseListItemFactory().many(15), 15, false),
|
|
118
118
|
);
|
|
119
119
|
fetchMock.get(
|
|
120
|
-
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/
|
|
121
|
-
mockPaginatedResponse(
|
|
120
|
+
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/offerings/?product_type=credential&page=1&page_size=${perPage}`,
|
|
121
|
+
mockPaginatedResponse(OfferingFactory().many(15), 15, false),
|
|
122
122
|
);
|
|
123
123
|
|
|
124
124
|
render(<TeacherDashboardOrganizationCourseLoader />, {
|
|
@@ -136,22 +136,22 @@ describe('components/TeacherDashboardOrganizationCourseLoader', () => {
|
|
|
136
136
|
mockPaginatedResponse(CourseListItemFactory().many(5), 5, false),
|
|
137
137
|
);
|
|
138
138
|
fetchMock.get(
|
|
139
|
-
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/
|
|
140
|
-
mockPaginatedResponse(
|
|
139
|
+
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/offerings/?query=text+query&product_type=credential&page=1&page_size=${perPage}`,
|
|
140
|
+
mockPaginatedResponse(OfferingFactory().many(5), 5, false),
|
|
141
141
|
);
|
|
142
142
|
const user = userEvent.setup();
|
|
143
143
|
await user.type(screen.getByRole('textbox', { name: /Search/ }), 'text query');
|
|
144
144
|
await user.click(screen.getByRole('button', { name: /Search/ }));
|
|
145
145
|
|
|
146
146
|
nbApiCalls = 1; // course api call
|
|
147
|
-
nbApiCalls += 1; //
|
|
147
|
+
nbApiCalls += 1; // offerings api call
|
|
148
148
|
const calledUrls = fetchMock.calls().map((call) => call[0]);
|
|
149
149
|
expect(calledUrls).toHaveLength(nbApiCalls);
|
|
150
150
|
expect(calledUrls).toContain(
|
|
151
151
|
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/courses/?query=text+query&has_listed_course_runs=true&page=1&page_size=${perPage}`,
|
|
152
152
|
);
|
|
153
153
|
expect(calledUrls).toContain(
|
|
154
|
-
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/
|
|
154
|
+
`https://joanie.endpoint/api/v1.0/organizations/${organization.id}/offerings/?query=text+query&product_type=credential&page=1&page_size=${perPage}`,
|
|
155
155
|
);
|
|
156
156
|
|
|
157
157
|
await waitFor(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FormattedMessage, defineMessages } from 'react-intl';
|
|
2
2
|
import { useParams } from 'react-router';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { useOffering } from 'hooks/useOffering';
|
|
5
5
|
import { DashboardLayout } from 'widgets/Dashboard/components/DashboardLayout';
|
|
6
6
|
import { TeacherDashboardCourseSidebar } from 'widgets/Dashboard/components/TeacherDashboardCourseSidebar';
|
|
7
7
|
import { Spinner } from 'components/Spinner';
|
|
@@ -22,17 +22,17 @@ const messages = defineMessages({
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
export const TeacherDashboardTrainingLoader = () => {
|
|
25
|
-
const {
|
|
26
|
-
|
|
25
|
+
const { offeringId, organizationId } = useParams<{
|
|
26
|
+
offeringId: string;
|
|
27
27
|
organizationId?: string;
|
|
28
28
|
}>();
|
|
29
29
|
|
|
30
30
|
const {
|
|
31
|
-
item:
|
|
31
|
+
item: offering,
|
|
32
32
|
states: { fetching },
|
|
33
|
-
} =
|
|
33
|
+
} = useOffering(offeringId, { organization_id: organizationId });
|
|
34
34
|
useBreadcrumbsPlaceholders({
|
|
35
|
-
courseTitle:
|
|
35
|
+
courseTitle: offering?.product.title ?? '',
|
|
36
36
|
});
|
|
37
37
|
return (
|
|
38
38
|
<DashboardLayout sidebar={<TeacherDashboardCourseSidebar />}>
|
|
@@ -48,7 +48,7 @@ export const TeacherDashboardTrainingLoader = () => {
|
|
|
48
48
|
</span>
|
|
49
49
|
</Spinner>
|
|
50
50
|
) : (
|
|
51
|
-
<TeacherDashboardTraining
|
|
51
|
+
<TeacherDashboardTraining offering={offering} />
|
|
52
52
|
)}
|
|
53
53
|
</DashboardLayout>
|
|
54
54
|
);
|