diff --git a/src/__tests__/snapshot-tests/__snapshots__/test-utils-selectors.test.tsx.snap b/src/__tests__/snapshot-tests/__snapshots__/test-utils-selectors.test.tsx.snap index 1f5a3b96d7..5daaf28ad8 100644 --- a/src/__tests__/snapshot-tests/__snapshots__/test-utils-selectors.test.tsx.snap +++ b/src/__tests__/snapshot-tests/__snapshots__/test-utils-selectors.test.tsx.snap @@ -515,6 +515,8 @@ exports[`test-utils selectors 1`] = ` "awsui_token-editor-token-remove-actions_1heb1", ], "radio-group": [ + "awsui_radio_1mabk", + "awsui_root_1mabk", "awsui_root_1np5w", ], "s3-resource-selector": [ diff --git a/src/radio-group/internal.tsx b/src/radio-group/internal.tsx index d0011fef7a..49af598327 100644 --- a/src/radio-group/internal.tsx +++ b/src/radio-group/internal.tsx @@ -58,6 +58,7 @@ const InternalRadioGroup = React.forwardRef( className={clsx( baseProps.className, testUtilStyles.root, + styles.root, styles['radio-group'], direction === 'horizontal' && styles['horizontal-group'] )} diff --git a/src/radio-group/styles.scss b/src/radio-group/styles.scss index cdf6994923..91e76aebb4 100644 --- a/src/radio-group/styles.scss +++ b/src/radio-group/styles.scss @@ -6,6 +6,10 @@ @use '../internal/styles' as styles; @use '../internal/styles/tokens' as awsui; +.root { + /* used for backwards-compatibility with older versions of test-utils */ +} + .radio-group { @include styles.styles-reset; diff --git a/src/test-utils/dom/radio-group/index.ts b/src/test-utils/dom/radio-group/index.ts index c36c8beb99..4b9305ea71 100644 --- a/src/test-utils/dom/radio-group/index.ts +++ b/src/test-utils/dom/radio-group/index.ts @@ -6,13 +6,17 @@ import { escapeSelector } from '@cloudscape-design/test-utils-core/utils'; import RadioButtonWrapper from '../radio-button'; import radioButtonStyles from '../../../internal/components/radio-button/test-classes/styles.selectors.js'; +import legacyStyles from '../../../radio-group/styles.selectors.js'; import styles from '../../../radio-group/test-classes/styles.selectors.js'; export default class RadioGroupWrapper extends ComponentWrapper { static rootSelector: string = styles.root; + static legacyRootSelector: string = legacyStyles.root; findButtons(): Array { - return this.findAllByClassName(radioButtonStyles.root).map(r => new RadioButtonWrapper(r.getElement())); + return this.findAll(`:is(.${radioButtonStyles.root}, .${legacyStyles.radio})`).map( + r => new RadioButtonWrapper(r.getElement()) + ); } findInputByValue(value: string): ElementWrapper | null {