From 317fe405536b32b7c290356ae6aea36723528881 Mon Sep 17 00:00:00 2001 From: logonoff Date: Thu, 3 Sep 2026 15:26:34 -0400 Subject: [PATCH 1/3] feat(multicontentcard): add callback passing to onExpand --- packages/module/src/MultiContentCard/MultiContentCard.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/module/src/MultiContentCard/MultiContentCard.tsx b/packages/module/src/MultiContentCard/MultiContentCard.tsx index 6a95ca8b..1f04ff23 100644 --- a/packages/module/src/MultiContentCard/MultiContentCard.tsx +++ b/packages/module/src/MultiContentCard/MultiContentCard.tsx @@ -40,6 +40,8 @@ export interface MultiContentCardProps extends Omit void; /** Indicates whether the card is expanded by default */ defaultExpanded?: boolean; /** Indicates whether the actions toggle is right aligned */ @@ -67,13 +69,15 @@ const MultiContentCard: FunctionComponent = ({ withDividers = false, isExpandable = false, defaultExpanded = true, + onExpand, ouiaId = 'MultiContentCard', ...props }: MultiContentCardProps) => { const [ isExpanded, setIsExpanded ] = useState(defaultExpanded); const classes = useStyles(); - const onExpand = () => { + const onExpandChange = () => { setIsExpanded(!isExpanded); + onExpand && onExpand(); }; const renderCards = (cards: (ReactElement | MutliContentCardProps)[], withDividers?: boolean) => ( @@ -105,7 +109,7 @@ const MultiContentCard: FunctionComponent = ({ {isExpandable && ( Date: Thu, 3 Sep 2026 15:43:28 -0400 Subject: [PATCH 2/3] add unit test --- .../MultiContentCard.test.tsx | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/module/src/MultiContentCard/MultiContentCard.test.tsx b/packages/module/src/MultiContentCard/MultiContentCard.test.tsx index 7648b8ee..e368bfc0 100644 --- a/packages/module/src/MultiContentCard/MultiContentCard.test.tsx +++ b/packages/module/src/MultiContentCard/MultiContentCard.test.tsx @@ -1,5 +1,5 @@ import type { Ref } from 'react'; -import { screen, render } from '@testing-library/react'; +import { screen, render, act } from '@testing-library/react'; import { Button, Card, CardHeader, CardBody, Content, ContentVariants, Icon, List, ListItem, CardFooter, Dropdown, MenuToggle, DropdownList, DropdownItem, MenuToggleElement } from '@patternfly/react-core'; import { ArrowRightIcon, BellIcon, CogIcon, EllipsisVIcon, LockIcon } from '@patternfly/react-icons'; import MultiContentCard, { MultiContentCardDividerVariant } from './MultiContentCard'; @@ -126,6 +126,29 @@ describe('MultiContentCard component', () => { expect(container.firstChild).toMatchSnapshot(); }); + it('should call onExpand when expanding the multi-content card', () => { + const onExpand = jest.fn(); + + render( + + ); + expect(screen.queryByText('Getting Started')).toBe(null); + + act(() => { + screen.getByRole('button', { name: 'Details' }).click(); + }); + + expect(onExpand).toHaveBeenCalled(); + + expect(screen.getByText('Getting Started')).toBeInTheDocument(); + }); + it('should render expandable multi-content card - with actions', () => { const { container } = render( Date: Thu, 3 Sep 2026 15:51:12 -0400 Subject: [PATCH 3/3] Update MultiContentCard.test.tsx.snap --- .../MultiContentCard.test.tsx.snap | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/packages/module/src/MultiContentCard/__snapshots__/MultiContentCard.test.tsx.snap b/packages/module/src/MultiContentCard/__snapshots__/MultiContentCard.test.tsx.snap index de8aed77..56932f35 100644 --- a/packages/module/src/MultiContentCard/__snapshots__/MultiContentCard.test.tsx.snap +++ b/packages/module/src/MultiContentCard/__snapshots__/MultiContentCard.test.tsx.snap @@ -1033,7 +1033,7 @@ exports[`MultiContentCard component should render expandable multi-content card aria-expanded="false" aria-label="Details" class="pf-v6-c-button pf-m-plain" - data-ouia-component-id="OUIA-Generated-Button-plain-:r1h:" + data-ouia-component-id="OUIA-Generated-Button-plain-:r28:" data-ouia-component-type="PF6/Button" data-ouia-safe="true" type="button" @@ -1068,7 +1068,7 @@ exports[`MultiContentCard component should render expandable multi-content card aria-expanded="true" aria-label="kebab dropdown toggle" class="pf-v6-c-menu-toggle pf-m-expanded pf-m-plain" - data-ouia-component-id="OUIA-Generated-MenuToggle-plain-:r1l:" + data-ouia-component-id="OUIA-Generated-MenuToggle-plain-:r2c:" data-ouia-component-type="PF6/MenuToggle" data-ouia-safe="true" type="button" @@ -1139,7 +1139,7 @@ exports[`MultiContentCard component should render multi-content card with a sing >