richie-education 2.25.0-b2.dev164 → 2.25.0-b2.dev169
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/.storybook/main.js +13 -10
- package/.storybook/preview.tsx +10 -7
- package/js/components/CourseGlimpse/utils.ts +6 -8
- package/js/components/PaymentButton/index.spec.tsx +14 -3
- package/js/components/SaleTunnel/components/SaleTunnelStepResume/index.tsx +4 -3
- package/js/components/SaleTunnel/components/SaleTunnelStepValidation/index.spec.tsx +1 -1
- package/js/components/SignContractButton/index.tsx +5 -5
- package/js/pages/DashboardAddressesManagement/DashboardCreateAddress.spec.tsx +2 -1
- package/js/pages/DashboardAddressesManagement/DashboardCreateAddressLoader.tsx +1 -1
- package/js/pages/DashboardAddressesManagement/DashboardEditAddress.spec.tsx +2 -1
- package/js/pages/DashboardAddressesManagement/DashboardEditAddressLoader.tsx +1 -1
- package/js/pages/DashboardAddressesManagement/index.spec.tsx +3 -2
- package/js/pages/DashboardCertificates/index.spec.tsx +2 -1
- package/js/pages/DashboardContracts/index.spec.tsx +2 -1
- package/js/pages/DashboardCourses/index.spec.tsx +2 -1
- package/js/pages/DashboardCreditCardsManagement/DashboardEditCreditCard.spec.tsx +2 -1
- package/js/pages/DashboardCreditCardsManagement/DashboardEditCreditCardLoader.tsx +1 -1
- package/js/pages/DashboardCreditCardsManagement/index.spec.tsx +2 -1
- package/js/pages/DashboardOrderLayout/index.spec.tsx +2 -1
- package/js/pages/DashboardOrderLayout/index.tsx +5 -8
- package/js/pages/DashboardPreferences/index.tsx +2 -1
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.spec.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.spec.tsx +2 -2
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.tsx +4 -5
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.spec.tsx +2 -1
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.useUnionResource.cache.spec.tsx +2 -1
- package/js/widgets/Dashboard/components/DashboardItem/index.spec.tsx +1 -1
- package/js/widgets/Dashboard/components/LearnerDashboardSidebar/index.tsx +5 -7
- package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/index.spec.tsx +4 -5
- package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/index.tsx +7 -13
- package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/utils.ts +1 -1
- package/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.tsx +4 -8
- package/js/widgets/Dashboard/components/TeacherDashboardProfileSidebar/components/OrganizationLinks/index.tsx +4 -4
- package/js/widgets/Dashboard/components/TeacherDashboardProfileSidebar/index.spec.tsx +4 -4
- package/js/widgets/Dashboard/components/TeacherDashboardProfileSidebar/index.tsx +4 -7
- package/js/widgets/Dashboard/hooks/useDashboardRouter/index.tsx +9 -15
- package/js/widgets/Dashboard/index.spec.tsx +1 -1
- package/js/widgets/Dashboard/utils/dashboardRoutes.tsx +14 -43
- package/js/widgets/Dashboard/utils/learnerRoutes.tsx +14 -24
- package/js/widgets/Dashboard/utils/learnerRoutesPaths.tsx +70 -0
- package/js/widgets/Dashboard/utils/teacherDashboardPaths.tsx +106 -0
- package/js/widgets/Dashboard/utils/teacherRoutes.tsx +22 -81
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/ProductSignatureHeader/index.tsx +4 -3
- package/package.json +42 -38
- package/js/widgets/Dashboard/utils/learnerRouteMessages.tsx +0 -125
- package/js/widgets/Dashboard/utils/teacherRouteMessages.tsx +0 -194
- /package/stories/{Introduction.stories.mdx → Introduction.mdx} +0 -0
package/.storybook/main.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import { dirname, join } from "path";
|
|
2
|
+
|
|
1
3
|
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
2
4
|
module.exports = {
|
|
3
|
-
stories: [
|
|
4
|
-
'../stories/**/*.stories.mdx',
|
|
5
|
-
'../stories/**/*.stories.@(js|jsx|ts|tsx)',
|
|
6
|
-
'../js/**/*.stories.@(js|jsx|ts|tsx)'
|
|
7
|
-
],
|
|
5
|
+
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|ts|tsx)', '../js/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
8
6
|
addons: [
|
|
9
|
-
'@storybook/addon-links',
|
|
10
|
-
'@storybook/addon-essentials',
|
|
11
|
-
'@storybook/addon-interactions'
|
|
7
|
+
getAbsolutePath('@storybook/addon-links'),
|
|
8
|
+
getAbsolutePath('@storybook/addon-essentials'),
|
|
9
|
+
getAbsolutePath('@storybook/addon-interactions'),
|
|
10
|
+
getAbsolutePath('@storybook/addon-webpack5-compiler-babel'),
|
|
12
11
|
],
|
|
13
12
|
framework: {
|
|
14
|
-
name: '@storybook/react-webpack5',
|
|
13
|
+
name: getAbsolutePath('@storybook/react-webpack5'),
|
|
15
14
|
options: {},
|
|
16
15
|
},
|
|
17
16
|
staticDirs: [{
|
|
@@ -31,6 +30,10 @@ module.exports = {
|
|
|
31
30
|
return config;
|
|
32
31
|
},
|
|
33
32
|
docs: {
|
|
34
|
-
autodocs:
|
|
33
|
+
autodocs: false,
|
|
35
34
|
},
|
|
36
35
|
};
|
|
36
|
+
|
|
37
|
+
function getAbsolutePath(value) {
|
|
38
|
+
return dirname(require.resolve(join(value, "package.json")));
|
|
39
|
+
}
|
package/.storybook/preview.tsx
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { IntlProvider } from 'react-intl';
|
|
3
3
|
import { CunninghamProvider } from '@openfun/cunningham-react';
|
|
4
|
+
import { Preview } from '@storybook/react';
|
|
4
5
|
import { useAsyncEffect } from 'hooks/useAsyncEffect';
|
|
5
6
|
import './__mocks__/utils/context';
|
|
6
7
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export const preview: Preview = {
|
|
9
|
+
parameters: {
|
|
10
|
+
actions: { argTypesRegex: '^on[A-Z].*' },
|
|
11
|
+
controls: {
|
|
12
|
+
matchers: {
|
|
13
|
+
color: /(background|color)$/i,
|
|
14
|
+
date: /Date$/,
|
|
15
|
+
},
|
|
13
16
|
},
|
|
14
|
-
}
|
|
17
|
+
}
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
const IconsWrapper = (props) => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { IntlShape } from 'react-intl';
|
|
2
|
+
import { generatePath } from 'react-router-dom';
|
|
2
3
|
import { Course as RichieCourse, isRichieCourse } from 'types/Course';
|
|
3
|
-
import { getDashboardRoutePath } from 'widgets/Dashboard/utils/dashboardRoutes';
|
|
4
|
-
import { TeacherDashboardPaths } from 'widgets/Dashboard/utils/teacherRouteMessages';
|
|
5
4
|
import {
|
|
6
5
|
CourseListItem as JoanieCourse,
|
|
7
6
|
CourseProductRelation,
|
|
8
7
|
isCourseProductRelation,
|
|
9
8
|
} from 'types/Joanie';
|
|
9
|
+
import { TeacherDashboardPaths } from 'widgets/Dashboard/utils/teacherDashboardPaths';
|
|
10
10
|
import { CourseGlimpseCourse } from '.';
|
|
11
11
|
|
|
12
12
|
const getCourseGlimpsePropsFromCourseProductRelation = (
|
|
@@ -14,17 +14,16 @@ const getCourseGlimpsePropsFromCourseProductRelation = (
|
|
|
14
14
|
intl: IntlShape,
|
|
15
15
|
organizationId?: string,
|
|
16
16
|
): CourseGlimpseCourse => {
|
|
17
|
-
const getRoutePath = getDashboardRoutePath(intl);
|
|
18
17
|
const courseRouteParams = {
|
|
19
18
|
courseId: courseProductRelation.course.id,
|
|
20
19
|
courseProductRelationId: courseProductRelation.id,
|
|
21
20
|
};
|
|
22
21
|
const courseRoute = organizationId
|
|
23
|
-
?
|
|
22
|
+
? generatePath(TeacherDashboardPaths.ORGANIZATION_PRODUCT, {
|
|
24
23
|
...courseRouteParams,
|
|
25
24
|
organizationId,
|
|
26
25
|
})
|
|
27
|
-
:
|
|
26
|
+
: generatePath(TeacherDashboardPaths.COURSE_PRODUCT, courseRouteParams);
|
|
28
27
|
return {
|
|
29
28
|
id: courseProductRelation.id,
|
|
30
29
|
code: courseProductRelation.course.code,
|
|
@@ -67,16 +66,15 @@ const getCourseGlimpsePropsFromJoanieCourse = (
|
|
|
67
66
|
intl: IntlShape,
|
|
68
67
|
organizationId?: string,
|
|
69
68
|
): CourseGlimpseCourse => {
|
|
70
|
-
const getRoutePath = getDashboardRoutePath(intl);
|
|
71
69
|
const courseRouteParams = {
|
|
72
70
|
courseId: course.id,
|
|
73
71
|
};
|
|
74
72
|
const courseRoute = organizationId
|
|
75
|
-
?
|
|
73
|
+
? generatePath(TeacherDashboardPaths.ORGANIZATION_COURSE_GENERAL_INFORMATION, {
|
|
76
74
|
...courseRouteParams,
|
|
77
75
|
organizationId,
|
|
78
76
|
})
|
|
79
|
-
:
|
|
77
|
+
: generatePath(TeacherDashboardPaths.COURSE_GENERAL_INFORMATION, courseRouteParams);
|
|
80
78
|
return {
|
|
81
79
|
id: course.id,
|
|
82
80
|
code: course.code,
|
|
@@ -159,7 +159,10 @@ describe.each([
|
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
afterEach(() => {
|
|
162
|
-
|
|
162
|
+
act(() => {
|
|
163
|
+
jest.runOnlyPendingTimers();
|
|
164
|
+
});
|
|
165
|
+
|
|
163
166
|
jest.useRealTimers();
|
|
164
167
|
cleanup();
|
|
165
168
|
});
|
|
@@ -787,9 +790,17 @@ describe.each([
|
|
|
787
790
|
screen.getByText('Payment in progress');
|
|
788
791
|
|
|
789
792
|
fetchMock.resetHistory();
|
|
793
|
+
|
|
790
794
|
// - Wait until order has been polled 29 times.
|
|
791
|
-
await
|
|
792
|
-
|
|
795
|
+
await act(async () => {
|
|
796
|
+
await jest.advanceTimersByTimeAsync(
|
|
797
|
+
(PAYMENT_SETTINGS.pollLimit - 1) * PAYMENT_SETTINGS.pollInterval,
|
|
798
|
+
);
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
await waitFor(async () => {
|
|
802
|
+
expect(fetchMock.calls()).toHaveLength(PAYMENT_SETTINGS.pollLimit - 1);
|
|
803
|
+
});
|
|
793
804
|
|
|
794
805
|
// - This round should be the last after which the order should be aborted
|
|
795
806
|
await act(async () => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Button } from '@openfun/cunningham-react';
|
|
2
2
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
3
|
+
import { generatePath } from 'react-router-dom';
|
|
3
4
|
import { SuccessIcon } from 'components/SuccessIcon';
|
|
4
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
5
5
|
import { getDashboardBasename } from 'widgets/Dashboard/hooks/useDashboardRouter/getDashboardBasename';
|
|
6
6
|
import { useSaleTunnelContext } from 'components/SaleTunnel/context';
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
8
9
|
|
|
9
10
|
const messages = defineMessages({
|
|
10
11
|
congratulations: {
|
|
@@ -72,7 +73,7 @@ export const SaleTunnelStepResume = ({ next }: SaleTunnelStepResumeProps) => {
|
|
|
72
73
|
<Button
|
|
73
74
|
href={
|
|
74
75
|
getDashboardBasename(intl.locale) +
|
|
75
|
-
|
|
76
|
+
generatePath(LearnerDashboardPaths.ORDER, { orderId: order!.id })
|
|
76
77
|
}
|
|
77
78
|
>
|
|
78
79
|
<FormattedMessage {...messages.ctaSignature} />
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { fireEvent, render, screen, within } from '@testing-library/react';
|
|
2
2
|
import { IntlProvider } from 'react-intl';
|
|
3
|
-
import { userEvent } from '@storybook/testing-library';
|
|
4
3
|
import { PropsWithChildren, useMemo, useState } from 'react';
|
|
5
4
|
import { QueryClientProvider } from '@tanstack/react-query';
|
|
6
5
|
import { CunninghamProvider } from '@openfun/cunningham-react';
|
|
6
|
+
import userEvent from '@testing-library/user-event';
|
|
7
7
|
import { Priority } from 'types';
|
|
8
8
|
import {
|
|
9
9
|
CourseRun,
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Button } from '@openfun/cunningham-react';
|
|
2
|
-
import { FormattedMessage, defineMessages
|
|
2
|
+
import { FormattedMessage, defineMessages } from 'react-intl';
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
+
import { generatePath } from 'react-router-dom';
|
|
4
5
|
import { LearnerContractFrame } from 'components/ContractFrame';
|
|
5
6
|
import { Contract, ContractState, CredentialOrder, NestedCredentialOrder } from 'types/Joanie';
|
|
6
7
|
import { RouterButton } from 'widgets/Dashboard/components/RouterButton';
|
|
7
|
-
import { getDashboardRoutePath } from 'widgets/Dashboard/utils/dashboardRoutes';
|
|
8
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
9
8
|
import DownloadContractButton from 'components/DownloadContractButton';
|
|
10
9
|
import { Maybe } from 'types/utils';
|
|
11
10
|
import { ContractHelper } from 'utils/ContractHelper';
|
|
12
11
|
|
|
12
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
13
|
+
|
|
13
14
|
const messages = defineMessages({
|
|
14
15
|
contractSignActionLabel: {
|
|
15
16
|
id: 'components.SignContractButton.contractSignActionLabel',
|
|
@@ -42,11 +43,10 @@ interface SignContractButtonLinkProps {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
const SignContractButtonLink = ({ orderId, className }: SignContractButtonLinkProps) => {
|
|
45
|
-
const getRoutePath = getDashboardRoutePath(useIntl());
|
|
46
46
|
return (
|
|
47
47
|
<RouterButton
|
|
48
48
|
size="small"
|
|
49
|
-
href={
|
|
49
|
+
href={generatePath(LearnerDashboardPaths.ORDER, {
|
|
50
50
|
orderId,
|
|
51
51
|
})}
|
|
52
52
|
className={className}
|
|
@@ -9,7 +9,6 @@ import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/fac
|
|
|
9
9
|
import { AddressFactory } from 'utils/test/factories/joanie';
|
|
10
10
|
import { SessionProvider } from 'contexts/SessionContext';
|
|
11
11
|
import { DashboardTest } from 'widgets/Dashboard/components/DashboardTest';
|
|
12
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
13
12
|
import { Address } from 'types/Joanie';
|
|
14
13
|
import { expectFetchCall } from 'utils/test/expectFetchCall';
|
|
15
14
|
import { expectBreadcrumbsToEqualParts } from 'utils/test/expectBreadcrumbsToEqualParts';
|
|
@@ -18,6 +17,8 @@ import { expectBannerError } from 'utils/test/expectBanner';
|
|
|
18
17
|
import { changeSelect } from 'components/Form/test-utils';
|
|
19
18
|
import { HttpStatusCode } from 'utils/errors/HttpError';
|
|
20
19
|
|
|
20
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
21
|
+
|
|
21
22
|
jest.mock('utils/context', () => ({
|
|
22
23
|
__esModule: true,
|
|
23
24
|
default: mockRichieContextFactory({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
2
1
|
import { useDashboardNavigate } from 'widgets/Dashboard/hooks/useDashboardRouter';
|
|
2
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
3
3
|
import { DashboardCreateAddress } from './DashboardCreateAddress';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -14,13 +14,14 @@ import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/fac
|
|
|
14
14
|
import { AddressFactory } from 'utils/test/factories/joanie';
|
|
15
15
|
import { SessionProvider } from 'contexts/SessionContext';
|
|
16
16
|
import { DashboardTest } from 'widgets/Dashboard/components/DashboardTest';
|
|
17
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
18
17
|
import { expectFetchCall } from 'utils/test/expectFetchCall';
|
|
19
18
|
import { expectBreadcrumbsToEqualParts } from 'utils/test/expectBreadcrumbsToEqualParts';
|
|
20
19
|
import JoanieSessionProvider from 'contexts/SessionContext/JoanieSessionProvider';
|
|
21
20
|
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
22
21
|
import { HttpStatusCode } from 'utils/errors/HttpError';
|
|
23
22
|
|
|
23
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
24
|
+
|
|
24
25
|
jest.mock('utils/context', () => ({
|
|
25
26
|
__esModule: true,
|
|
26
27
|
default: mockRichieContextFactory({
|
|
@@ -2,9 +2,9 @@ import { useParams } from 'react-router-dom';
|
|
|
2
2
|
import Banner, { BannerType } from 'components/Banner';
|
|
3
3
|
import { Spinner } from 'components/Spinner';
|
|
4
4
|
import { useAddress } from 'hooks/useAddresses';
|
|
5
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
6
5
|
import { useDashboardNavigate } from 'widgets/Dashboard/hooks/useDashboardRouter';
|
|
7
6
|
import { useBreadcrumbsPlaceholders } from 'hooks/useBreadcrumbsPlaceholders';
|
|
7
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
8
8
|
import { DashboardEditAddress } from './DashboardEditAddress';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
act,
|
|
3
|
+
findByText,
|
|
3
4
|
fireEvent,
|
|
4
5
|
getByRole,
|
|
5
6
|
queryByRole,
|
|
@@ -10,12 +11,10 @@ import {
|
|
|
10
11
|
import { IntlProvider } from 'react-intl';
|
|
11
12
|
import { QueryClientProvider } from '@tanstack/react-query';
|
|
12
13
|
import fetchMock from 'fetch-mock';
|
|
13
|
-
import { findByText } from '@storybook/testing-library';
|
|
14
14
|
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
|
|
15
15
|
import { AddressFactory } from 'utils/test/factories/joanie';
|
|
16
16
|
import { SessionProvider } from 'contexts/SessionContext';
|
|
17
17
|
import { DashboardTest } from 'widgets/Dashboard/components/DashboardTest';
|
|
18
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
19
18
|
import * as Joanie from 'types/Joanie';
|
|
20
19
|
import { expectBreadcrumbsToEqualParts } from 'utils/test/expectBreadcrumbsToEqualParts';
|
|
21
20
|
import { resolveAll } from 'utils/resolveAll';
|
|
@@ -23,6 +22,8 @@ import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
|
23
22
|
import { expectBannerError } from 'utils/test/expectBanner';
|
|
24
23
|
import { HttpStatusCode } from 'utils/errors/HttpError';
|
|
25
24
|
|
|
25
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
26
|
+
|
|
26
27
|
jest.mock('utils/context', () => ({
|
|
27
28
|
__esModule: true,
|
|
28
29
|
default: mockRichieContextFactory({
|
|
@@ -13,10 +13,11 @@ import { Deferred } from 'utils/test/deferred';
|
|
|
13
13
|
import { History, HistoryContext } from 'hooks/useHistory';
|
|
14
14
|
import { SessionProvider } from 'contexts/SessionContext';
|
|
15
15
|
import { DashboardTest } from 'widgets/Dashboard/components/DashboardTest';
|
|
16
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
17
16
|
import { CertificateFactory } from 'utils/test/factories/joanie';
|
|
18
17
|
import { HttpStatusCode } from 'utils/errors/HttpError';
|
|
19
18
|
|
|
19
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
20
|
+
|
|
20
21
|
jest.mock('utils/context', () => ({
|
|
21
22
|
__esModule: true,
|
|
22
23
|
default: mockRichieContextFactory({
|
|
@@ -13,9 +13,10 @@ import { Deferred } from 'utils/test/deferred';
|
|
|
13
13
|
import { History, HistoryContext } from 'hooks/useHistory';
|
|
14
14
|
import { SessionProvider } from 'contexts/SessionContext';
|
|
15
15
|
import { DashboardTest } from 'widgets/Dashboard/components/DashboardTest';
|
|
16
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
17
16
|
import { ContractFactory } from 'utils/test/factories/joanie';
|
|
18
17
|
|
|
18
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
19
|
+
|
|
19
20
|
jest.mock('utils/context', () => ({
|
|
20
21
|
__esModule: true,
|
|
21
22
|
default: mockRichieContextFactory({
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
CredentialOrderFactory,
|
|
11
11
|
} from 'utils/test/factories/joanie';
|
|
12
12
|
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
13
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
14
13
|
import { CourseLight, CourseProductRelation, Enrollment, CredentialOrder } from 'types/Joanie';
|
|
15
14
|
import { expectNoSpinner, expectSpinner } from 'utils/test/expectSpinner';
|
|
16
15
|
import { expectBannerError, expectBannerInfo, expectNoBannerInfo } from 'utils/test/expectBanner';
|
|
@@ -23,6 +22,8 @@ import { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
|
|
|
23
22
|
import { render } from 'utils/test/render';
|
|
24
23
|
import { BaseJoanieAppWrapper } from 'utils/test/wrappers/BaseJoanieAppWrapper';
|
|
25
24
|
|
|
25
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
26
|
+
|
|
26
27
|
jest.mock('utils/context', () => ({
|
|
27
28
|
__esModule: true,
|
|
28
29
|
default: mockRichieContextFactory({
|
|
@@ -14,13 +14,14 @@ import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/fac
|
|
|
14
14
|
import { CreditCardFactory } from 'utils/test/factories/joanie';
|
|
15
15
|
import { DashboardTest } from 'widgets/Dashboard/components/DashboardTest';
|
|
16
16
|
import { SessionProvider } from 'contexts/SessionContext';
|
|
17
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
18
17
|
import { expectFetchCall } from 'utils/test/expectFetchCall';
|
|
19
18
|
import { expectBreadcrumbsToEqualParts } from 'utils/test/expectBreadcrumbsToEqualParts';
|
|
20
19
|
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
21
20
|
import { expectBannerError } from 'utils/test/expectBanner';
|
|
22
21
|
import { HttpStatusCode } from 'utils/errors/HttpError';
|
|
23
22
|
|
|
23
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
24
|
+
|
|
24
25
|
jest.mock('utils/context', () => ({
|
|
25
26
|
__esModule: true,
|
|
26
27
|
default: mockRichieContextFactory({
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useParams } from 'react-router-dom';
|
|
2
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
3
2
|
import { useDashboardNavigate } from 'widgets/Dashboard/hooks/useDashboardRouter';
|
|
4
3
|
import { useCreditCard } from 'hooks/useCreditCards';
|
|
5
4
|
import { Spinner } from 'components/Spinner';
|
|
6
5
|
import Banner, { BannerType } from 'components/Banner';
|
|
7
6
|
import { useBreadcrumbsPlaceholders } from 'hooks/useBreadcrumbsPlaceholders';
|
|
7
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
8
8
|
import { DashboardEditCreditCard } from './DashboardEditCreditCard';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -16,7 +16,6 @@ import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/fac
|
|
|
16
16
|
import { CreditCardFactory } from 'utils/test/factories/joanie';
|
|
17
17
|
import { SessionProvider } from 'contexts/SessionContext';
|
|
18
18
|
import { DashboardTest } from 'widgets/Dashboard/components/DashboardTest';
|
|
19
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
20
19
|
import { CreditCard } from 'types/Joanie';
|
|
21
20
|
import { confirm } from 'utils/indirection/window';
|
|
22
21
|
import { expectBreadcrumbsToEqualParts } from 'utils/test/expectBreadcrumbsToEqualParts';
|
|
@@ -24,6 +23,8 @@ import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
|
24
23
|
import { expectBannerError } from 'utils/test/expectBanner';
|
|
25
24
|
import { HttpStatusCode } from 'utils/errors/HttpError';
|
|
26
25
|
|
|
26
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
27
|
+
|
|
27
28
|
jest.mock('utils/context', () => ({
|
|
28
29
|
__esModule: true,
|
|
29
30
|
default: mockRichieContextFactory({
|
|
@@ -6,12 +6,13 @@ import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/fac
|
|
|
6
6
|
import { CredentialOrder } from 'types/Joanie';
|
|
7
7
|
import { CredentialOrderFactory, TargetCourseFactory } from 'utils/test/factories/joanie';
|
|
8
8
|
import { mockCourseProductWithOrder } from 'utils/test/mockCourseProductWithOrder';
|
|
9
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
10
9
|
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
11
10
|
import { SessionProvider } from 'contexts/SessionContext';
|
|
12
11
|
import { DashboardTest } from 'widgets/Dashboard/components/DashboardTest';
|
|
13
12
|
import { expectUrlMatchLocationDisplayed } from 'utils/test/expectUrlMatchLocationDisplayed';
|
|
14
13
|
|
|
14
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
15
|
+
|
|
15
16
|
jest.mock('utils/context', () => ({
|
|
16
17
|
__esModule: true,
|
|
17
18
|
default: mockRichieContextFactory({
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { Outlet, useParams } from 'react-router-dom';
|
|
1
|
+
import { generatePath, Outlet, useParams } from 'react-router-dom';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
getDashboardRouteLabel,
|
|
6
|
-
getDashboardRoutePath,
|
|
7
|
-
} from 'widgets/Dashboard/utils/dashboardRoutes';
|
|
8
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
4
|
+
import { getDashboardRouteLabel } from 'widgets/Dashboard/utils/dashboardRoutes';
|
|
9
5
|
import { DashboardLayout } from 'widgets/Dashboard/components/DashboardLayout';
|
|
10
6
|
import { useOmniscientOrder } from 'hooks/useOrders';
|
|
11
7
|
import { useBreadcrumbsPlaceholders } from 'hooks/useBreadcrumbsPlaceholders';
|
|
@@ -13,6 +9,8 @@ import { CourseLight, Product } from 'types/Joanie';
|
|
|
13
9
|
import { LearnerDashboardSidebar } from 'widgets/Dashboard/components/LearnerDashboardSidebar';
|
|
14
10
|
import { useCourseProduct } from 'hooks/useCourseProducts';
|
|
15
11
|
|
|
12
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
13
|
+
|
|
16
14
|
export const DashboardOrderLayout = () => {
|
|
17
15
|
const params = useParams<{ orderId: string }>();
|
|
18
16
|
const order = useOmniscientOrder(params.orderId);
|
|
@@ -23,13 +21,12 @@ export const DashboardOrderLayout = () => {
|
|
|
23
21
|
});
|
|
24
22
|
const product = courseProduct?.item?.product;
|
|
25
23
|
const intl = useIntl();
|
|
26
|
-
const getRoutePath = getDashboardRoutePath(intl);
|
|
27
24
|
const getRouteLabel = getDashboardRouteLabel(intl);
|
|
28
25
|
|
|
29
26
|
const links = useMemo(
|
|
30
27
|
() => [
|
|
31
28
|
{
|
|
32
|
-
to:
|
|
29
|
+
to: generatePath(LearnerDashboardPaths.ORDER, { orderId: params.orderId! }),
|
|
33
30
|
label: getRouteLabel(LearnerDashboardPaths.ORDER_RUNS),
|
|
34
31
|
},
|
|
35
32
|
],
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DashboardCreditCardsManagement } from 'pages/DashboardCreditCardsManagement';
|
|
2
2
|
import { DashboardAddressesManagement } from 'pages/DashboardAddressesManagement';
|
|
3
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
4
3
|
import { useDashboardNavigate } from 'widgets/Dashboard/hooks/useDashboardRouter';
|
|
5
4
|
|
|
5
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* This component relies on react-router.
|
|
8
9
|
*/
|
|
@@ -16,13 +16,13 @@ import {
|
|
|
16
16
|
} from 'utils/test/factories/joanie';
|
|
17
17
|
import { Priority } from 'types';
|
|
18
18
|
import { DashboardTest } from 'widgets/Dashboard/components/DashboardTest';
|
|
19
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
20
19
|
import { expectNoSpinner } from 'utils/test/expectSpinner';
|
|
21
20
|
import { PER_PAGE } from 'settings';
|
|
22
21
|
import { SaleTunnelProps } from 'components/SaleTunnel';
|
|
23
22
|
import { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
|
|
24
23
|
import { render } from 'utils/test/render';
|
|
25
24
|
import { BaseJoanieAppWrapper } from 'utils/test/wrappers/BaseJoanieAppWrapper';
|
|
25
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
26
26
|
import ProductCertificateFooter from '.';
|
|
27
27
|
|
|
28
28
|
jest.mock('utils/context', () => ({
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from '@testing-library/react';
|
|
12
12
|
import { faker } from '@faker-js/faker';
|
|
13
13
|
import fetchMock from 'fetch-mock';
|
|
14
|
-
import
|
|
14
|
+
import userEvent from '@testing-library/user-event';
|
|
15
15
|
import { DEFAULT_DATE_FORMAT } from 'hooks/useDateFormat';
|
|
16
16
|
import {
|
|
17
17
|
CourseStateFactory,
|
|
@@ -39,7 +39,7 @@ import { HttpStatusCode } from 'utils/errors/HttpError';
|
|
|
39
39
|
import { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
|
|
40
40
|
import { render } from 'utils/test/render';
|
|
41
41
|
import { BaseJoanieAppWrapper } from 'utils/test/wrappers/BaseJoanieAppWrapper';
|
|
42
|
-
import { LearnerDashboardPaths } from '
|
|
42
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
43
43
|
import { DashboardTest } from '../../DashboardTest';
|
|
44
44
|
import { DashboardItemOrder } from './DashboardItemOrder';
|
|
45
45
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FormattedMessage, useIntl, defineMessages } from 'react-intl';
|
|
2
2
|
import { Button } from '@openfun/cunningham-react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
+
import { generatePath } from 'react-router-dom';
|
|
4
5
|
import { CourseLight, CredentialOrder, Product } from 'types/Joanie';
|
|
5
6
|
import { Icon, IconTypeEnum } from 'components/Icon';
|
|
6
7
|
import { CoursesHelper } from 'utils/CoursesHelper';
|
|
@@ -9,13 +10,12 @@ import { Spinner } from 'components/Spinner';
|
|
|
9
10
|
import { DashboardSubItem } from 'widgets/Dashboard/components/DashboardItem/DashboardSubItem';
|
|
10
11
|
import { DashboardItemCertificate } from 'widgets/Dashboard/components/DashboardItem/Certificate';
|
|
11
12
|
import { RouterButton } from 'widgets/Dashboard/components/RouterButton';
|
|
12
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
13
|
-
import { getDashboardRoutePath } from 'widgets/Dashboard/utils/dashboardRoutes';
|
|
14
13
|
import { useCourseProduct } from 'hooks/useCourseProducts';
|
|
15
14
|
import { OrderHelper } from 'utils/OrderHelper';
|
|
16
15
|
import ContractStatus from 'components/ContractStatus';
|
|
17
16
|
import SignContractButton from 'components/SignContractButton';
|
|
18
17
|
import { AddressView } from 'components/Address';
|
|
18
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
19
19
|
import { DashboardSubItemsList } from '../DashboardSubItemsList';
|
|
20
20
|
import { DashboardItemCourseEnrolling } from '../CourseEnrolling';
|
|
21
21
|
import { DashboardItem } from '../index';
|
|
@@ -138,7 +138,6 @@ export const DashboardItemOrder = ({
|
|
|
138
138
|
});
|
|
139
139
|
const { product } = courseProductRelation || {};
|
|
140
140
|
const needsSignature = OrderHelper.orderNeedsSignature(order, product?.contract_definition);
|
|
141
|
-
const getRoutePath = getDashboardRoutePath(useIntl());
|
|
142
141
|
|
|
143
142
|
return (
|
|
144
143
|
<div className="dashboard-item-order">
|
|
@@ -168,7 +167,7 @@ export const DashboardItemOrder = ({
|
|
|
168
167
|
<RouterButton
|
|
169
168
|
size="small"
|
|
170
169
|
className="dashboard-item__button"
|
|
171
|
-
href={
|
|
170
|
+
href={generatePath(LearnerDashboardPaths.ORDER, { orderId: order.id })}
|
|
172
171
|
data-testid="dashboard-item-order__button"
|
|
173
172
|
>
|
|
174
173
|
{intl.formatMessage(messages.accessCourse)}
|
|
@@ -203,7 +202,7 @@ export const DashboardItemOrder = ({
|
|
|
203
202
|
targetCourse,
|
|
204
203
|
order,
|
|
205
204
|
)}
|
|
206
|
-
notEnrolledUrl={
|
|
205
|
+
notEnrolledUrl={generatePath(LearnerDashboardPaths.ORDER, {
|
|
207
206
|
orderId: order.id,
|
|
208
207
|
})}
|
|
209
208
|
hideEnrollButtons={needsSignature}
|
package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.spec.tsx
CHANGED
|
@@ -11,12 +11,13 @@ import {
|
|
|
11
11
|
TargetCourseFactory,
|
|
12
12
|
} from 'utils/test/factories/joanie';
|
|
13
13
|
import { mockCourseProductWithOrder } from 'utils/test/mockCourseProductWithOrder';
|
|
14
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
15
14
|
import { expectBannerError } from 'utils/test/expectBanner';
|
|
16
15
|
import { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
|
|
17
16
|
import { render } from 'utils/test/render';
|
|
18
17
|
import { BaseJoanieAppWrapper } from 'utils/test/wrappers/BaseJoanieAppWrapper';
|
|
19
18
|
|
|
19
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
20
|
+
|
|
20
21
|
jest.mock('utils/context', () => ({
|
|
21
22
|
__esModule: true,
|
|
22
23
|
default: mockRichieContextFactory({
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
TargetCourseFactory,
|
|
12
12
|
} from 'utils/test/factories/joanie';
|
|
13
13
|
import { mockCourseProductWithOrder } from 'utils/test/mockCourseProductWithOrder';
|
|
14
|
-
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRouteMessages';
|
|
15
14
|
import { Deferred } from 'utils/test/deferred';
|
|
16
15
|
import { expectNoSpinner, expectSpinner } from 'utils/test/expectSpinner';
|
|
17
16
|
import { CONTRACT_SETTINGS } from 'settings';
|
|
@@ -19,6 +18,8 @@ import { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
|
|
|
19
18
|
import { render } from 'utils/test/render';
|
|
20
19
|
import { BaseJoanieAppWrapper } from 'utils/test/wrappers/BaseJoanieAppWrapper';
|
|
21
20
|
|
|
21
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
22
|
+
|
|
22
23
|
jest.mock('utils/context', () => ({
|
|
23
24
|
__esModule: true,
|
|
24
25
|
default: mockRichieContextFactory({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { screen } from '@testing-library/react';
|
|
2
|
-
import { userEvent } from '@storybook/testing-library';
|
|
3
2
|
import { PropsWithChildren } from 'react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { render } from 'utils/test/render';
|
|
5
5
|
import { IntlWrapper } from 'utils/test/wrappers/IntlWrapper';
|
|
6
6
|
import { DashboardSubItemsList } from './DashboardSubItemsList';
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { defineMessages, useIntl } from 'react-intl';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
getDashboardRouteLabel,
|
|
6
|
-
getDashboardRoutePath,
|
|
7
|
-
} from 'widgets/Dashboard/utils/dashboardRoutes';
|
|
3
|
+
import { generatePath } from 'react-router-dom';
|
|
4
|
+
import { getDashboardRouteLabel } from 'widgets/Dashboard/utils/dashboardRoutes';
|
|
8
5
|
import {
|
|
9
6
|
DashboardSidebar,
|
|
10
7
|
DashboardSidebarProps,
|
|
@@ -12,6 +9,8 @@ import {
|
|
|
12
9
|
import { useSession } from 'contexts/SessionContext';
|
|
13
10
|
import { UserHelper } from 'utils/UserHelper';
|
|
14
11
|
|
|
12
|
+
import { LearnerDashboardPaths } from 'widgets/Dashboard/utils/learnerRoutesPaths';
|
|
13
|
+
|
|
15
14
|
const messages = defineMessages({
|
|
16
15
|
header: {
|
|
17
16
|
id: 'components.StudentDashboardSidebar.header',
|
|
@@ -29,7 +28,6 @@ export const LearnerDashboardSidebar = (props: Partial<DashboardSidebarProps>) =
|
|
|
29
28
|
const intl = useIntl();
|
|
30
29
|
const { user } = useSession();
|
|
31
30
|
|
|
32
|
-
const getRoutePath = getDashboardRoutePath(intl);
|
|
33
31
|
const getRouteLabel = getDashboardRouteLabel(intl);
|
|
34
32
|
|
|
35
33
|
const links = useMemo(
|
|
@@ -40,7 +38,7 @@ export const LearnerDashboardSidebar = (props: Partial<DashboardSidebarProps>) =
|
|
|
40
38
|
LearnerDashboardPaths.CONTRACTS,
|
|
41
39
|
LearnerDashboardPaths.PREFERENCES,
|
|
42
40
|
].map((path) => ({
|
|
43
|
-
to:
|
|
41
|
+
to: generatePath(path),
|
|
44
42
|
label: getRouteLabel(path),
|
|
45
43
|
})),
|
|
46
44
|
[],
|