From ff5bdfb2f1d2980d16e2e47dcd92115efb683728 Mon Sep 17 00:00:00 2001 From: mshriver Date: Mon, 20 Jul 2026 09:40:51 -0400 Subject: [PATCH 1/2] chore(ExpandableSection): Include OUIAProps for ExpandableSection Add OUIA attribute support to ExpandableSection for better test automation. Co-authored-by: Cursor --- .../ExpandableSection/ExpandableSection.tsx | 14 +++++++-- .../__tests__/ExpandableSection.test.tsx | 30 ++++++++++++++++++- .../ExpandableSection.test.tsx.snap | 11 +++++++ packages/react-core/src/helpers/OUIA/OUIA.md | 1 + 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/packages/react-core/src/components/ExpandableSection/ExpandableSection.tsx b/packages/react-core/src/components/ExpandableSection/ExpandableSection.tsx index ed4e612982c..b045532b71d 100644 --- a/packages/react-core/src/components/ExpandableSection/ExpandableSection.tsx +++ b/packages/react-core/src/components/ExpandableSection/ExpandableSection.tsx @@ -6,7 +6,7 @@ import RhMicronsCaretDownIcon from '@patternfly/react-icons/dist/esm/icons/rh-mi import { PickOptional } from '../../helpers/typeUtils'; import { debounce } from '../../helpers/util'; import { getResizeObserver } from '../../helpers/resizeObserver'; -import { GenerateId } from '../../helpers'; +import { GenerateId, getOUIAProps, OUIAProps } from '../../helpers'; import { Button } from '../Button'; export enum ExpandableSectionVariant { @@ -16,7 +16,7 @@ export enum ExpandableSectionVariant { /** The main expandable section component. */ -export interface ExpandableSectionProps extends Omit, 'onToggle'> { +export interface ExpandableSectionProps extends Omit, 'onToggle'>, OUIAProps { /** Content rendered inside the expandable section. */ children?: React.ReactNode; /** Additional classes added to the expandable section. */ @@ -84,6 +84,10 @@ export interface ExpandableSectionProps extends Omit {variant === ExpandableSectionVariant.default && expandableToggle}
{ - const { asFragment } = render(test ); + const { asFragment } = render( + + test{' '} + + ); expect(asFragment()).toMatchSnapshot(); }); @@ -306,3 +310,27 @@ test('Renders toggle icon by default when hasToggleIcon is true', () => { const button = screen.getByRole('button'); expect(button.querySelector('.pf-v6-c-expandable-section__toggle-icon')).toBeInTheDocument(); }); + +test('Renders with custom ouiaId', () => { + const { container } = render(Test content); + expect(container.firstChild).toHaveAttribute('data-ouia-component-id', 'test-id'); +}); + +test('Renders with expected ouia component type', () => { + const { container } = render(Test content); + expect(container.firstChild).toHaveAttribute('data-ouia-component-type', 'PF6/ExpandableSection'); +}); + +test('Renders with ouiaSafe defaulting to true', () => { + const { container } = render(Test content); + expect(container.firstChild).toHaveAttribute('data-ouia-safe', 'true'); +}); + +test('Renders with ouiaSafe=false when specified', () => { + const { container } = render( + + Test content + + ); + expect(container.firstChild).toHaveAttribute('data-ouia-safe', 'false'); +}); diff --git a/packages/react-core/src/components/ExpandableSection/__tests__/__snapshots__/ExpandableSection.test.tsx.snap b/packages/react-core/src/components/ExpandableSection/__tests__/__snapshots__/ExpandableSection.test.tsx.snap index 9129caa2247..1225988eca1 100644 --- a/packages/react-core/src/components/ExpandableSection/__tests__/__snapshots__/ExpandableSection.test.tsx.snap +++ b/packages/react-core/src/components/ExpandableSection/__tests__/__snapshots__/ExpandableSection.test.tsx.snap @@ -4,6 +4,8 @@ exports[`Disclosure ExpandableSection 1`] = `
Date: Wed, 22 Jul 2026 16:12:32 -0400 Subject: [PATCH 2/2] Fix tests --- .../__snapshots__/MultipleFileUploadStatus.test.tsx.snap | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/react-core/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadStatus.test.tsx.snap b/packages/react-core/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadStatus.test.tsx.snap index 1dc68518f06..f9a9364418a 100644 --- a/packages/react-core/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadStatus.test.tsx.snap +++ b/packages/react-core/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadStatus.test.tsx.snap @@ -7,6 +7,8 @@ exports[`MultipleFileUploadStatus renders custom class names 1`] = ` >