Skip to content

Commit be72e36

Browse files
authored
feat: allow runtime configuration (#955)
Allows frontend-app-learning to be configured at runtime using the LMS's new MFE Configuration API. Part of openedx/wg-frontend#103
1 parent fa5cf8f commit be72e36

File tree

14 files changed

+612
-135
lines changed

14 files changed

+612
-135
lines changed

package-lock.json

Lines changed: 574 additions & 108 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
},
3131
"dependencies": {
3232
"@edx/brand": "npm:@edx/brand-openedx@1.1.0",
33-
"@edx/frontend-component-footer": "10.2.4",
34-
"@edx/frontend-component-header": "2.4.6",
35-
"@edx/frontend-lib-special-exams": "1.16.3",
36-
"@edx/frontend-platform": "1.15.6",
33+
"@edx/frontend-component-footer": "11.1.0",
34+
"@edx/frontend-component-header": "3.1.0",
35+
"@edx/frontend-lib-special-exams": "2.0.0",
36+
"@edx/frontend-platform": "2.5.1",
3737
"@edx/paragon": "19.18.3",
3838
"@fortawesome/fontawesome-svg-core": "1.3.0",
3939
"@fortawesome/free-brands-svg-icons": "5.15.4",

src/alerts/active-enteprise-alert/ActiveEnterpriseAlert.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('ActiveEnterpriseAlert', () => {
1919
it('Shows alert message and links', () => {
2020
render(<ActiveEnterpriseAlert {...mockData} />);
2121
expect(screen.getByRole('alert')).toBeInTheDocument();
22-
expect(screen.getByText('test message')).toBeInTheDocument();
22+
expect(screen.getByText('test message', { exact: false })).toBeInTheDocument();
2323
expect(screen.getByRole('link', { name: 'change enterprise now' })).toHaveAttribute(
2424
'href', `${getConfig().LMS_BASE_URL}/enterprise/select/active/?success_url=http%3A%2F%2Flocalhost%2Fcourse%2Ftest-course-id%2Fhome`,
2525
);

src/alerts/course-start-alert/CourseStartAlert.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33
import {
44
FormattedDate,
55
FormattedMessage,
6-
FormattedRelative,
6+
FormattedRelativeTime,
77
FormattedTime,
88
} from '@edx/frontend-platform/i18n';
99
import { Alert } from '@edx/paragon';
@@ -26,7 +26,7 @@ function CourseStartAlert({ payload }) {
2626
const timezoneFormatArgs = userTimezone ? { timeZone: userTimezone } : {};
2727

2828
const timeRemaining = (
29-
<FormattedRelative
29+
<FormattedRelativeTime
3030
key="timeRemaining"
3131
value={startDate}
3232
{...timezoneFormatArgs}

src/course-home/outline-tab/OutlineTab.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ describe('Outline Tab', () => {
577577
const instructorToolbar = await screen.getByTestId('instructor-toolbar');
578578
expect(instructorToolbar).toBeInTheDocument();
579579
expect(screen.getByText('This learner no longer has access to this course. Their access expired on', { exact: false })).toBeInTheDocument();
580-
expect(screen.getByText('1/1/2020')).toBeInTheDocument();
580+
expect(screen.getByText('1/1/2020', { exact: false })).toBeInTheDocument();
581581
});
582582

583583
it('does not render banner when not masquerading', async () => {

src/course-home/outline-tab/alerts/course-end-alert/CourseEndAlert.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33
import {
44
FormattedDate,
55
FormattedMessage,
6-
FormattedRelative,
6+
FormattedRelativeTime,
77
FormattedTime,
88
} from '@edx/frontend-platform/i18n';
99
import { Alert } from '@edx/paragon';
@@ -21,7 +21,7 @@ function CourseEndAlert({ payload }) {
2121
const timezoneFormatArgs = userTimezone ? { timeZone: userTimezone } : {};
2222

2323
const timeRemaining = (
24-
<FormattedRelative
24+
<FormattedRelativeTime
2525
key="timeRemaining"
2626
value={endDate}
2727
{...timezoneFormatArgs}

src/course-home/progress-tab/ProgressTab.test.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,7 @@ describe('Progress Tab', () => {
12371237
month: 'long',
12381238
day: 'numeric',
12391239
}),
1240+
{ exact: false },
12401241
)).toBeInTheDocument();
12411242
});
12421243
});
@@ -1302,7 +1303,7 @@ describe('Progress Tab', () => {
13021303
await act(async () => render(<LoadedTabPage courseId={courseId} activeTabSlug="progress">...</LoadedTabPage>, { store }));
13031304
expect(screen.getByTestId('instructor-toolbar')).toBeInTheDocument();
13041305
expect(screen.getByText('This learner no longer has access to this course. Their access expired on', { exact: false })).toBeInTheDocument();
1305-
expect(screen.getByText('1/1/2020')).toBeInTheDocument();
1306+
expect(screen.getByText('1/1/2020', { exact: false })).toBeInTheDocument();
13061307
});
13071308
it('does not render banner when not masquerading', async () => {
13081309
setMetadata({ is_enrolled: true, original_user_is_staff: true });
@@ -1315,7 +1316,7 @@ describe('Progress Tab', () => {
13151316
await executeThunk(thunks.fetchProgressTab(courseId), store.dispatch);
13161317
await act(async () => render(<LoadedTabPage courseId={courseId} activeTabSlug="progress">...</LoadedTabPage>, { store }));
13171318
expect(screen.queryByText('This learner no longer has access to this course. Their access expired on', { exact: false })).not.toBeInTheDocument();
1318-
expect(screen.queryByText('1/1/2020')).not.toBeInTheDocument();
1319+
expect(screen.queryByText('1/1/2020', { exact: false })).not.toBeInTheDocument();
13191320
});
13201321
});
13211322

@@ -1331,7 +1332,7 @@ describe('Progress Tab', () => {
13311332
await act(async () => render(<LoadedTabPage courseId={courseId} activeTabSlug="progress">...</LoadedTabPage>, { store }));
13321333
expect(screen.getByTestId('instructor-toolbar')).toBeInTheDocument();
13331334
expect(screen.getByText('This learner does not yet have access to this course. The course starts on', { exact: false })).toBeInTheDocument();
1334-
expect(screen.getByText('1/1/2999')).toBeInTheDocument();
1335+
expect(screen.getByText('1/1/2999', { exact: false })).toBeInTheDocument();
13351336
});
13361337
it('does not render banner when not masquerading', async () => {
13371338
setMetadata({
@@ -1343,7 +1344,7 @@ describe('Progress Tab', () => {
13431344
await executeThunk(thunks.fetchProgressTab(courseId), store.dispatch);
13441345
await act(async () => render(<LoadedTabPage courseId={courseId} activeTabSlug="progress">...</LoadedTabPage>, { store }));
13451346
expect(screen.queryByText('This learner does not yet have access to this course. The course starts on', { exact: false })).not.toBeInTheDocument();
1346-
expect(screen.queryByText('1/1/2999')).not.toBeInTheDocument();
1347+
expect(screen.queryByText('1/1/2999', { exact: false })).not.toBeInTheDocument();
13471348
});
13481349
});
13491350

src/courseware/CoursewareRedirectLandingPage.test.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
2-
import { render } from '@testing-library/react';
32
import { Router } from 'react-router';
43
import { createMemoryHistory } from 'history';
4+
import { render, initializeMockApp } from '../setupTest';
55
import CoursewareRedirectLandingPage from './CoursewareRedirectLandingPage';
66

77
const redirectUrl = jest.fn();
@@ -17,6 +17,7 @@ jest.mock('react-router', () => ({
1717

1818
describe('CoursewareRedirectLandingPage', () => {
1919
beforeEach(async () => {
20+
await initializeMockApp();
2021
delete global.location;
2122
global.location = { assign: redirectUrl };
2223
});

src/courseware/course/CourseBreadcrumbs.test.jsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { screen, render } from '@testing-library/react';
33
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
44
import { getConfig } from '@edx/frontend-platform';
55
import { BrowserRouter } from 'react-router-dom';
6+
import { IntlProvider } from '@edx/frontend-platform/i18n';
67
import { useModel, useModels } from '../../generic/model-store';
78
import CourseBreadcrumbs from './CourseBreadcrumbs';
89

@@ -106,14 +107,16 @@ describe('CourseBreadcrumbs', () => {
106107
],
107108
]);
108109
render(
109-
<BrowserRouter>
110-
<CourseBreadcrumbs
111-
courseId="course-v1:edX+DemoX+Demo_Course"
112-
sectionId="block-v1:edX+DemoX+Demo_Course+type@chapter+block@interactive_demonstrations"
113-
sequenceId="block-v1:edX+DemoX+Demo_Course+type@sequential+block@basic_questions"
114-
isStaff
115-
/>
116-
</BrowserRouter>,
110+
<IntlProvider>
111+
<BrowserRouter>
112+
<CourseBreadcrumbs
113+
courseId="course-v1:edX+DemoX+Demo_Course"
114+
sectionId="block-v1:edX+DemoX+Demo_Course+type@chapter+block@interactive_demonstrations"
115+
sequenceId="block-v1:edX+DemoX+Demo_Course+type@sequential+block@basic_questions"
116+
isStaff
117+
/>
118+
</BrowserRouter>,
119+
</IntlProvider>,
117120
);
118121
it('renders course breadcrumbs as expected', async () => {
119122
expect(screen.queryAllByRole('link')).toHaveLength(1);

src/courseware/course/course-exit/CourseExit.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ describe('Course Exit Pages', () => {
411411
month: 'long',
412412
day: 'numeric',
413413
}),
414+
{ exact: false },
414415
)).toBeInTheDocument();
415416
});
416417
});

0 commit comments

Comments
 (0)