From d60cb53e002cb957f290c77991927da722a3b913 Mon Sep 17 00:00:00 2001 From: Peter Kulko Date: Thu, 14 Nov 2024 21:19:10 +0200 Subject: [PATCH 1/2] fix: added LMS_BASE_URL for brand logo --- src/containers/LearnerDashboardHeader/BrandLogo.jsx | 6 ++++-- src/containers/LearnerDashboardHeader/BrandLogo.test.jsx | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/containers/LearnerDashboardHeader/BrandLogo.jsx b/src/containers/LearnerDashboardHeader/BrandLogo.jsx index d9a79afe..063878c4 100644 --- a/src/containers/LearnerDashboardHeader/BrandLogo.jsx +++ b/src/containers/LearnerDashboardHeader/BrandLogo.jsx @@ -1,7 +1,8 @@ -import React from 'react'; +import { useContext } from 'react'; import { useIntl } from '@edx/frontend-platform/i18n'; +import { AppContext } from '@edx/frontend-platform/react'; import { reduxHooks } from 'hooks'; import { getConfig } from '@edx/frontend-platform'; @@ -10,9 +11,10 @@ import messages from './messages'; export const BrandLogo = () => { const { formatMessage } = useIntl(); const dashboard = reduxHooks.useEnterpriseDashboardData(); + const { config } = useContext(AppContext); return ( - + ({ }, })); +jest.mock('@edx/frontend-platform/react', () => ({ + AppContext: { + config: { + LMS_BASE_URL: '/', + }, + }, +})); + describe('BrandLogo', () => { test('dashboard defined', () => { reduxHooks.useEnterpriseDashboardData.mockReturnValueOnce({ From 56faac225faddb707db311f1d1d4d8d43b015f56 Mon Sep 17 00:00:00 2001 From: Peter Kulko Date: Mon, 18 Nov 2024 18:00:01 +0200 Subject: [PATCH 2/2] refactor: after review --- src/containers/LearnerDashboardHeader/BrandLogo.jsx | 6 +----- .../LearnerDashboardHeader/BrandLogo.test.jsx | 13 +++---------- .../__snapshots__/BrandLogo.test.jsx.snap | 2 +- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/containers/LearnerDashboardHeader/BrandLogo.jsx b/src/containers/LearnerDashboardHeader/BrandLogo.jsx index 063878c4..72d8e1ee 100644 --- a/src/containers/LearnerDashboardHeader/BrandLogo.jsx +++ b/src/containers/LearnerDashboardHeader/BrandLogo.jsx @@ -1,8 +1,5 @@ -import { useContext } from 'react'; - import { useIntl } from '@edx/frontend-platform/i18n'; -import { AppContext } from '@edx/frontend-platform/react'; import { reduxHooks } from 'hooks'; import { getConfig } from '@edx/frontend-platform'; @@ -11,10 +8,9 @@ import messages from './messages'; export const BrandLogo = () => { const { formatMessage } = useIntl(); const dashboard = reduxHooks.useEnterpriseDashboardData(); - const { config } = useContext(AppContext); return ( - + ({ @@ -9,14 +10,6 @@ jest.mock('hooks', () => ({ }, })); -jest.mock('@edx/frontend-platform/react', () => ({ - AppContext: { - config: { - LMS_BASE_URL: '/', - }, - }, -})); - describe('BrandLogo', () => { test('dashboard defined', () => { reduxHooks.useEnterpriseDashboardData.mockReturnValueOnce({ @@ -31,6 +24,6 @@ describe('BrandLogo', () => { reduxHooks.useEnterpriseDashboardData.mockReturnValueOnce(null); const wrapper = shallow(); expect(wrapper.snapshot).toMatchSnapshot(); - expect(wrapper.instance.findByType('a')[0].props.href).toEqual('/'); + expect(wrapper.instance.findByType('a')[0].props.href).toEqual(getConfig().LMS_BASE_URL); }); }); diff --git a/src/containers/LearnerDashboardHeader/__snapshots__/BrandLogo.test.jsx.snap b/src/containers/LearnerDashboardHeader/__snapshots__/BrandLogo.test.jsx.snap index f069b0a0..6fe98c38 100644 --- a/src/containers/LearnerDashboardHeader/__snapshots__/BrandLogo.test.jsx.snap +++ b/src/containers/LearnerDashboardHeader/__snapshots__/BrandLogo.test.jsx.snap @@ -16,7 +16,7 @@ exports[`BrandLogo dashboard defined 1`] = ` exports[`BrandLogo dashboard undefined 1`] = `