From 47b43040cfdb20ec90b19685150a6eded9121891 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 5 Oct 2023 09:07:31 -0400 Subject: [PATCH 1/2] fix: ensure budget_id query param is passed to analytics api for lcm detail --- .../BudgetDetailActivityTabContents.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/learner-credit-management/BudgetDetailActivityTabContents.jsx b/src/components/learner-credit-management/BudgetDetailActivityTabContents.jsx index ce5b1c0c0a..a593012a63 100644 --- a/src/components/learner-credit-management/BudgetDetailActivityTabContents.jsx +++ b/src/components/learner-credit-management/BudgetDetailActivityTabContents.jsx @@ -4,7 +4,7 @@ import { connect } from 'react-redux'; import { useParams } from 'react-router-dom'; import LearnerCreditAllocationTable from './LearnerCreditAllocationTable'; -import { useOfferRedemptions } from './data'; +import { useOfferRedemptions, isUUID } from './data'; const BudgetDetailActivityTabContents = ({ enterpriseUUID, @@ -12,11 +12,13 @@ const BudgetDetailActivityTabContents = ({ enableLearnerPortal, }) => { const { budgetId } = useParams(); + const enterpriseOfferId = isUUID(budgetId) ? null : budgetId; + const subsidyAccessPolicyId = isUUID(budgetId) ? budgetId : null; const { isLoading: isLoadingOfferRedemptions, offerRedemptions, fetchOfferRedemptions, - } = useOfferRedemptions(enterpriseUUID, budgetId); + } = useOfferRedemptions(enterpriseUUID, enterpriseOfferId, subsidyAccessPolicyId); return ( Date: Thu, 5 Oct 2023 09:46:45 -0400 Subject: [PATCH 2/2] chore: update tests --- .../tests/BudgetDetailPage.test.jsx | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/components/learner-credit-management/tests/BudgetDetailPage.test.jsx b/src/components/learner-credit-management/tests/BudgetDetailPage.test.jsx index f09b42afb2..b3a85b84bb 100644 --- a/src/components/learner-credit-management/tests/BudgetDetailPage.test.jsx +++ b/src/components/learner-credit-management/tests/BudgetDetailPage.test.jsx @@ -45,12 +45,12 @@ useOfferRedemptions.mockReturnValue({ const mockStore = configureMockStore([thunk]); const getMockStore = store => mockStore(store); -const enterpriseId = 'test-enterprise'; +const enterpriseSlug = 'test-enterprise'; const enterpriseUUID = '1234'; const initialStoreState = { portalConfiguration: { - enterpriseId, - enterpriseSlug: enterpriseId, + enterpriseId: enterpriseUUID, + enterpriseSlug, enableLearnerPortal: true, enterpriseFeatures: { topDownAssignmentRealTimeLcm: true, @@ -59,6 +59,7 @@ const initialStoreState = { }; const mockEnterpriseOfferId = '123'; +const mockSubsidyAccessPolicyUUID = 'c17de32e-b80b-468f-b994-85e68fd32751'; const mockOfferDisplayName = 'Test Enterprise Offer'; const mockOfferSummary = { @@ -102,13 +103,29 @@ describe('', () => { }); }); - it('displays spend table in "Activity" tab with empty results', async () => { + it.each([ + { + budgetId: mockEnterpriseOfferId, + expectedUseOfferRedemptionsArgs: [enterpriseUUID, mockEnterpriseOfferId, null], + }, + { + budgetId: mockSubsidyAccessPolicyUUID, + expectedUseOfferRedemptionsArgs: [enterpriseUUID, null, mockSubsidyAccessPolicyUUID], + }, + ])('displays spend table in "Activity" tab with empty results (%s)', async ({ + budgetId, + expectedUseOfferRedemptionsArgs, + }) => { const mockOffer = { - id: mockEnterpriseOfferId, + id: budgetId, name: mockOfferDisplayName, start: '2022-01-01', end: '2023-01-01', }; + useParams.mockReturnValue({ + budgetId, + activeTabKey: 'activity', + }); useOfferSummary.mockReturnValue({ isLoading: false, offerSummary: mockOfferSummary, @@ -125,10 +142,14 @@ describe('', () => { renderWithRouter( , ); + + expect(useOfferRedemptions).toHaveBeenCalledTimes(1); + expect(useOfferRedemptions).toHaveBeenCalledWith(...expectedUseOfferRedemptionsArgs); + // Hero expect(screen.getByText('Learner Credit Management')); // Breadcrumb @@ -149,7 +170,7 @@ describe('', () => { renderWithRouter( , ); // Catalog tab exists and is active @@ -169,7 +190,7 @@ describe('', () => { , ); // Catalog tab does NOT exist @@ -184,7 +205,7 @@ describe('', () => { renderWithRouter( , ); // Activity tab exists and is active @@ -199,7 +220,7 @@ describe('', () => { renderWithRouter( , ); expect(screen.getByText('404')).toBeInTheDocument(); @@ -210,7 +231,7 @@ describe('', () => { renderWithRouter( , ); const catalogTab = screen.getByText('Catalog'); @@ -228,7 +249,7 @@ describe('', () => { renderWithRouter(