From 6a71fa7effaaa605052507cac0bc0231db52d645 Mon Sep 17 00:00:00 2001 From: "jennifer.mullen" Date: Tue, 7 Jan 2025 14:06:45 -0800 Subject: [PATCH 1/3] feat: aadd test IDs, round 1 --- .../sage-react/lib/Accordion/Accordion.jsx | 5 +++- .../lib/Accordion/Accordion.story.jsx | 19 +++++++++++---- packages/sage-react/lib/Alert/Alert.jsx | 14 +++++++---- packages/sage-react/lib/Alert/Alert.story.jsx | 10 ++++++++ packages/sage-react/lib/Badge/Badge.jsx | 4 ++++ packages/sage-react/lib/Badge/Badge.story.jsx | 9 +++++--- packages/sage-react/lib/Banner/Banner.jsx | 3 +++ .../lib/Breadcrumbs/Breadcrumbs.jsx | 5 ++++ packages/sage-react/lib/Button/Button.jsx | 5 ++++ .../lib/Button/ButtonGroup.story.jsx | 4 ++-- packages/sage-react/lib/Card/Card.jsx | 3 +++ .../sage-react/lib/CopyButton/CopyButton.jsx | 6 ++++- .../lib/CopyButton/CopyButton.story.jsx | 2 ++ packages/sage-react/lib/DataCard/DataCard.jsx | 5 +++- .../lib/DataCard/DataCardHeader.jsx | 3 ++- .../lib/ExpandableCard/ExpandableCard.jsx | 10 +++++--- packages/sage-react/lib/Hint/Hint.jsx | 5 +++- packages/sage-react/lib/Hint/Hint.story.jsx | 1 + packages/sage-react/lib/Icon/Icon.jsx | 6 +++++ packages/sage-react/lib/Input/Input.jsx | 5 +++- packages/sage-react/lib/Input/Input.story.jsx | 2 ++ packages/sage-react/lib/Link/Link.jsx | 5 ++++ packages/sage-react/lib/Link/Link.story.jsx | 4 ++-- .../sage-react/lib/MediaTile/MediaTile.jsx | 5 +++- .../lib/MediaTile/MediaTile.story.jsx | 1 + packages/sage-react/lib/Modal/Modal.jsx | 6 ++++- .../lib/NextBestAction/NextBestAction.jsx | 7 +++++- .../NextBestAction/NextBestAction.story.jsx | 2 ++ .../lib/PageHeading/PageHeading.jsx | 10 ++++---- packages/sage-react/lib/Panel/Panel.jsx | 5 +++- .../lib/ProgressBar/ProgressBar.jsx | 5 +++- .../lib/ProgressBar/ProgressBar.story.jsx | 2 ++ packages/sage-react/lib/Property/Property.jsx | 5 +++- .../lib/Property/Property.story.jsx | 3 ++- packages/sage-react/lib/Search/Search.jsx | 5 +++- packages/sage-react/lib/Select/Select.jsx | 5 +++- .../sage-react/lib/Select/Select.story.jsx | 13 +++++++---- packages/sage-react/lib/StatBox/StatBox.jsx | 4 ++++ .../sage-react/lib/StatBox/StatBox.story.jsx | 6 +++++ packages/sage-react/lib/Table/Table.jsx | 8 ++++++- packages/sage-react/lib/Table/TableRow.jsx | 23 ++++++++++++++++--- packages/sage-react/lib/Table/configs.js | 1 + packages/sage-react/lib/Textarea/Textarea.jsx | 5 +++- .../lib/Textarea/Textarea.story.jsx | 1 + packages/sage-react/lib/Toast/Toast.jsx | 6 ++++- packages/sage-react/lib/Toast/Toast.story.jsx | 2 ++ packages/sage-react/lib/Toggle/Checkbox.jsx | 3 +++ packages/sage-react/lib/Tooltip/Tooltip.jsx | 4 ++++ .../sage-react/lib/Tooltip/TooltipElement.jsx | 4 ++++ .../automationTestIds/automationTestIds.js | 20 ++++++++++++++++ .../lib/configs/automationTestIds/index.js | 1 + packages/sage-react/lib/configs/index.js | 1 + 52 files changed, 249 insertions(+), 49 deletions(-) create mode 100644 packages/sage-react/lib/configs/automationTestIds/automationTestIds.js create mode 100644 packages/sage-react/lib/configs/automationTestIds/index.js diff --git a/packages/sage-react/lib/Accordion/Accordion.jsx b/packages/sage-react/lib/Accordion/Accordion.jsx index 138f6e73bb..a0e61abb84 100644 --- a/packages/sage-react/lib/Accordion/Accordion.jsx +++ b/packages/sage-react/lib/Accordion/Accordion.jsx @@ -7,6 +7,7 @@ export const Accordion = ({ children, id, onlyOnePanelExpanded, + testId, ...rest }) => { const classNames = classnames( @@ -18,7 +19,7 @@ export const Accordion = ({ ); return ( -
+
{children}
); @@ -29,6 +30,7 @@ Accordion.defaultProps = { className: '', id: '', onlyOnePanelExpanded: false, + testId: null, }; Accordion.propTypes = { @@ -36,4 +38,5 @@ Accordion.propTypes = { className: PropTypes.string, id: PropTypes.string, onlyOnePanelExpanded: PropTypes.bool, + testId: PropTypes.string, }; diff --git a/packages/sage-react/lib/Accordion/Accordion.story.jsx b/packages/sage-react/lib/Accordion/Accordion.story.jsx index 632f31c70f..5daada7d4d 100644 --- a/packages/sage-react/lib/Accordion/Accordion.story.jsx +++ b/packages/sage-react/lib/Accordion/Accordion.story.jsx @@ -16,8 +16,8 @@ const MultipleTemplate = () => { }; return ( - - + + { id="checkbox1-demo" label="Grant offers" name="checkbox1-demo" + testId="grantOffers" /> { id="checkbox2-demo" label="Add tags" name="checkbox2-demo" + testId="addTags" /> { id="checkbox3-demo" label="Subscribe to emails" name="checkbox3-demo" + testId="subscribeToEmails" /> - + { id="checkbox1-demo" label="Grant offers" name="checkbox1-demo" + testId="grantOffers" /> { id="checkbox2-demo" label="Add tags" name="checkbox2-demo" + testId="addTags" /> { id="checkbox3-demo" label="Subscribe to emails" name="checkbox3-demo" + testId="subscribeToEmails" /> - + { id="checkbox1-demo" label="Grant offers" name="checkbox1-demo" + testId="grantOffers" /> { id="checkbox2-demo" label="Add tags" name="checkbox2-demo" + testId="addTags" /> { id="checkbox3-demo" label="Subscribe to emails" name="checkbox3-demo" + testId="subscribeToEmails" /> @@ -101,7 +110,7 @@ const MultipleTemplate = () => { const DefaultTemplate = () => ( - + - +
+
{title && ( -

+

{title} {titleAddon}

)} {description && ( -

{description}

+

{description}

)}
{actions && ( @@ -87,6 +88,7 @@ export const Alert = ({ value="Close" onClick={handleDismiss} aria-label="Close Alert" + testId="closeButton" />
)} @@ -105,6 +107,7 @@ Alert.defaultProps = { icon: null, onDismiss: null, small: false, + testId: null, title: null, titleAddon: null, }; @@ -118,6 +121,7 @@ Alert.propTypes = { icon: PropTypes.oneOf(Object.values(SageTokens.ICONS)), onDismiss: PropTypes.func, small: PropTypes.bool, + testId: PropTypes.string, title: PropTypes.string, titleAddon: PropTypes.string, }; diff --git a/packages/sage-react/lib/Alert/Alert.story.jsx b/packages/sage-react/lib/Alert/Alert.story.jsx index 009f36681e..9455d3ad98 100644 --- a/packages/sage-react/lib/Alert/Alert.story.jsx +++ b/packages/sage-react/lib/Alert/Alert.story.jsx @@ -48,12 +48,14 @@ DefaultWithActions.args = { Check Usage @@ -66,6 +68,7 @@ DismissableAlert.args = { description: 'Body duis rhoncus neque, sed nulla sed quis fames. Eu eu ut at odio ultrices orci varius habitant. Tempor vulputate in nisl massa eget id.', color: Alert.COLORS.DEFAULT, dismissable: true, + testId: 'exampleAlert', onClickDismiss: () => console.log('clicked to dismiss'), // eslint-disable-line }; @@ -80,11 +83,13 @@ DismissableAlertWithActions.args = { Check Usage @@ -97,17 +102,20 @@ export const NonDismissableAlert = Template.bind({}); NonDismissableAlert.args = { color: Alert.COLORS.APPROACHING, description: 'Body duis rhoncus neque, sed nulla sed quis fames. Eu eu ut at odio ultrices orci varius habitant. Tempor vulputate in nisl massa eget id.', + testId: 'nonDismissableAlert', actions: ( <> Check Usage @@ -121,11 +129,13 @@ SmallAlert.args = { dismissable: true, title: null, description: 'Body duis rhoncus neque, sed nulla sed quis fames et tu odio.', + testId: 'smallAlert', actions: ( <> Check Usage diff --git a/packages/sage-react/lib/Badge/Badge.jsx b/packages/sage-react/lib/Badge/Badge.jsx index 6f5b95422f..471049f7a2 100644 --- a/packages/sage-react/lib/Badge/Badge.jsx +++ b/packages/sage-react/lib/Badge/Badge.jsx @@ -14,6 +14,7 @@ export const Badge = React.forwardRef(({ isInteractive, isStatus, large, + testId, value, ...rest }, ref) => { @@ -32,6 +33,7 @@ export const Badge = React.forwardRef(({ return ( @@ -67,6 +69,7 @@ Badge.defaultProps = { isDropdown: false, isStatus: false, large: false, + testId: null, }; Badge.propTypes = { @@ -78,5 +81,6 @@ Badge.propTypes = { isDropdown: PropTypes.bool, isStatus: PropTypes.bool, large: PropTypes.bool, + testId: PropTypes.string, value: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired, }; diff --git a/packages/sage-react/lib/Badge/Badge.story.jsx b/packages/sage-react/lib/Badge/Badge.story.jsx index 610eca92e0..ff19fd45dd 100644 --- a/packages/sage-react/lib/Badge/Badge.story.jsx +++ b/packages/sage-react/lib/Badge/Badge.story.jsx @@ -34,7 +34,8 @@ export const IndicatorBadge = Template.bind({}); IndicatorBadge.args = { dot: ( - ) + ), + testId: 'indicatorBadge', }; export const InteractiveBadge = Template.bind({}); @@ -43,7 +44,8 @@ InteractiveBadge.args = { isInteractive: true, dot: ( - ) + ), + testId: 'interactiveBadge', }; export const LargeBadge = Template.bind({}); @@ -52,5 +54,6 @@ LargeBadge.args = { large: true, dot: ( - ) + ), + testId: 'largeBadge', }; diff --git a/packages/sage-react/lib/Banner/Banner.jsx b/packages/sage-react/lib/Banner/Banner.jsx index f16400852d..863470e54d 100644 --- a/packages/sage-react/lib/Banner/Banner.jsx +++ b/packages/sage-react/lib/Banner/Banner.jsx @@ -8,6 +8,7 @@ import { BANNER_TYPES } from './configs'; export const Banner = ({ active, bannerContext, + testId, ...rest }) => ( (bannerContext !== null) @@ -24,6 +25,7 @@ Banner.defaultProps = { dismissable: true, link: null, onDismiss: null, + testId: null, text: null, type: Banner.TYPES.DEFAULT, }; @@ -39,6 +41,7 @@ Banner.propTypes = { target: PropTypes.string }), onDismiss: PropTypes.func, + testId: PropTypes.string, text: PropTypes.string, type: PropTypes.oneOf(Object.values(BANNER_TYPES)), }; diff --git a/packages/sage-react/lib/Breadcrumbs/Breadcrumbs.jsx b/packages/sage-react/lib/Breadcrumbs/Breadcrumbs.jsx index 15c00e0125..fcf9fcd94f 100644 --- a/packages/sage-react/lib/Breadcrumbs/Breadcrumbs.jsx +++ b/packages/sage-react/lib/Breadcrumbs/Breadcrumbs.jsx @@ -11,6 +11,7 @@ export const Breadcrumbs = ({ icon, isProgressbar, items, + testId, ...rest }) => { const classNames = classnames( @@ -38,6 +39,7 @@ export const Breadcrumbs = ({ className={`sage-breadcrumbs__link ${isCurrent && 'sage-breadcrumbs__link--current'}`} suppressDefaultClass={true} tag={linkTag} + testId="breadcrumbListItem" {...otherProps} > {(icon && items.length === 1 && i === 0) && ( @@ -59,6 +61,7 @@ export const Breadcrumbs = ({