@edx/frontend-plugin-learner-dashboard 3.3.5 → 3.5.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.
Files changed (84) hide show
  1. package/dist/index.js +14 -0
  2. package/dist/index.js.map +1 -1
  3. package/dist/package.json +6 -3
  4. package/dist/progressive-profiling-dashboard/ProgressiveProfilingEntry.js +38 -0
  5. package/dist/progressive-profiling-dashboard/ProgressiveProfilingEntry.js.map +1 -0
  6. package/dist/progressive-profiling-dashboard/ProgressiveProfilingModal.js +117 -0
  7. package/dist/progressive-profiling-dashboard/ProgressiveProfilingModal.js.map +1 -0
  8. package/dist/progressive-profiling-dashboard/api/service.js +37 -0
  9. package/dist/progressive-profiling-dashboard/api/service.js.map +1 -0
  10. package/dist/progressive-profiling-dashboard/data/progressiveProfilingFields.js +25 -0
  11. package/dist/progressive-profiling-dashboard/data/progressiveProfilingFields.js.map +1 -0
  12. package/dist/progressive-profiling-dashboard/field-renderer/FieldRenderer.js +86 -0
  13. package/dist/progressive-profiling-dashboard/field-renderer/FieldRenderer.js.map +1 -0
  14. package/dist/progressive-profiling-dashboard/field-renderer/index.js +14 -0
  15. package/dist/progressive-profiling-dashboard/field-renderer/index.js.map +1 -0
  16. package/dist/progressive-profiling-dashboard/hooks/useClearProgressiveProfilingQueryParams.js +16 -0
  17. package/dist/progressive-profiling-dashboard/hooks/useClearProgressiveProfilingQueryParams.js.map +1 -0
  18. package/dist/progressive-profiling-dashboard/hooks/useProgressiveProfilingForm.js +58 -0
  19. package/dist/progressive-profiling-dashboard/hooks/useProgressiveProfilingForm.js.map +1 -0
  20. package/dist/progressive-profiling-dashboard/hooks/useProgressiveProfilingTrigger.js +14 -0
  21. package/dist/progressive-profiling-dashboard/hooks/useProgressiveProfilingTrigger.js.map +1 -0
  22. package/dist/progressive-profiling-dashboard/index.js +9 -0
  23. package/dist/progressive-profiling-dashboard/index.js.map +1 -0
  24. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/ProgressiveProfiling.js +157 -0
  25. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/ProgressiveProfiling.js.map +1 -0
  26. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/ProgressiveProfilingPageModal.js +62 -0
  27. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/ProgressiveProfilingPageModal.js.map +1 -0
  28. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/LargeLayout.js +101 -0
  29. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/LargeLayout.js.map +1 -0
  30. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/MediumLayout.js +125 -0
  31. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/MediumLayout.js.map +1 -0
  32. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/SmallLayout.js +106 -0
  33. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/SmallLayout.js.map +1 -0
  34. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/index.js +28 -0
  35. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/index.js.map +1 -0
  36. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/messages.js +40 -0
  37. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/messages.js.map +1 -0
  38. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/index.js +59 -0
  39. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/index.js.map +1 -0
  40. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/index.js +14 -0
  41. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/index.js.map +1 -0
  42. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/index.scss +269 -0
  43. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/messages.js +68 -0
  44. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/messages.js.map +1 -0
  45. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/service/getThirdPartyAuthContext.js +28 -0
  46. package/dist/progressive-profiling-dashboard/progressive-profiling-authn-replica/service/getThirdPartyAuthContext.js.map +1 -0
  47. package/dist/progressive-profiling-dashboard/utils/constants.js +12 -0
  48. package/dist/progressive-profiling-dashboard/utils/constants.js.map +1 -0
  49. package/dist/tracking/constants.js +2 -1
  50. package/dist/tracking/constants.js.map +1 -1
  51. package/dist/tracking/trackers/progressiveProfiling.js +47 -0
  52. package/dist/tracking/trackers/progressiveProfiling.js.map +1 -0
  53. package/dist/tracking/utils.js +15 -2
  54. package/dist/tracking/utils.js.map +1 -1
  55. package/package.json +7 -4
  56. package/src/index.jsx +4 -0
  57. package/src/progressive-profiling-dashboard/ProgressiveProfilingEntry.jsx +33 -0
  58. package/src/progressive-profiling-dashboard/ProgressiveProfilingModal.jsx +110 -0
  59. package/src/progressive-profiling-dashboard/api/service.js +32 -0
  60. package/src/progressive-profiling-dashboard/data/progressiveProfilingFields.js +32 -0
  61. package/src/progressive-profiling-dashboard/field-renderer/FieldRenderer.jsx +87 -0
  62. package/src/progressive-profiling-dashboard/field-renderer/index.jsx +1 -0
  63. package/src/progressive-profiling-dashboard/hooks/useClearProgressiveProfilingQueryParams.jsx +12 -0
  64. package/src/progressive-profiling-dashboard/hooks/useProgressiveProfilingForm.jsx +55 -0
  65. package/src/progressive-profiling-dashboard/hooks/useProgressiveProfilingTrigger.jsx +9 -0
  66. package/src/progressive-profiling-dashboard/index.jsx +3 -0
  67. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/ProgressiveProfiling.jsx +156 -0
  68. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/ProgressiveProfilingPageModal.jsx +59 -0
  69. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/LargeLayout.jsx +105 -0
  70. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/MediumLayout.jsx +95 -0
  71. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/SmallLayout.jsx +85 -0
  72. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/index.jsx +3 -0
  73. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/components/welcome-page-layout/messages.js +35 -0
  74. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/index.jsx +46 -0
  75. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/base-container/tests/BaseContainer.test.jsx +76 -0
  76. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/index.jsx +1 -0
  77. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/index.scss +269 -0
  78. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/messages.jsx +62 -0
  79. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/service/getThirdPartyAuthContext.js +24 -0
  80. package/src/progressive-profiling-dashboard/progressive-profiling-authn-replica/tests/ProgressiveProfiling.test.jsx +165 -0
  81. package/src/progressive-profiling-dashboard/utils/constants.jsx +5 -0
  82. package/src/tracking/constants.js +2 -0
  83. package/src/tracking/trackers/progressiveProfiling.js +45 -0
  84. package/src/tracking/utils.js +16 -2
