diff --git a/src/components/academies/GoToAcademy.jsx b/src/components/academies/GoToAcademy.jsx index 58337c65eb..dddbfa084c 100644 --- a/src/components/academies/GoToAcademy.jsx +++ b/src/components/academies/GoToAcademy.jsx @@ -14,7 +14,7 @@ const GoToAcademy = () => {

diff --git a/src/components/dashboard/sidebar/SubsidiesSummary.jsx b/src/components/dashboard/sidebar/SubsidiesSummary.jsx index 04c214cef8..a9a0c9d77f 100644 --- a/src/components/dashboard/sidebar/SubsidiesSummary.jsx +++ b/src/components/dashboard/sidebar/SubsidiesSummary.jsx @@ -10,6 +10,7 @@ import SubscriptionSummaryCard from './SubscriptionSummaryCard'; import LearnerCreditSummaryCard from './LearnerCreditSummaryCard'; import SidebarCard from './SidebarCard'; import { + useAcademies, useBrowseAndRequest, useCouponCodes, useEnterpriseCourseEnrollments, @@ -48,7 +49,7 @@ const SubsidiesSummary = ({ const { isPlanApproachingExpiry } = useExpirationMetadata( learnerCreditSummaryCardData?.expirationDate, ); - + const { data: academies } = useAcademies(); const learnerCreditStatusMetadata = getStatusMetadata({ isPlanApproachingExpiry, endDateStr: learnerCreditSummaryCardData?.expirationDate, @@ -71,19 +72,33 @@ const SubsidiesSummary = ({ return null; } + const isOneAcademy = enterpriseCustomer?.enableOneAcademy; const searchCoursesCta = ( !programProgressPage && !enterpriseCustomer.disableSearch && showSearchCoursesCta && ( ) ); diff --git a/src/components/dashboard/sidebar/tests/DashboardSidebar.test.jsx b/src/components/dashboard/sidebar/tests/DashboardSidebar.test.jsx index 5e14fad158..aa4d6f9759 100644 --- a/src/components/dashboard/sidebar/tests/DashboardSidebar.test.jsx +++ b/src/components/dashboard/sidebar/tests/DashboardSidebar.test.jsx @@ -31,9 +31,10 @@ import { useRedeemablePolicies, useSubscriptions, useHasAvailableSubsidiesOrRequests, + useAcademies, } from '../../../app/data'; import { SUBSIDY_REQUEST_STATE } from '../../../../constants'; -import { enterpriseCustomerFactory } from '../../../app/data/services/data/__factories__'; +import { enterpriseCustomerFactory, academiesFactory } from '../../../app/data/services/data/__factories__'; jest.mock('@edx/frontend-platform/config', () => ({ ...jest.requireActual('@edx/frontend-platform/config'), @@ -53,6 +54,7 @@ jest.mock('../../../app/data', () => ({ useBrowseAndRequest: jest.fn(), useIsAssignmentsOnlyLearner: jest.fn(), useHasAvailableSubsidiesOrRequests: jest.fn(), + useAcademies: jest.fn(), })); const mockEnterpriseOffer = { @@ -132,6 +134,7 @@ describe('', () => { useHasAvailableSubsidiesOrRequests.mockReturnValue( useMockHasAvailableSubsidyOrRequests(mockUseActiveSubsidyOrRequestsData), ); + useAcademies.mockReturnValue({ data: academiesFactory(3) }); }); test('Coupon codes summary card is displayed when coupon codes are available', () => { @@ -345,6 +348,37 @@ describe('', () => { renderWithRouter(); expect(screen.getByText(LEARNER_CREDIT_ASSIGNMENT_ONLY_SUMMARY)).toBeInTheDocument(); }); + test('Learner credit summary card with go to academy cta when we have one academy', () => { + const policyExpirationDate = '2030-01-01 12:00:00Z'; + useIsAssignmentsOnlyLearner.mockReturnValue(false); + useRedeemablePolicies.mockReturnValue({ + data: { + redeemablePolicies: [{ + uuid: 'policy-uuid', + subsidyExpirationDate: policyExpirationDate, + active: true, + policyType: POLICY_TYPES.ASSIGNED_CREDIT, + learnerContentAssignments: [ + { state: ASSIGNMENT_TYPES.ALLOCATED }, + ], + }], + learnerContentAssignments: { + ...emptyRedeemableLearnerCreditPolicies.learnerContentAssignments, + allocatedAssignments: [{ state: ASSIGNMENT_TYPES.ALLOCATED }], + hasAllocatedAssignments: true, + assignmentsForDisplay: [{ state: ASSIGNMENT_TYPES.ALLOCATED }], + hasAssignmentsForDisplay: true, + }, + }, + }); + useHasAvailableSubsidiesOrRequests.mockReturnValue(useMockHasAvailableSubsidyOrRequests({ + mockHasAvailableLearnerCreditPolicies: true, + mockLearnerCreditSummaryCardData: { expirationDate: dayjs().add(70, 'days').toISOString() }, + })); + useEnterpriseCustomer.mockReturnValue({ data: enterpriseCustomerFactory({ enable_one_academy: true }) }); + renderWithRouter(); + expect(screen.getByText('Go to Academy')).toBeInTheDocument(); + }); test('Find a course button is not rendered when user has no coupon codes or license subsidy', () => { useHasAvailableSubsidiesOrRequests.mockReturnValue( diff --git a/src/components/program-progress/tests/ProgramProgressPage.test.jsx b/src/components/program-progress/tests/ProgramProgressPage.test.jsx index d469486be7..13448a132c 100644 --- a/src/components/program-progress/tests/ProgramProgressPage.test.jsx +++ b/src/components/program-progress/tests/ProgramProgressPage.test.jsx @@ -4,7 +4,7 @@ import { renderWithRouter } from '@edx/frontend-enterprise-utils'; import { screen } from '@testing-library/react'; import React from 'react'; import { ProgramProgressPage } from '../index'; -import { authenticatedUserFactory, enterpriseCustomerFactory } from '../../app/data/services/data/__factories__'; +import { authenticatedUserFactory, enterpriseCustomerFactory, academiesFactory } from '../../app/data/services/data/__factories__'; import { useBrowseAndRequest, useCouponCodes, @@ -16,6 +16,7 @@ import { useRedeemablePolicies, useSubscriptions, useHasAvailableSubsidiesOrRequests, + useAcademies, } from '../../app/data'; jest.mock('../../app/data', () => ({ @@ -30,6 +31,7 @@ jest.mock('../../app/data', () => ({ useBrowseAndRequest: jest.fn(), useIsAssignmentsOnlyLearner: jest.fn(), useHasAvailableSubsidiesOrRequests: jest.fn(), + useAcademies: jest.fn(), })); jest.mock('@edx/frontend-platform/react', () => ({ @@ -159,6 +161,7 @@ describe('', () => { }, }); useIsAssignmentsOnlyLearner.mockReturnValue(false); + useAcademies.mockReturnValue({ data: academiesFactory(3) }); }); it('renders error page', () => { useLearnerProgramProgressData.mockReturnValue({