-
{isControl === false
- ? formatMessage(messages.recommendationsHeading) : formatMessage(messages.popularCoursesHeading)}
-
-
- {courses.map((course) => (
-
- ))}
+ <>
+
+
{isControl === false
+ ? formatMessage(messages.recommendationsHeading) : formatMessage(messages.popularCoursesHeading)}
+
+
+ {courses.map((course) => (
+
+ ))}
+
+
+
+
-
-
-
-
+
+ >
);
};
@@ -61,6 +59,8 @@ LoadedView.propTypes = {
marketingUrl: PropTypes.string,
})).isRequired,
isControl: PropTypes.oneOf([true, false, null]),
+ setIsRecommendationsModalOpen: PropTypes.func.isRequired,
+ isRecommendationsModalOpen: PropTypes.bool.isRequired,
};
export default LoadedView;
diff --git a/src/widgets/RecommendationsPanel/LoadedView.test.jsx b/src/widgets/RecommendationsPanel/LoadedView.test.jsx
index 20b7a4b..555965d 100644
--- a/src/widgets/RecommendationsPanel/LoadedView.test.jsx
+++ b/src/widgets/RecommendationsPanel/LoadedView.test.jsx
@@ -24,6 +24,8 @@ describe('RecommendationsPanel LoadedView', () => {
const props = {
courses: mockData.courses,
isControl: null,
+ setIsRecommendationsModalOpen: () => {},
+ isRecommendationsModalOpen: false,
};
describe('snapshot', () => {
test('without personalize recommendation', () => {
diff --git a/src/widgets/RecommendationsPanel/__snapshots__/LoadedView.test.jsx.snap b/src/widgets/RecommendationsPanel/__snapshots__/LoadedView.test.jsx.snap
index c04c032..6676fa5 100644
--- a/src/widgets/RecommendationsPanel/__snapshots__/LoadedView.test.jsx.snap
+++ b/src/widgets/RecommendationsPanel/__snapshots__/LoadedView.test.jsx.snap
@@ -1,151 +1,157 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`RecommendationsPanel LoadedView snapshot with personalize recommendation 1`] = `
-
-
- Recommendations for you
-
-
-
-
-
-
-
+
-
+ Recommendations for you
+
+
+
+
+
+
+
+
+
+
-
+
+
`;
exports[`RecommendationsPanel LoadedView snapshot without personalize recommendation 1`] = `
-
-
- Popular courses
-
-
-
-
-
-
-
+
-
+ Popular courses
+
+
+
+
+
+
+
+
+
+
-
+
+
`;
diff --git a/src/widgets/RecommendationsPanel/index.jsx b/src/widgets/RecommendationsPanel/index.jsx
index c091a8d..47bfb36 100644
--- a/src/widgets/RecommendationsPanel/index.jsx
+++ b/src/widgets/RecommendationsPanel/index.jsx
@@ -4,6 +4,7 @@ import LookingForChallengeWidget from 'widgets/LookingForChallengeWidget';
import LoadingView from './LoadingView';
import LoadedView from './LoadedView';
import hooks from './hooks';
+import { useRecommendationsModal } from '../../components/ModalView/hooks';
export const RecommendationsPanel = () => {
const {
@@ -14,12 +15,19 @@ export const RecommendationsPanel = () => {
isLoading,
} = hooks.useRecommendationPanelData();
+ const { isRecommendationsModalOpen, toggleRecommendationsModal } = useRecommendationsModal();
+
if (isLoading) {
return (
);
}
if (isLoaded && courses.length > 0) {
return (
-
+
);
}
if (isFailed) {
diff --git a/src/widgets/RecommendationsPanel/index.test.jsx b/src/widgets/RecommendationsPanel/index.test.jsx
index f87cd5c..e46d5e2 100644
--- a/src/widgets/RecommendationsPanel/index.test.jsx
+++ b/src/widgets/RecommendationsPanel/index.test.jsx
@@ -7,10 +7,14 @@ import mockData from './mockData';
import LoadedView from './LoadedView';
import LoadingView from './LoadingView';
import RecommendationsPanel from '.';
+import { useRecommendationsModal } from '../../components/ModalView/hooks';
jest.mock('./hooks', () => ({
useRecommendationPanelData: jest.fn(),
}));
+jest.mock('../../components/ModalView/hooks', () => ({
+ useRecommendationsModal: jest.fn(),
+}));
jest.mock('widgets/LookingForChallengeWidget', () => 'LookingForChallengeWidget');
jest.mock('./LoadingView', () => 'LoadingView');
jest.mock('./LoadedView', () => 'LoadedView');
@@ -21,6 +25,8 @@ describe('RecommendationsPanel snapshot', () => {
const defaultLoadedViewProps = {
courses: [],
isControl: false,
+ setIsRecommendationsModalOpen: jest.fn(),
+ isRecommendationsModalOpen: false,
};
const defaultValues = {
isFailed: false,
@@ -29,6 +35,10 @@ describe('RecommendationsPanel snapshot', () => {
...defaultLoadedViewProps,
};
it('displays LoadingView if request is loading', () => {
+ useRecommendationsModal.mockReturnValueOnce({
+ isRecommendationsModalOpen: false,
+ toggleRecommendationsModal: jest.fn(),
+ });
hooks.useRecommendationPanelData.mockReturnValueOnce({
...defaultValues,
isLoading: true,
@@ -36,16 +46,23 @@ describe('RecommendationsPanel snapshot', () => {
expect(shallow(
)).toMatchObject(shallow(
));
});
it('displays LoadedView with courses if request is loaded', () => {
+ useRecommendationsModal.mockReturnValueOnce({
+ isRecommendationsModalOpen: false,
+ toggleRecommendationsModal: jest.fn(),
+ });
hooks.useRecommendationPanelData.mockReturnValueOnce({
...defaultValues,
courses,
isLoaded: true,
});
- expect(shallow(
)).toMatchObject(
- shallow(
),
- );
+ expect(JSON.stringify(shallow(
)))
+ .toEqual(JSON.stringify(shallow(
)));
});
it('displays LookingForChallengeWidget if request is failed', () => {
+ useRecommendationsModal.mockReturnValueOnce({
+ isRecommendationsModalOpen: false,
+ toggleRecommendationsModal: jest.fn(),
+ });
hooks.useRecommendationPanelData.mockReturnValueOnce({
...defaultValues,
isFailed: true,
@@ -55,6 +72,10 @@ describe('RecommendationsPanel snapshot', () => {
);
});
it('defaults to LookingForChallengeWidget if no flags are true', () => {
+ useRecommendationsModal.mockReturnValueOnce({
+ isRecommendationsModalOpen: false,
+ toggleRecommendationsModal: jest.fn(),
+ });
hooks.useRecommendationPanelData.mockReturnValueOnce({
...defaultValues,
});
diff --git a/src/widgets/RecommendationsPanel/messages.js b/src/widgets/RecommendationsPanel/messages.js
index 69bedd4..6422d24 100644
--- a/src/widgets/RecommendationsPanel/messages.js
+++ b/src/widgets/RecommendationsPanel/messages.js
@@ -16,6 +16,11 @@ const messages = defineMessages({
defaultMessage: 'Explore courses',
description: 'Button to explore more courses on recommendations panel',
},
+ seeAllRecommendationsButton: {
+ id: 'RecommendationsPanel.seeAllRecommendationsButton',
+ defaultMessage: 'See All Recommendations',
+ description: 'Button to see all recommendations',
+ },
});
export default messages;