@@ -0,0 +1,269 @@
1
+ @use "@openedx/paragon/styles/css/core/custom-media-breakpoints" as paragonCustomMediaBreakpoints;
2
+
3
+ .pp-page__button-width{
4
+ min-width: 6rem;
5
+ }
6
+ .pp-page__support-link {
7
+ font-size: 0.875rem;
8
+ font-weight: 400;
9
+ }
10
+ .pp-page__heading {
11
+ line-height: 1.75rem;
12
+ font-size: 1.375rem;
13
+ margin-bottom: 0.5rem;
14
+ font-weight: 700;
15
+
16
+ @media (--pgn-size-breakpoint-max-width-md) {
17
+ line-height: 1.5rem;
18
+ font-size: 1.125rem;
19
+ }
20
+ }
21
+ @media (max-width: 464px) {
22
+ .pp-page__support-link {
23
+ font-size: 0.688rem;
24
+ font-weight: normal;
25
+ line-height: 0.938rem;
26
+ }
27
+ }
28
+
29
+ .logo-small {
30
+ width: 44.67px;
31
+ margin-top: 1.25rem;
32
+ margin-left: 1.5rem;
33
+ }
34
+
35
+ .welcome-page-logo {
36
+ width: 71px;
37
+ margin-top: 2rem;
38
+ margin-left: 1.5rem;
39
+ }
40
+
41
+ .main-heading {
42
+ position: relative;
43
+ z-index: 2;
44
+ }
45
+
46
+ .small-screen-top-stripe {
47
+ height: 0.25rem;
48
+ background-image: linear-gradient(102.02deg,
49
+ var(--pgn-color-brand-700),
50
+ var(--pgn-color-brand-700) 20%,
51
+ var(--pgn-color-brand-base) 20%,
52
+ );
53
+ background-repeat: no-repeat;
54
+ }
55
+
56
+ @media (--pgn-size-breakpoint-min-width-md) and (--pgn-size-breakpoint-max-width-md) {
57
+ .medium-screen-top-stripe {
58
+ display: flex;
59
+ height: 0.5rem;
60
+ background-image: linear-gradient(102.02deg,
61
+ var(--pgn-color-brand-700),
62
+ var(--pgn-color-brand-700) 10%,
63
+ var(--pgn-color-brand-base) 10%,
64
+ var(--pgn-color-brand-base) 90%,
65
+ var(--pgn-color-primary-700) 90%,
66
+ var(--pgn-color-primary-700) 100%,
67
+ );
68
+ background-repeat: no-repeat;
69
+ }
70
+ }
71
+
72
+ @media (--pgn-size-breakpoint-min-width-lg) and (--pgn-size-breakpoint-max-width-lg) {
73
+ .medium-screen-top-stripe {
74
+ display: flex;
75
+ height: 0.5rem;
76
+ background-image: linear-gradient(102.02deg,
77
+ var(--pgn-color-brand-700) 10%,
78
+ var(--pgn-color-brand-base) 10%,
79
+ var(--pgn-color-brand-base) 65%,
80
+ var(--pgn-color-primary-700) 65%,
81
+ var(--pgn-color-primary-700) 75%,
82
+ var(--pgn-color-accent-a) 75%,
83
+ var(--pgn-color-accent-a) 75%);
84
+ background-repeat: no-repeat;
85
+ }
86
+ }
87
+
88
+ .extra-large-screen-top-stripe {
89
+ display: none;
90
+ }
91
+
92
+ @media (--pgn-size-breakpoint-min-width-xl) {
93
+ .extra-large-screen-top-stripe {
94
+ display: flex;
95
+ height: 0.5rem;
96
+ background-image: linear-gradient(102.02deg,
97
+ var(--pgn-color-brand-700) 10%,
98
+ var(--pgn-color-brand-base) 10%,
99
+ var(--pgn-color-brand-base) 45%,
100
+ var(--pgn-color-primary-700) 45%,
101
+ var(--pgn-color-primary-700) 55%,
102
+ var(--pgn-color-accent-a) 55%,
103
+ var(--pgn-color-accent-a) 75%,
104
+ var(--pgn-color-info-200) 75%,
105
+ );
106
+ background-repeat: no-repeat;
107
+ }
108
+ }
109
+
110
+ .large-screen-svg-primary {
111
+ fill: var(--pgn-color-primary-400);
112
+ overflow: hidden;
113
+ position: absolute;
114
+ }
115
+
116
+ .medium-screen-svg-primary {
117
+ fill: var(--pgn-color-primary-400);
118
+ overflow: inherit;
119
+ position: absolute;
120
+ }
121
+
122
+ [dir=rtl] {
123
+ .medium-screen-svg-primary,
124
+ .large-screen-svg-primary {
125
+ transform: scaleX(-1);
126
+ }
127
+ }
128
+
129
+ .small-yellow-line {
130
+ width: 80px;
131
+ height: 0;
132
+ border: 2px solid var(--pgn-color-accent-b);
133
+ transform: rotate(102.02deg);
134
+ }
135
+
136
+ .medium-yellow-line {
137
+ width: 120px;
138
+ height: 0;
139
+ border: 3px solid var(--pgn-color-accent-b);
140
+ transform: rotate(102.02deg);
141
+ }
142
+
143
+ .large-yellow-line {
144
+ width: 240px;
145
+ height: 0;
146
+ border: 3px solid var(--pgn-color-accent-b);
147
+ transform: rotate(102.02deg);
148
+ }
149
+ .auth-hero-left {
150
+ padding-left: 3.5rem;
151
+ padding-right: 3.5rem;
152
+ min-height: 100vh;
153
+ display: flex;
154
+ flex-direction: column;
155
+ }
156
+
157
+ .auth-hero-base-logo {
158
+ // reuse existing .logo sizes, just ensure it sits above everything
159
+ position: relative;
160
+ z-index: 2;
161
+ }
162
+
163
+ .auth-hero-content {
164
+ // distance from top stripe & logo to hero block (matches Figma visually)
165
+ margin-top: 7rem;
166
+ max-width: 560px;
167
+ }
168
+
169
+ /* enterprise logo in white card */
170
+ .auth-hero-enterprise-logo-wrapper {
171
+ background: #ffffff;
172
+ border-radius: 6px;
173
+ padding: 0.75rem 1rem;
174
+ display: inline-flex;
175
+ align-items: center;
176
+ justify-content: center;
177
+ }
178
+
179
+ .auth-hero-enterprise-logo {
180
+ max-width: 145px;
181
+ max-height: 74px;
182
+ object-fit: contain;
183
+ }
184
+
185
+ /* yellow slanted line */
186
+ .auth-hero-slash {
187
+ width: 0; // only height+border matters
188
+ height: 110px; // tune this to match logo/heading height
189
+ border-left: 6px solid #F0CC00; // Figma yellow
190
+ border-radius: 999px;
191
+ transform: skewX(-12deg); // gives that forward slash look
192
+ transform-origin: center;
193
+ }
194
+
195
+ /* heading text: "Start learning" + "with edX" */
196
+ .auth-hero-heading {
197
+ display: flex;
198
+ flex-direction: column;
199
+ }
200
+
201
+ .auth-hero-heading-line {
202
+ font-family: 'Inter', sans-serif;
203
+ font-size: 60px;
204
+ font-weight: 700;
205
+ line-height: 60px;
206
+ letter-spacing: -1.2px;
207
+ color: #FFFFFF; // for "Start learning"
208
+ }
209
+
210
+ .auth-hero-heading-line.text-accent-a {
211
+ color: #03C7E8 !important; // for "with edX"
212
+ }
213
+
214
+ /* enterprise message aligned under heading, same left edge */
215
+ .auth-hero-message {
216
+ max-width: 492px;
217
+ color: #fff;
218
+ font-family: 'Inter', sans-serif;
219
+ font-size: 22px;
220
+ font-weight: 400;
221
+ line-height: 36px;
222
+ }
223
+
224
+ .auth-hero-message p {
225
+ margin: 0;
226
+ color: inherit;
227
+ font-size: inherit;
228
+ line-height: inherit;
229
+ }
230
+
231
+ .auth-hero-message a {
232
+ color: #03c7e8;
233
+ text-decoration: underline;
234
+ }
235
+
236
+ /* simple responsive tweaks */
237
+ @media (max-width: 1199.98px) {
238
+ .auth-hero-heading-line {
239
+ font-size: 2.5rem;
240
+ }
241
+
242
+ .auth-hero-content {
243
+ margin-top: 4rem;
244
+ }
245
+ }
246
+
247
+ .layout {
248
+ display: flex;
249
+
250
+ @media (--pgn-size-breakpoint-max-width-lg) {
251
+ flex-direction: column;
252
+ justify-content: center;
253
+ align-items: center;
254
+ }
255
+
256
+ @media (--pgn-size-breakpoint-min-width-xl) {
257
+ justify-content: space-between;
258
+ }
259
+ }
260
+
261
+ .content {
262
+ @media (--pgn-size-breakpoint-min-width-xl) {
263
+ display: flex;
264
+ justify-content: center;
265
+ width: 50vw;
266
+ margin-top: 4rem;
267
+ }
268
+ }
269
+
@@ -0,0 +1,62 @@
1
+ import { defineMessages } from '@edx/frontend-platform/i18n';
2
+
3
+ const messages = defineMessages({
4
+ 'progressive.profiling.page.title': {
5
+ id: 'progressive.profiling.page.title',
6
+ defaultMessage: 'Welcome | {siteName}',
7
+ description: 'progressive profiling page title',
8
+ },
9
+ 'progressive.profiling.page.heading': {
10
+ id: 'progressive.profiling.page.heading',
11
+ defaultMessage: 'A few questions for you will help us get smarter.',
12
+ description: 'The page heading for the progressive profiling page.',
13
+ },
14
+ 'optional.fields.information.link': {
15
+ id: 'optional.fields.information.link',
16
+ defaultMessage: 'Learn more about how we use this information.',
17
+ description: 'Optional fields page information link',
18
+ },
19
+ 'optional.fields.submit.button': {
20
+ id: 'optional.fields.submit.button',
21
+ defaultMessage: 'Submit',
22
+ description: 'Submit button text',
23
+ },
24
+ 'optional.fields.skip.button': {
25
+ id: 'optional.fields.skip.button',
26
+ defaultMessage: 'Skip for now',
27
+ description: 'Skip button text',
28
+ },
29
+ 'optional.fields.next.button': {
30
+ id: 'optional.fields.next.button',
31
+ defaultMessage: 'Next',
32
+ description: 'Next button text',
33
+ },
34
+ // modal dialog box
35
+ 'continue.to.platform': {
36
+ id: 'continue.to.platform',
37
+ defaultMessage: 'Continue to {platformName}',
38
+ description: 'Button text for modal when user chooses "skip for now" option',
39
+ },
40
+ 'modal.title': {
41
+ id: 'modal.title',
42
+ defaultMessage: 'Thanks for letting us know.',
43
+ description: 'Heading for welcome page modal',
44
+ },
45
+ 'modal.description': {
46
+ id: 'modal.description',
47
+ defaultMessage: 'You can complete your profile in settings at any time if you change your mind.',
48
+ description: 'Modal body text',
49
+ },
50
+ // error message
51
+ 'welcome.page.error.heading': {
52
+ id: 'welcome.page.error.heading',
53
+ defaultMessage: 'We couldn\'t update your profile',
54
+ description: 'Error message heading',
55
+ },
56
+ 'welcome.page.error.message': {
57
+ id: 'welcome.page.error.message',
58
+ defaultMessage: 'An error occurred. You can complete your profile in settings at any time.',
59
+ description: 'Error message body',
60
+ },
61
+ });
62
+ export default messages;
@@ -0,0 +1,24 @@
1
+ import { getConfig } from '@edx/frontend-platform';
2
+ import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
3
+
4
+ export default async function getThirdPartyAuthContext(urlParams) {
5
+ const requestConfig = {
6
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
7
+ params: urlParams,
8
+ isPublic: true,
9
+ };
10
+
11
+ const { data } = await getAuthenticatedHttpClient()
12
+ .get(
13
+ `${getConfig().LMS_BASE_URL}/api/mfe_context`,
14
+ requestConfig,
15
+ )
16
+ .catch((e) => {
17
+ throw (e);
18
+ });
19
+ return {
20
+ fieldDescriptions: data.registrationFields || {},
21
+ optionalFields: data.optionalFields || {},
22
+ thirdPartyAuthContext: data.contextData || {},
23
+ };
24
+ }
@@ -0,0 +1,165 @@
1
+ import React from 'react';
2
+ import {
3
+ act, render, screen, fireEvent, waitFor,
4
+ } from '@testing-library/react';
5
+ import { IntlProvider } from '@edx/frontend-platform/i18n';
6
+
7
+ import {
8
+ trackProgressiveProfilingSkipLinkClick,
9
+ trackProgressiveProfilingSubmitClick,
10
+ } from '../../../tracking/trackers/progressiveProfiling';
11
+ import getThirdPartyAuthContext from '../service/getThirdPartyAuthContext';
12
+ import useProgressiveProfilingForm from '../../hooks/useProgressiveProfilingForm';
13
+ import ProgressiveProfilingPage from '../ProgressiveProfiling';
14
+
15
+ const mockNavigate = jest.fn();
16
+
17
+ jest.mock('react-router-dom', () => ({
18
+ useNavigate: () => mockNavigate,
19
+ }));
20
+
21
+ jest.mock('@edx/frontend-platform', () => ({
22
+ getConfig: () => ({
23
+ SITE_NAME: 'Test Site',
24
+ AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK: null,
25
+ }),
26
+ }));
27
+
28
+ jest.mock('@edx/frontend-platform/auth', () => ({
29
+ getAuthenticatedUser: () => ({ username: 'testuser', fullName: 'Test User' }),
30
+ getAuthenticatedHttpClient: () => ({}),
31
+ }));
32
+
33
+ jest.mock('../../hooks/useProgressiveProfilingForm');
34
+
35
+ jest.mock('../service/getThirdPartyAuthContext');
36
+
37
+ jest.mock('../../../tracking/trackers/progressiveProfiling', () => ({
38
+ trackProgressiveProfilingSkipLinkClick: jest.fn(),
39
+ trackProgressiveProfilingSubmitClick: jest.fn(),
40
+ trackProgressiveProfilingSupportLinkClick: jest.fn(),
41
+ trackProgressiveProfilingPageViewed: jest.fn(),
42
+ }));
43
+
44
+ // eslint-disable-next-line react/prop-types, func-names
45
+ jest.mock('../base-container', () => function ({ children }) {
46
+ return <div data-testid="base-container">{children}</div>;
47
+ });
48
+ // eslint-disable-next-line react/prop-types, func-names
49
+ jest.mock('../ProgressiveProfilingPageModal', () => function ({ isOpen }) {
50
+ return isOpen ? <div data-testid="skip-modal" /> : null;
51
+ });
52
+
53
+ const mockSubmit = jest.fn();
54
+
55
+ const defaultHookReturn = {
56
+ loadState: 'complete',
57
+ submitState: 'default',
58
+ error: null,
59
+ values: {},
60
+ fieldList: [],
61
+ onChangeHandler: jest.fn(),
62
+ submit: mockSubmit,
63
+ };
64
+
65
+ const renderPage = async () => {
66
+ let result;
67
+ await act(async () => {
68
+ result = render(
69
+ <IntlProvider locale="en">
70
+ <ProgressiveProfilingPage />
71
+ </IntlProvider>,
72
+ );
73
+ });
74
+ return result;
75
+ };
76
+
77
+ describe('ProgressiveProfilingPage', () => {
78
+ beforeEach(() => {
79
+ jest.clearAllMocks();
80
+ useProgressiveProfilingForm.mockReturnValue(defaultHookReturn);
81
+ getThirdPartyAuthContext.mockResolvedValue({});
82
+ });
83
+
84
+ it('renders the page heading', async () => {
85
+ await renderPage();
86
+ expect(screen.getByText('A few questions for you will help us get smarter.')).toBeInTheDocument();
87
+ });
88
+
89
+ it('renders the Submit and Skip buttons', async () => {
90
+ await renderPage();
91
+ expect(screen.getByText('Submit')).toBeInTheDocument();
92
+ expect(screen.getByText('Skip for now')).toBeInTheDocument();
93
+ });
94
+
95
+ it('calls getThirdPartyAuthContext on mount', async () => {
96
+ await renderPage();
97
+ expect(getThirdPartyAuthContext).toHaveBeenCalledTimes(1);
98
+ });
99
+
100
+ it('navigates to / and fires tracking on successful submit', async () => {
101
+ mockSubmit.mockResolvedValue(true);
102
+ await renderPage();
103
+
104
+ fireEvent.click(screen.getByText('Submit'));
105
+
106
+ await waitFor(() => {
107
+ expect(trackProgressiveProfilingSubmitClick).toHaveBeenCalledWith({
108
+ isGenderSelected: false,
109
+ isYearOfBirthSelected: false,
110
+ isLevelOfEducationSelected: false,
111
+ isWorkExperienceSelected: false,
112
+ });
113
+ expect(mockNavigate).toHaveBeenCalledWith('/', { replace: true });
114
+ });
115
+ });
116
+
117
+ it('does not navigate when submit fails', async () => {
118
+ mockSubmit.mockResolvedValue(false);
119
+ await renderPage();
120
+
121
+ fireEvent.click(screen.getByText('Submit'));
122
+
123
+ await waitFor(() => expect(mockSubmit).toHaveBeenCalled());
124
+ expect(mockNavigate).not.toHaveBeenCalled();
125
+ });
126
+
127
+ it('opens the skip modal when Skip is clicked', async () => {
128
+ await renderPage();
129
+ expect(screen.queryByTestId('skip-modal')).toBeNull();
130
+
131
+ fireEvent.click(screen.getByText('Skip for now'));
132
+
133
+ expect(trackProgressiveProfilingSkipLinkClick).toHaveBeenCalled();
134
+ expect(screen.getByTestId('skip-modal')).toBeInTheDocument();
135
+ });
136
+
137
+ it('shows an error alert when the hook returns an error', async () => {
138
+ useProgressiveProfilingForm.mockReturnValue({
139
+ ...defaultHookReturn,
140
+ error: new Error('Something went wrong'),
141
+ });
142
+
143
+ await renderPage();
144
+
145
+ expect(screen.getByText("We couldn't update your profile")).toBeInTheDocument();
146
+ expect(screen.getByText('An error occurred. You can complete your profile in settings at any time.')).toBeInTheDocument();
147
+ });
148
+
149
+ it('disables submit when submitState is pending', async () => {
150
+ useProgressiveProfilingForm.mockReturnValue({
151
+ ...defaultHookReturn,
152
+ submitState: 'pending',
153
+ });
154
+
155
+ const { container } = await renderPage();
156
+
157
+ // In pending state Paragon replaces the label with a spinner; query by class instead
158
+ expect(container.querySelector('.pp-page__button-width')).toBeDisabled();
159
+ });
160
+
161
+ it('does not render the support link when config is unset', async () => {
162
+ await renderPage();
163
+ expect(screen.queryByText('Learn more about how we use this information.')).toBeNull();
164
+ });
165
+ });
@@ -0,0 +1,5 @@
1
+ export const PROGRESSIVE_PROFILING_QUERY_PARAM = 'progressiveProfiling';
2
+ export const DEFAULT_STATE = 'default';
3
+ export const PENDING_STATE = 'pending';
4
+ export const COMPLETE_STATE = 'complete';
5
+ export const FAILURE_STATE = 'failure';
@@ -1,3 +1,5 @@
1
+ export const LEARNER_HOME_APP_NAME = 'learner-home';
2
+
1
3
  const learnerPortal = 'edx.ui.enterprise.lms.dashboard.learner_portal_modal';
