richie-education 2.25.0-b2.dev148 → 2.25.0-b2.dev152
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/contexts/JoanieApiContext/index.spec.tsx +1 -1
- package/js/contexts/SessionContext/JoanieSessionProvider.spec.tsx +44 -37
- package/js/contexts/SessionContext/index.spec.tsx +42 -21
- package/js/contexts/SessionContext/no-authentication.spec.tsx +3 -2
- package/js/hooks/useCourseSearchParams/index.spec.tsx +0 -1
- package/js/hooks/useUnionResource/index.spec.tsx +11 -9
- package/js/utils/test/render.tsx +5 -1
- package/js/utils/test/wrappers/BaseAppWrapper.tsx +5 -8
- package/js/utils/test/wrappers/BaseJoanieAppWrapper.tsx +4 -7
- package/js/utils/test/wrappers/IntlWrapper.tsx +4 -2
- package/js/utils/test/wrappers/PresentationalAppWrapper.tsx +1 -1
- package/js/utils/test/wrappers/ReactQueryAppWrapper.tsx +16 -0
- package/js/widgets/Dashboard/components/DashboardAvatar/index.spec.tsx +8 -5
- package/js/widgets/Dashboard/components/DashboardBox/index.spec.tsx +3 -1
- package/js/widgets/Dashboard/components/DashboardItem/Certificate/index.spec.tsx +19 -39
- package/js/widgets/Dashboard/components/DashboardItem/CertificateStatus/index.spec.tsx +14 -12
- package/js/widgets/Dashboard/components/DashboardItem/Contract/index.spec.tsx +5 -43
- package/js/widgets/Dashboard/components/DashboardItem/CourseEnrolling/index.spec.tsx +16 -15
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.spec.tsx +8 -18
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.spec.tsx +19 -51
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.spec.tsx +40 -70
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.spec.tsx +31 -32
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateLearnerMessage/index.spec.tsx +19 -31
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateTeacherMessage/index.spec.tsx +26 -37
- package/js/widgets/Dashboard/components/DashboardItem/index.spec.tsx +28 -23
- package/js/widgets/Dashboard/components/DashboardLayoutRoute/index.spec.tsx +53 -51
- package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.spec.tsx +24 -49
- package/js/widgets/Dashboard/components/DashboardSidebar/components/MenuNavLink/index.spec.tsx +5 -14
- package/js/widgets/Dashboard/components/ProtectedOutlet/AuthenticatedOutlet.spec.tsx +62 -54
- package/js/widgets/Dashboard/components/ProtectedOutlet/ProtectedOutlet.spec.tsx +67 -42
- package/js/widgets/Dashboard/components/RouterButton/index.spec.tsx +12 -14
- package/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.spec.tsx +14 -39
- package/js/widgets/Dashboard/hooks/useDashboardRouter/index.spec.tsx +2 -4
- package/js/widgets/Dashboard/hooks/useEnroll/index.spec.tsx +7 -28
- package/js/widgets/Dashboard/hooks/useRouteInfo/index.spec.tsx +25 -33
- package/js/widgets/Dashboard/index.spec.tsx +49 -43
- package/js/widgets/LanguageSelector/index.spec.tsx +7 -7
- package/js/widgets/LtiConsumer/index.spec.tsx +46 -48
- package/js/widgets/RootSearchSuggestField/index.spec.tsx +8 -6
- package/js/widgets/Search/components/PaginateCourseSearch/index.spec.tsx +10 -3
- package/js/widgets/Search/components/SearchFilterGroup/index.spec.tsx +5 -3
- package/js/widgets/Search/components/SearchFilterGroupModal/index.spec.tsx +8 -4
- package/js/widgets/Search/components/SearchFilterValueLeaf/index.spec.tsx +7 -3
- package/js/widgets/Search/components/SearchFilterValueParent/index.spec.tsx +12 -7
- package/js/widgets/Search/components/SearchFiltersPane/index.spec.tsx +5 -1
- package/js/widgets/Search/hooks/useCourseSearch/index.spec.tsx +4 -12
- package/js/widgets/Search/hooks/useFilterValue/index.spec.tsx +0 -2
- package/js/widgets/Search/index.spec.tsx +14 -6
- package/js/widgets/SearchSuggestField/index.spec.tsx +14 -1
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCertificateItem/index.spec.tsx +16 -31
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCourseRuns/index.spec.tsx +46 -72
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseRunItem/index.spec.tsx +5 -2
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.spec.tsx +147 -162
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/CourseRunUnenrollmentButton/index.spec.tsx +6 -4
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/index.joanie.spec.tsx +22 -99
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/index.openedx.spec.tsx +27 -83
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunItem/index.spec.tsx +4 -1
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunItemWithEnrollment/index.spec.tsx +28 -35
- package/js/widgets/SyllabusCourseRunsList/components/CourseWishButton/hooks/useCourseWish/index.spec.tsx +9 -28
- package/js/widgets/SyllabusCourseRunsList/components/CourseWishButton/index.login.spec.tsx +23 -48
- package/js/widgets/SyllabusCourseRunsList/components/CourseWishButton/index.logout.spec.tsx +20 -29
- package/js/widgets/SyllabusCourseRunsList/components/SyllabusSimpleCourseRunsList/index.spec.tsx +9 -4
- package/js/widgets/SyllabusCourseRunsList/hooks/useCourseEnrollment/index.spec.tsx +8 -10
- package/js/widgets/SyllabusCourseRunsList/index.spec.tsx +28 -39
- package/js/widgets/UserLogin/components/UserMenu/index.spec.tsx +9 -6
- package/js/widgets/UserLogin/index.not.isJoanieEnabled.spec.tsx +21 -32
- package/js/widgets/UserLogin/index.spec.tsx +15 -37
- package/js/widgets/index.spec.tsx +12 -17
- package/package.json +1 -1
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
1
|
+
import { screen } from '@testing-library/react';
|
|
3
2
|
import userEvent from '@testing-library/user-event';
|
|
4
3
|
import fetchMock from 'fetch-mock';
|
|
5
|
-
import { IntlProvider } from 'react-intl';
|
|
6
4
|
import { act } from 'react-dom/test-utils';
|
|
7
|
-
import { PropsWithChildren } from 'react';
|
|
8
5
|
import {
|
|
9
6
|
RichieContextFactory as mockRichieContextFactory,
|
|
10
7
|
UserFactory,
|
|
@@ -14,8 +11,8 @@ import context from 'utils/context';
|
|
|
14
11
|
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
15
12
|
import { User } from 'types/User';
|
|
16
13
|
import { HttpStatusCode } from 'utils/errors/HttpError';
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
14
|
+
import { render } from 'utils/test/render';
|
|
15
|
+
import { BaseAppWrapper } from 'utils/test/wrappers/BaseAppWrapper';
|
|
19
16
|
import UserLogin from '.';
|
|
20
17
|
|
|
21
18
|
jest.mock('utils/errors/handle', () => ({
|
|
@@ -41,25 +38,15 @@ jest.mock('utils/context', () => ({
|
|
|
41
38
|
}));
|
|
42
39
|
|
|
43
40
|
describe('<UserLogin />', () => {
|
|
44
|
-
const Wrapper = ({
|
|
45
|
-
children,
|
|
46
|
-
user = false,
|
|
47
|
-
}: PropsWithChildren & { user?: Nullable<User | boolean> }) => (
|
|
48
|
-
<QueryClientProvider client={createTestQueryClient({ user })}>
|
|
49
|
-
<IntlProvider locale="en">
|
|
50
|
-
<BaseSessionProvider>{children}</BaseSessionProvider>
|
|
51
|
-
</IntlProvider>
|
|
52
|
-
</QueryClientProvider>
|
|
53
|
-
);
|
|
54
|
-
|
|
55
41
|
it('gets and renders the user name and a dropdown containing a logout link', async () => {
|
|
56
42
|
const user: User = UserFactory({ full_name: undefined }).one();
|
|
57
43
|
|
|
58
|
-
render(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
render(<UserLogin context={context} />, {
|
|
45
|
+
wrapper: BaseAppWrapper,
|
|
46
|
+
queryOptions: {
|
|
47
|
+
client: createTestQueryClient({ user }),
|
|
48
|
+
},
|
|
49
|
+
});
|
|
63
50
|
|
|
64
51
|
const button = await screen.findByLabelText(`Access to your profile settings`, {
|
|
65
52
|
selector: 'button',
|
|
@@ -76,11 +63,12 @@ describe('<UserLogin />', () => {
|
|
|
76
63
|
const loginDeferred = new Deferred();
|
|
77
64
|
fetchMock.get('https://auth.test/api/user/v1/me', loginDeferred.promise);
|
|
78
65
|
|
|
79
|
-
render(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
render(<UserLogin context={context} />, {
|
|
67
|
+
wrapper: BaseAppWrapper,
|
|
68
|
+
queryOptions: {
|
|
69
|
+
client: createTestQueryClient({ user: null }),
|
|
70
|
+
},
|
|
71
|
+
});
|
|
84
72
|
|
|
85
73
|
await act(async () => {
|
|
86
74
|
loginDeferred.resolve(HttpStatusCode.UNAUTHORIZED);
|
|
@@ -99,11 +87,12 @@ describe('<UserLogin />', () => {
|
|
|
99
87
|
account: { label: 'Account', action: 'https://auth.local.test/u/(username)' },
|
|
100
88
|
};
|
|
101
89
|
|
|
102
|
-
render(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
90
|
+
render(<UserLogin context={context} profileUrls={profileUrls} />, {
|
|
91
|
+
wrapper: BaseAppWrapper,
|
|
92
|
+
queryOptions: {
|
|
93
|
+
client: createTestQueryClient({ user }),
|
|
94
|
+
},
|
|
95
|
+
});
|
|
107
96
|
|
|
108
97
|
const button = await screen.findByLabelText(`Access to your profile settings`, {
|
|
109
98
|
selector: 'button',
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
1
|
+
import { screen } from '@testing-library/react';
|
|
3
2
|
import userEvent from '@testing-library/user-event';
|
|
4
3
|
import fetchMock from 'fetch-mock';
|
|
5
|
-
import { IntlProvider } from 'react-intl';
|
|
6
4
|
import { act } from 'react-dom/test-utils';
|
|
7
|
-
import { PropsWithChildren } from 'react';
|
|
8
5
|
import {
|
|
9
6
|
RichieContextFactory as mockRichieContextFactory,
|
|
10
7
|
UserFactory,
|
|
11
8
|
} from 'utils/test/factories/richie';
|
|
12
9
|
import { Deferred } from 'utils/test/deferred';
|
|
13
10
|
import context from 'utils/context';
|
|
14
|
-
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
15
11
|
import { JoanieUserApiAbilityActions, User } from 'types/User';
|
|
16
12
|
import { HttpStatusCode } from 'utils/errors/HttpError';
|
|
17
|
-
import JoanieSessionProvider from 'contexts/SessionContext/JoanieSessionProvider';
|
|
18
13
|
import { JoanieUserProfileFactory } from 'utils/test/factories/joanie';
|
|
19
|
-
import {
|
|
14
|
+
import { render } from 'utils/test/render';
|
|
15
|
+
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
20
16
|
import UserLogin from '.';
|
|
21
17
|
|
|
22
18
|
jest.mock('utils/errors/handle', () => ({
|
|
@@ -45,16 +41,6 @@ jest.mock('utils/context', () => ({
|
|
|
45
41
|
}));
|
|
46
42
|
|
|
47
43
|
describe('<UserLogin />', () => {
|
|
48
|
-
const Wrapper = ({
|
|
49
|
-
children,
|
|
50
|
-
user = false,
|
|
51
|
-
}: PropsWithChildren & { user?: Nullable<User | boolean> }) => (
|
|
52
|
-
<QueryClientProvider client={createTestQueryClient({ user })}>
|
|
53
|
-
<IntlProvider locale="en">
|
|
54
|
-
<JoanieSessionProvider>{children}</JoanieSessionProvider>
|
|
55
|
-
</IntlProvider>
|
|
56
|
-
</QueryClientProvider>
|
|
57
|
-
);
|
|
58
44
|
beforeEach(() => {
|
|
59
45
|
fetchMock
|
|
60
46
|
.get('https://endpoint.test/api/v1.0/orders/', [])
|
|
@@ -69,11 +55,9 @@ describe('<UserLogin />', () => {
|
|
|
69
55
|
const user: User = UserFactory().one();
|
|
70
56
|
|
|
71
57
|
fetchMock.get('https://endpoint.test/api/v1.0/users/me/', JoanieUserProfileFactory().one());
|
|
72
|
-
render(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
</Wrapper>,
|
|
76
|
-
);
|
|
58
|
+
render(<UserLogin context={context} />, {
|
|
59
|
+
queryOptions: { client: createTestQueryClient({ user }) },
|
|
60
|
+
});
|
|
77
61
|
|
|
78
62
|
const button = await screen.findByLabelText(`Access to your profile settings`, {
|
|
79
63
|
selector: 'button',
|
|
@@ -91,11 +75,9 @@ describe('<UserLogin />', () => {
|
|
|
91
75
|
fetchMock.get('https://auth.test/api/user/v1/me', loginDeferred.promise);
|
|
92
76
|
|
|
93
77
|
fetchMock.get('https://endpoint.test/api/v1.0/users/me/', JoanieUserProfileFactory().one());
|
|
94
|
-
render(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
</Wrapper>,
|
|
98
|
-
);
|
|
78
|
+
render(<UserLogin context={context} />, {
|
|
79
|
+
queryOptions: { client: createTestQueryClient({ user: null }) },
|
|
80
|
+
});
|
|
99
81
|
|
|
100
82
|
await act(async () => {
|
|
101
83
|
loginDeferred.resolve(HttpStatusCode.UNAUTHORIZED);
|
|
@@ -124,11 +106,9 @@ describe('<UserLogin />', () => {
|
|
|
124
106
|
},
|
|
125
107
|
}).one(),
|
|
126
108
|
);
|
|
127
|
-
render(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
</Wrapper>,
|
|
131
|
-
);
|
|
109
|
+
render(<UserLogin context={context} profileUrls={profileUrls} />, {
|
|
110
|
+
queryOptions: { client: createTestQueryClient({ user }) },
|
|
111
|
+
});
|
|
132
112
|
|
|
133
113
|
const button = await screen.findByLabelText(`Access to your profile settings`, {
|
|
134
114
|
selector: 'button',
|
|
@@ -160,11 +140,9 @@ describe('<UserLogin />', () => {
|
|
|
160
140
|
},
|
|
161
141
|
}).one(),
|
|
162
142
|
);
|
|
163
|
-
render(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
</Wrapper>,
|
|
167
|
-
);
|
|
143
|
+
render(<UserLogin context={context} profileUrls={profileUrls} />, {
|
|
144
|
+
queryOptions: { client: createTestQueryClient({ user }) },
|
|
145
|
+
});
|
|
168
146
|
|
|
169
147
|
const button = await screen.findByLabelText(`Access to your profile settings`, {
|
|
170
148
|
selector: 'button',
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { findByText, render } from '@testing-library/react';
|
|
2
|
+
import { findByText } from '@testing-library/react';
|
|
4
3
|
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
|
|
5
4
|
import { handle as mockHandle } from 'utils/errors/handle';
|
|
6
5
|
import { noop } from 'utils';
|
|
6
|
+
import { render } from 'utils/test/render';
|
|
7
|
+
import { IntlWrapper } from 'utils/test/wrappers/IntlWrapper';
|
|
7
8
|
import { Root } from '.';
|
|
8
9
|
|
|
9
10
|
jest.mock('utils/context', () => ({
|
|
@@ -55,11 +56,9 @@ describe('<Root />', () => {
|
|
|
55
56
|
document.body.append(rootSearchSuggestFieldContainer);
|
|
56
57
|
|
|
57
58
|
// Render the root component, passing the elements in need of frontend rendering
|
|
58
|
-
render(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
</IntlProvider>,
|
|
62
|
-
);
|
|
59
|
+
render(<Root richieReactSpots={[userLoginContainer, rootSearchSuggestFieldContainer]} />, {
|
|
60
|
+
wrapper: IntlWrapper,
|
|
61
|
+
});
|
|
63
62
|
|
|
64
63
|
await findByText(userLoginContainer, 'user login component rendered');
|
|
65
64
|
await findByText(
|
|
@@ -79,11 +78,9 @@ describe('<Root />', () => {
|
|
|
79
78
|
document.body.append(userFeedbackContainer);
|
|
80
79
|
|
|
81
80
|
// Render the root component, passing our real element and our bogus one
|
|
82
|
-
render(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
</IntlProvider>,
|
|
86
|
-
);
|
|
81
|
+
render(<Root richieReactSpots={[userFeedbackContainer, userLoginContainer]} />, {
|
|
82
|
+
wrapper: IntlWrapper,
|
|
83
|
+
});
|
|
87
84
|
|
|
88
85
|
await findByText(userLoginContainer, 'user login component rendered');
|
|
89
86
|
await findByText(userFeedbackContainer, '');
|
|
@@ -106,11 +103,9 @@ describe('<Root />', () => {
|
|
|
106
103
|
document.body.append(searchFailingComponent);
|
|
107
104
|
|
|
108
105
|
// Render the root component, passing our real element and our bogus one
|
|
109
|
-
render(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
</IntlProvider>,
|
|
113
|
-
);
|
|
106
|
+
render(<Root richieReactSpots={[userLoginContainer, searchFailingComponent]} />, {
|
|
107
|
+
wrapper: IntlWrapper,
|
|
108
|
+
});
|
|
114
109
|
|
|
115
110
|
await findByText(userLoginContainer, 'user login component rendered');
|
|
116
111
|
expect(mockHandle).toHaveBeenCalledWith(new Error('Failed to render Search component.'));
|