Skip to content

Commit

Permalink
feat: add display name in heading of catalog tab (#1074)
Browse files Browse the repository at this point in the history
* feat: display search result cards in catalog tab

* fix: failing test in BudgetDetailPage

* fix: replace word register with enroll

* fix: implemented reviewer comments

* fix: lint error

* fix: lint error

* feat: added policy's catalog uuid to search filter

* feat: implement view course button to learn more

* fix: failing test

* fix: added test

* fix: added test coverage

* fix: refactored based on reviewer feedback

* fix: lint error

* fix: refactored code to include new api field and updated test

* fix: removing unused prop in test

* fix: refactored

* fix: search filters

* chore: rebase

* feat: add display name

* chore: refactored

* chore: fix lint error

* chore: refactored

* fix: refactored and updated test
  • Loading branch information
katrinan029 authored Oct 31, 2023
1 parent 5d2a736 commit ff9bba7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ const CatalogSearch = () => {
data: subsidyAccessPolicy,
} = useSubsidyAccessPolicy(subsidyAccessPolicyId);
const searchFilters = `enterprise_catalog_uuids:${subsidyAccessPolicy.catalogUuid} AND content_type:course`;
const displayName = subsidyAccessPolicy.displayName ? `${subsidyAccessPolicy.displayName} catalog` : 'Overview';

return (
<section>
<FormattedMessage
id="catalogs.enterpriseCatalogs.header"
defaultMessage="Budget associated catalog"
defaultMessage={displayName}
description="Search dialogue."
tagName="h3"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,23 +502,27 @@ describe('<BudgetDetailPage />', () => {
expect(modalPopupContents.getByText(expectedModalPopupContent, { exact: false })).toBeInTheDocument();
});

it('renders with catalog tab active on initial load for assignable budgets', async () => {
it.each([
{ displayName: null },
{ displayName: 'Test Budget Display Name' },
])('renders with catalog tab active on initial load for assignable budgets with %s display name', ({ displayName }) => {
useParams.mockReturnValue({
budgetId: mockSubsidyAccessPolicyUUID,
activeTabKey: 'catalog',
});
useSubsidyAccessPolicy.mockReturnValue({
isInitialLoading: false,
data: mockAssignableSubsidyAccessPolicy,
data: { ...mockAssignableSubsidyAccessPolicy, displayName },
});
useBudgetDetailActivityOverview.mockReturnValueOnce({
isLoading: false,
data: mockEmptyStateBudgetDetailActivityOverview,
});
renderWithRouter(<BudgetDetailPageWrapper />);

const expectedDisplayName = displayName ? `${displayName} catalog` : 'Overview';
// Catalog tab exists and is active
expect(screen.getByText('Catalog').getAttribute('aria-selected')).toBe('true');
expect(screen.getByText(expectedDisplayName, { selector: 'h3' }));
});

it('hides catalog tab when budget is not assignable', () => {
Expand Down

0 comments on commit ff9bba7

Please sign in to comment.