Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ exports[`test-utils selectors 1`] = `
"awsui_token-editor-token-remove-actions_1heb1",
],
"radio-group": [
"awsui_radio_1mabk",
"awsui_root_1mabk",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"awsui_root_1np5w",
],
"s3-resource-selector": [
Expand Down
1 change: 1 addition & 0 deletions src/radio-group/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const InternalRadioGroup = React.forwardRef(
className={clsx(
baseProps.className,
testUtilStyles.root,
styles.root,
styles['radio-group'],
direction === 'horizontal' && styles['horizontal-group']
)}
Expand Down
4 changes: 4 additions & 0 deletions src/radio-group/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion src/test-utils/dom/radio-group/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<RadioButtonWrapper> {
return this.findAllByClassName(radioButtonStyles.root).map(r => new RadioButtonWrapper(r.getElement()));
return this.findAll(`:is(.${radioButtonStyles.root}, .${legacyStyles.radio})`).map(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For finding the radio group with the old test utils, adding the static legacyRootSelector statement above is enough (related: cloudscape-design/test-utils#100), but in order to find the radio buttons inside the radio group, it is necessary to manually construct the selector here.

r => new RadioButtonWrapper(r.getElement())
);
}

findInputByValue(value: string): ElementWrapper<HTMLInputElement> | null {
Expand Down
Loading