Revert "fix: display programs only if the url is configured (#479)"

This reverts commit e8886c9d9d.
This commit is contained in:
Deborah Kaplan
2024-11-18 14:37:40 -05:00
committed by GitHub
parent bc449a3c34
commit ee515ad666
9 changed files with 10 additions and 84 deletions

View File

@@ -9,7 +9,6 @@ const getLearnerHeaderMenu = (
courseSearchUrl,
authenticatedUser,
exploreCoursesClick,
programsEnabled = false,
) => ({
mainMenu: [
{
@@ -18,11 +17,11 @@ const getLearnerHeaderMenu = (
content: formatMessage(messages.course),
isActive: true,
},
...(programsEnabled ? [{
{
type: 'item',
href: `${urls.programsUrl()}`,
content: formatMessage(messages.program),
}] : []),
},
{
type: 'item',
href: `${urls.baseAppUrl(courseSearchUrl)}`,

View File

@@ -12,6 +12,11 @@ exports[`LearnerDashboardHeader render 1`] = `
"isActive": true,
"type": "item",
},
{
"content": "Programs",
"href": "http://localhost:18000/dashboard/programs",
"type": "item",
},
{
"content": "Discover New",
"href": "http://localhost:18000/course-search-url",

View File

@@ -5,7 +5,6 @@ import track from 'tracking';
import { StrictDict } from 'utils';
import { linkNames } from 'tracking/constants';
import { apiHooks } from 'hooks';
import getLearnerHeaderMenu from './LearnerDashboardMenu';
import * as module from './hooks';
@@ -31,9 +30,8 @@ export const findCoursesNavDropdownClicked = (href) => track.findCourses.findCou
export const useLearnerDashboardHeaderMenu = ({
courseSearchUrl, authenticatedUser, exploreCoursesClick,
}) => {
const { enabled: programsEnabled } = apiHooks.useProgramsConfig();
const { formatMessage } = useIntl();
return getLearnerHeaderMenu(formatMessage, courseSearchUrl, authenticatedUser, exploreCoursesClick, programsEnabled);
return getLearnerHeaderMenu(formatMessage, courseSearchUrl, authenticatedUser, exploreCoursesClick);
};
export const useLearnerDashboardHeaderData = () => {

View File

@@ -21,11 +21,6 @@ jest.mock('tracking', () => ({
findCoursesClicked: jest.fn(),
},
}));
jest.mock('hooks', () => ({
apiHooks: {
useProgramsConfig: jest.fn(() => ({})),
},
}));
const url = 'http://example.com';
@@ -61,7 +56,7 @@ describe('LearnerDashboardHeader hooks', () => {
username: 'test',
};
const learnerHomeHeaderMenu = useLearnerDashboardHeaderMenu({ courseSearchUrl, authenticatedUser });
expect(learnerHomeHeaderMenu.mainMenu.length).toBe(2);
expect(learnerHomeHeaderMenu.mainMenu.length).toBe(3);
});
});

View File

@@ -3,7 +3,6 @@ import { shallow } from '@edx/react-unit-test-utils';
import Header from '@edx/frontend-component-header';
import urls from 'data/services/lms/urls';
import { apiHooks } from 'hooks';
import LearnerDashboardHeader from '.';
import { findCoursesNavClicked } from './hooks';
@@ -13,9 +12,6 @@ jest.mock('hooks', () => ({
courseSearchUrl: '/course-search-url',
})),
},
apiHooks: {
useProgramsConfig: jest.fn(() => ({})),
},
}));
jest.mock('./hooks', () => ({
...jest.requireActual('./hooks'),
@@ -33,7 +29,7 @@ describe('LearnerDashboardHeader', () => {
expect(wrapper.instance.findByType('ConfirmEmailBanner')).toHaveLength(1);
expect(wrapper.instance.findByType('MasqueradeBar')).toHaveLength(1);
expect(wrapper.instance.findByType(Header)).toHaveLength(1);
wrapper.instance.findByType(Header)[0].props.mainMenuItems[1].onClick();
wrapper.instance.findByType(Header)[0].props.mainMenuItems[2].onClick();
expect(findCoursesNavClicked).toHaveBeenCalledWith(urls.baseAppUrl('/course-search-url'));
expect(wrapper.instance.findByType(Header)[0].props.secondaryMenuItems.length).toBe(0);
});
@@ -42,11 +38,5 @@ describe('LearnerDashboardHeader', () => {
mergeConfig({ SUPPORT_URL: 'http://localhost:18000/support' });
const wrapper = shallow(<LearnerDashboardHeader />);
expect(wrapper.instance.findByType(Header)[0].props.secondaryMenuItems.length).toBe(1);
expect(wrapper.instance.findByType(Header)[0].props.mainMenuItems.length).toBe(2);
});
test('should display Programs link if the service is configured in the backend', () => {
apiHooks.useProgramsConfig.mockReturnValue({ enabled: true });
const wrapper = shallow(<LearnerDashboardHeader />);
expect(wrapper.instance.findByType(Header)[0].props.mainMenuItems.length).toBe(3);
});
});