2
4
 
3
5
  export const eventNames = {
@@ -0,0 +1,45 @@
1
+ /* eslint-disable function-paren-newline */
2
+ import { createEventTracker, createPageEventTracker } from '../utils';
3
+
4
+ export const eventNames = {
5
+ progressiveProfilingSubmitClick: 'edx.bi.welcome.page.submit.clicked',
6
+ progressiveProfilingSkipLinkClick: 'edx.bi.welcome.page.skip.link.clicked',
7
+ disablePostRegistrationRecommendations: 'edx.bi.user.recommendations.not.enabled',
8
+ progressiveProfilingSupportLinkClick: 'edx.bi.welcome.page.support.link.clicked',
9
+ loginAndRegistration: 'login_and_registration',
10
+ progressiveProfilingQuestionaireModalFormOpened: 'edx.bi.welcome.page.questionaire.modal.opened',
11
+ };
12
+
13
+ // Event link tracker for Progressive profiling skip button click
14
+ export const trackProgressiveProfilingSkipLinkClick = evenProperties => createEventTracker(
15
+ eventNames.progressiveProfilingSkipLinkClick, { ...evenProperties },
16
+ )();
17
+
18
+ // Event tracker for progressive profiling submit button click
19
+ export const trackProgressiveProfilingSubmitClick = (evenProperties) => createEventTracker(
20
+ eventNames.progressiveProfilingSubmitClick,
21
+ { ...evenProperties },
22
+ )();
23
+
24
+ // Event tracker for progressive profiling submit button click
25
+ export const trackDisablePostRegistrationRecommendations = (evenProperties) => createEventTracker(
26
+ eventNames.disablePostRegistrationRecommendations,
27
+ { ...evenProperties },
28
+ )();
29
+
30
+ // Tracks the progressive profiling page event.
31
+ export const trackProgressiveProfilingPageViewed = () => {
32
+ createPageEventTracker(eventNames.loginAndRegistration, 'welcome')();
33
+ };
34
+
35
+ // Tracks the progressive profiling support link click.
36
+ export const trackProgressiveProfilingSupportLinkClick = () => createEventTracker(
37
+ eventNames.progressiveProfilingSupportLinkClick,
38
+ {},
39
+ )();
40
+
41
+ // Tracks the progressive profiling modal opened with the questionaire form.
42
+ export const trackProgressiveProfilingQuestionaireModalFormOpened = (evenProperties) => createEventTracker(
43
+ eventNames.progressiveProfilingQuestionaireModalFormOpened,
44
+ { ...evenProperties },
45
+ )();
@@ -1,6 +1,7 @@
1
1
  import { getConfig } from '@edx/frontend-platform';
2
2
  import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
3
- import { sendTrackEvent } from '@edx/frontend-platform/analytics';
3
+ import { sendTrackEvent, sendPageEvent } from '@edx/frontend-platform/analytics';
4
+ import { LEARNER_HOME_APP_NAME } from './constants';
4
5
 
5
6
  const LINK_TIMEOUT = 300;
6
7
 
@@ -16,7 +17,20 @@ export const logEvent = ({ eventName, data, courseId }) => getAuthenticatedHttpC
16
17
 
17
18
  export const createEventTracker = (name, options = {}) => () => sendTrackEvent(
18
19
  name,
19
- { ...options, app_name: 'learner-home' },
20
+ { ...options, app_name: LEARNER_HOME_APP_NAME },
21
+ );
22
+
23
+ /**
24
+ * Creates an event tracker function that sends a tracking event with the given name and options.
25
+ *
26
+ * @param {string} name - The name of the event to be tracked.
27
+ * @param {object} [options={}] - Additional options to be included with the event.
28
+ * @returns {function} - A function that, when called, sends the tracking event.
29
+ */
30
+ export const createPageEventTracker = (name, options = null) => () => sendPageEvent(
31
+ name,
32
+ options,
33
+ { app_name: LEARNER_HOME_APP_NAME },
20
34
  );
21
35
 
22
36
  export const createLinkTracker = (tracker, href) => (e) => {