fix: force LMS url to reload when changed (#136)
This commit is contained in:
committed by
GitHub
parent
5db95b0029
commit
f92bd9c8f9
@@ -18,8 +18,8 @@ exports[`LookingForChallengeWidget snapshots default 1`] = `
|
||||
<h5>
|
||||
<Hyperlink
|
||||
className="d-flex align-items-center"
|
||||
destination="course-search-url"
|
||||
onClick={[MockFunction track.findCoursesWidgetClicked('course-search-url')]}
|
||||
destination="http://localhost:18000/course-search-url"
|
||||
onClick={[MockFunction track.findCoursesWidgetClicked('http://localhost:18000/course-search-url')]}
|
||||
variant="brand"
|
||||
>
|
||||
<format-message-function
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ArrowForward } from '@edx/paragon/icons';
|
||||
|
||||
import { reduxHooks } from 'hooks';
|
||||
import moreCoursesSVG from 'assets/more-courses-sidewidget.svg';
|
||||
import { baseAppUrl } from 'data/services/lms/urls';
|
||||
|
||||
import track from '../RecommendationsPanel/track';
|
||||
import messages from './messages';
|
||||
@@ -29,8 +30,8 @@ export const LookingForChallengeWidget = () => {
|
||||
<h5>
|
||||
<Hyperlink
|
||||
variant="brand"
|
||||
destination={courseSearchUrl}
|
||||
onClick={track.findCoursesWidgetClicked(courseSearchUrl)}
|
||||
destination={baseAppUrl(courseSearchUrl)}
|
||||
onClick={track.findCoursesWidgetClicked(baseAppUrl(courseSearchUrl))}
|
||||
className="d-flex align-items-center"
|
||||
>
|
||||
{formatMessage(messages.findCoursesButton, { arrow: arrowIcon })}
|
||||
|
||||
@@ -5,7 +5,7 @@ import LookingForChallengeWidget from '.';
|
||||
jest.mock('hooks', () => ({
|
||||
reduxHooks: {
|
||||
usePlatformSettingsData: () => ({
|
||||
courseSearchUrl: 'course-search-url',
|
||||
courseSearchUrl: 'http://localhost:18000/course-search-url',
|
||||
}),
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import { Button } from '@edx/paragon';
|
||||
import { Search } from '@edx/paragon/icons';
|
||||
import { baseAppUrl } from 'data/services/lms/urls';
|
||||
|
||||
import { reduxHooks } from 'hooks';
|
||||
import track from './track';
|
||||
@@ -38,8 +39,8 @@ export const LoadedView = ({
|
||||
variant="tertiary"
|
||||
iconBefore={Search}
|
||||
as="a"
|
||||
href={courseSearchUrl}
|
||||
onClick={track.findCoursesWidgetClicked(courseSearchUrl)}
|
||||
href={baseAppUrl(courseSearchUrl)}
|
||||
onClick={track.findCoursesWidgetClicked(baseAppUrl(courseSearchUrl))}
|
||||
>
|
||||
{formatMessage(messages.exploreCoursesButton)}
|
||||
</Button>
|
||||
|
||||
@@ -5,17 +5,20 @@ import LoadedView from './LoadedView';
|
||||
import mockData from './mockData';
|
||||
import messages from './messages';
|
||||
|
||||
jest.mock('./components/CourseCard', () => 'CourseCard');
|
||||
jest.mock('hooks', () => ({
|
||||
reduxHooks: {
|
||||
usePlatformSettingsData: () => ({
|
||||
courseSearchUrl: 'course-search-url',
|
||||
courseSearchUrl: '/course-search-url',
|
||||
}),
|
||||
},
|
||||
}));
|
||||
jest.mock('data/services/lms/urls', () => ({
|
||||
baseAppUrl: (url) => (`http://localhost:18000${url}`),
|
||||
}));
|
||||
jest.mock('./track', () => ({
|
||||
findCoursesWidgetClicked: (href) => jest.fn().mockName(`track.findCoursesWidgetClicked('${href}')`),
|
||||
}));
|
||||
jest.mock('./components/CourseCard', () => 'CourseCard');
|
||||
|
||||
describe('RecommendationsPanel LoadedView', () => {
|
||||
const props = {
|
||||
|
||||
@@ -64,9 +64,9 @@ exports[`RecommendationsPanel LoadedView snapshot with personalize recommendatio
|
||||
>
|
||||
<Button
|
||||
as="a"
|
||||
href="course-search-url"
|
||||
href="http://localhost:18000/course-search-url"
|
||||
iconBefore={[MockFunction icons.Search]}
|
||||
onClick={[MockFunction track.findCoursesWidgetClicked('course-search-url')]}
|
||||
onClick={[MockFunction track.findCoursesWidgetClicked('http://localhost:18000/course-search-url')]}
|
||||
variant="tertiary"
|
||||
>
|
||||
Explore courses
|
||||
@@ -139,9 +139,9 @@ exports[`RecommendationsPanel LoadedView snapshot without personalize recommenda
|
||||
>
|
||||
<Button
|
||||
as="a"
|
||||
href="course-search-url"
|
||||
href="http://localhost:18000/course-search-url"
|
||||
iconBefore={[MockFunction icons.Search]}
|
||||
onClick={[MockFunction track.findCoursesWidgetClicked('course-search-url')]}
|
||||
onClick={[MockFunction track.findCoursesWidgetClicked('http://localhost:18000/course-search-url')]}
|
||||
variant="tertiary"
|
||||
>
|
||||
Explore courses
|
||||
|
||||
@@ -2,10 +2,10 @@ import { StrictDict } from 'utils';
|
||||
import { get, stringifyUrl } from 'data/services/lms/utils';
|
||||
import urls from 'data/services/lms/urls';
|
||||
|
||||
export const fetchUrl = `${urls.api}/learner_recommendations/courses/`;
|
||||
export const getFetchUrl = () => (`${urls.getApiUrl()}/learner_recommendations/courses/`);
|
||||
export const apiKeys = StrictDict({ user: 'user' });
|
||||
|
||||
const fetchRecommendedCourses = () => get(stringifyUrl(fetchUrl));
|
||||
const fetchRecommendedCourses = () => get(stringifyUrl(getFetchUrl()));
|
||||
|
||||
export default {
|
||||
fetchRecommendedCourses,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { get, stringifyUrl } from 'data/services/lms/utils';
|
||||
import api, { fetchUrl } from './api';
|
||||
import api, { getFetchUrl } from './api';
|
||||
|
||||
jest.mock('data/services/lms/utils', () => ({
|
||||
stringifyUrl: (...args) => ({ stringifyUrl: args }),
|
||||
@@ -10,7 +10,7 @@ describe('recommendedCourses api', () => {
|
||||
describe('fetchRecommendedCourses', () => {
|
||||
it('calls get with the correct recommendation courses URL and user', () => {
|
||||
expect(api.fetchRecommendedCourses()).toEqual(
|
||||
get(stringifyUrl(fetchUrl)),
|
||||
get(stringifyUrl(getFetchUrl())),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user