Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ ENABLE_NOTICES=''
CAREER_LINK_URL=''
ENABLE_EDX_PERSONAL_DASHBOARD=false
ENABLE_PROGRAMS=false
NON_BROWSABLE_COURSES=false
# Fallback in local style files
PARAGON_THEME_URLS={}
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ ENABLE_NOTICES=''
CAREER_LINK_URL=''
ENABLE_EDX_PERSONAL_DASHBOARD=false
ENABLE_PROGRAMS=false
NON_BROWSABLE_COURSES=false
# Fallback in local style files
PARAGON_THEME_URLS={}
3 changes: 2 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ ENABLE_NOTICES=''
CAREER_LINK_URL=''
ENABLE_EDX_PERSONAL_DASHBOARD=true
ENABLE_PROGRAMS=false
PARAGON_THEME_URLS={}
NON_BROWSABLE_COURSES=false
PARAGON_THEME_URLS={}
1,903 changes: 1,007 additions & 896 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@redux-devtools/extension": "3.3.0",
"@reduxjs/toolkit": "^2.0.0",
"classnames": "^2.3.1",
"core-js": "3.40.0",
"core-js": "3.42.0",
"filesize": "^10.0.0",
"font-awesome": "4.7.0",
"history": "5.3.0",
Expand Down
18 changes: 6 additions & 12 deletions src/App.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,9 @@ describe('App router component', () => {
it('loads dashboard', () => {
const main = el.instance.findByType('main')[0];
expect(main.children.length).toEqual(1);
const dashboard = main.children[0];
const dashboard = main.children[0].el;
expect(dashboard.type).toEqual('Dashboard');
expect(
dashboard.matches(shallow(<Dashboard />)),
).toEqual(true);
expect(dashboard).toEqual(shallow(<Dashboard />));
});
});
describe('no network failure with optimizely url', () => {
Expand All @@ -91,11 +89,9 @@ describe('App router component', () => {
it('loads dashboard', () => {
const main = el.instance.findByType('main')[0];
expect(main.children.length).toEqual(1);
const dashboard = main.children[0];
const dashboard = main.children[0].el;
expect(dashboard.type).toEqual('Dashboard');
expect(
dashboard.matches(shallow(<Dashboard />)),
).toEqual(true);
expect(dashboard).toEqual(shallow(<Dashboard />));
});
});
describe('no network failure with optimizely project id', () => {
Expand All @@ -108,11 +104,9 @@ describe('App router component', () => {
it('loads dashboard', () => {
const main = el.instance.findByType('main')[0];
expect(main.children.length).toEqual(1);
const dashboard = main.children[0];
const dashboard = main.children[0].el;
expect(dashboard.type).toEqual('Dashboard');
expect(
dashboard.matches(shallow(<Dashboard />)),
).toEqual(true);
expect(dashboard).toEqual(shallow(<Dashboard />));
});
});
describe('initialize failure', () => {
Expand Down
1 change: 1 addition & 0 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const configuration = {
ENABLE_EDX_PERSONAL_DASHBOARD: process.env.ENABLE_EDX_PERSONAL_DASHBOARD === 'true',
SEARCH_CATALOG_URL: process.env.SEARCH_CATALOG_URL || null,
ENABLE_PROGRAMS: process.env.ENABLE_PROGRAMS === 'true',
NON_BROWSABLE_COURSES: process.env.NON_BROWSABLE_COURSES === 'true',
};

const features = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export const useAccessMessage = ({ cardId }) => {
const courseRun = reduxHooks.useCardCourseRunData(cardId);
const formatDate = utilHooks.useFormatDate();
if (!courseRun.isStarted) {
if (!courseRun.startDate) { return null; }
const startDate = formatDate(courseRun.startDate);
if (!courseRun.startDate && !courseRun.advertisedStart) { return null; }
const startDate = courseRun.advertisedStart ? courseRun.advertisedStart : formatDate(courseRun.startDate);
return formatMessage(messages.courseStarts, { startDate });
}
if (enrollment.isEnrolled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ const getLearnerHeaderMenu = (
href: `${urls.programsUrl()}`,
content: formatMessage(messages.program),
}] : []),
{
...(!getConfig().NON_BROWSABLE_COURSES ? [{
type: 'item',
href: `${urls.baseAppUrl(courseSearchUrl)}`,
content: formatMessage(messages.discoverNew),
onClick: (e) => {
exploreCoursesClick(e);
},
},
}]
: []),
],
secondaryMenu: [
...(getConfig().SUPPORT_URL ? [{
Expand Down
5 changes: 5 additions & 0 deletions src/containers/LearnerDashboardHeader/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ describe('LearnerDashboardHeader', () => {
const wrapper = shallow(<LearnerDashboardHeader />);
expect(wrapper.instance.findByType(Header)[0].props.mainMenuItems.length).toBe(3);
});
test('should not display Discover New tab if it is disabled by configuration', () => {
mergeConfig({ NON_BROWSABLE_COURSES: true });
const wrapper = shallow(<LearnerDashboardHeader />);
expect(wrapper.instance.findByType(Header)[0].props.mainMenuItems.length).toBe(2);
});
});
1 change: 1 addition & 0 deletions src/data/redux/app/selectors/courseCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const courseCard = StrictDict({
(courseRun) => (courseRun === null ? {} : {
endDate: module.loadDateVal(courseRun.endDate),
startDate: module.loadDateVal(courseRun.startDate),
advertisedStart: courseRun.advertisedStart,

courseId: courseRun.courseId,
isArchived: courseRun.isArchived,
Expand Down
4 changes: 4 additions & 0 deletions src/data/redux/app/selectors/courseCard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ describe('courseCard selectors module', () => {
loadSelector(courseCard.courseRun, {
endDate: '3000-10-20',
startDate: '2000-10-20',
advertisedStart: 'Mid June',

courseId: 'test-course-id',
isArchived: 'test-is-archived',
Expand All @@ -172,6 +173,9 @@ describe('courseCard selectors module', () => {
expect(selected.endDate).toEqual(new Date(testData.endDate));
expect(selected.startDate).toEqual(new Date(testData.startDate));
});
it('passes advertised start date', () => {
expect(selected.advertisedStart).toEqual(testData.advertisedStart);
});
it('passes [courseId, isArchived, isStarted]', () => {
expect(selected.courseId).toEqual(testData.courseId);
expect(selected.isArchived).toEqual(testData.isArchived);
Expand Down
2 changes: 1 addition & 1 deletion src/data/services/lms/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const get = (...args) => getAuthenticatedHttpClient().get(...args);
* @param {string} url - target url
* @param {object|string} body - post payload
*/
export const post = (url, body) => getAuthenticatedHttpClient().post(url, stringify(body));
export const post = (url, body = {}) => getAuthenticatedHttpClient().post(url, stringify(body));

export const client = getAuthenticatedHttpClient;

Expand Down