Skip to content

Commit

Permalink
EPMRPP-91237 || Notifications page. Add test automation attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
AmsterGet committed May 30, 2024
1 parent 917bd94 commit 5b1fa03
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ FieldElement.defaultProps = {
labelClassName: '',
descriptionClassName: '',
withoutProvider: false,
dataAutomationId: '',
dataAutomationId: null,
isRequired: false,
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@ import { isInternalLink } from '../utils';

const cx = classNames.bind(styles);

export const LinkComponent = ({ to, children, icon, className }) => {
export const LinkComponent = ({ to, children, icon, className, automationId }) => {
return isInternalLink(to) ? (
<Link to={to} className={cx(className)} target={'_blank'}>
<Link to={to} className={cx(className)} target={'_blank'} data-automation-id={automationId}>
{children}
{icon && <i className={cx('icon')}>{Parser(icon)}</i>}
</Link>
) : (
<a href={to} className={cx(className)} target={'_blank'} rel="noopener noreferrer">
<a
href={to}
className={cx(className)}
target={'_blank'}
rel="noopener noreferrer"
data-automation-id={automationId}
>
{children}
{icon && <i className={cx('icon')}>{Parser(icon)}</i>}
</a>
Expand All @@ -49,8 +55,10 @@ LinkComponent.propTypes = {
children: PropTypes.node.isRequired,
icon: PropTypes.string,
className: PropTypes.string,
automationId: PropTypes.string,
};

LinkComponent.defaultProps = {
className: 'link-item-wrapper',
icon: null,
automationId: null,
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const EmptyRuleState = ({ ruleName, onCreateClick }) => {
variant={'text'}
customClassName={cx('button')}
startIcon={plusIcon}
dataAutomationId="createRuleFromEmptyStateButton"
>
{formatMessage(messages.create)}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const NotificationsFooter = () => {
link: docsReferences.pluginsDocs,
description: formatMessage(messages.discoverPluginsDescription),
openIcon: openInNewTabIcon,
automationId: 'documentationLink',
},
{
title: formatMessage(messages.integrationSettings),
Expand All @@ -58,6 +59,7 @@ export const NotificationsFooter = () => {
},
description: formatMessage(messages.integrationSettingsDescription),
openIcon: arrowRightIcon,
automationId: 'integrationSettingsLink',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ const cx = classNames.bind(styles);
export const HelpPanel = ({ items }) => {
return (
<div className={cx('help-panel-container')}>
{items.map((item) => (
<div key={`info-item-${item.title}`} className={cx('info-item')}>
{items.map(({ title, mainIcon, link, openIcon, automationId, description }) => (
<div key={`info-item-${title}`} className={cx('info-item')}>
<span className={cx('main-item-icon')}>
<i className={cx('icon')}>{Parser(item.mainIcon)}</i>
<i className={cx('icon')}>{Parser(mainIcon)}</i>
</span>
<div className={cx('item-content-wrapper')}>
<LinkComponent to={item.link} icon={item.openIcon}>
<span className={cx('item-title')}>{item.title}</span>
<LinkComponent to={link} icon={openIcon} automationId={automationId}>
<span className={cx('item-title')}>{title}</span>
</LinkComponent>
<p>{item.description}</p>
<p>{description}</p>
</div>
</div>
))}
Expand All @@ -56,6 +56,10 @@ HelpPanel.propTypes = {
payload: PropTypes.object,
}),
]).isRequired,
automationId: PropTypes.string,
}),
),
};
HelpPanel.defaultProps = {
items: [],
};
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ const AddEditNotificationModal = ({
type={field.type}
className={cx('dynamicField')}
description={field.description}
dataAutomationId={`${field.name}Field`}
>
<FieldErrorHint provideHint={false}>
<TypedComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ export const RuleGroup = ({ pluginName, ruleDescription, rules, isPluginEnabled,
const activeProject = useSelector(activeProjectSelector);
const userRole = useSelector(userAccountRoleSelector);
const isEmailIntegrationAvailable = useSelector(isEmailIntegrationAvailableSelector);
const pluginNameInCamelCase = toCamelCase(pluginName);
const isPluginNotificationsEnabled = useSelector(
projectPluginNotificationsStateSelector(toCamelCase(pluginName)),
projectPluginNotificationsStateSelector(pluginNameInCamelCase),
);

const isUpdateSettingAvailable = canUpdateSettings(userRole, projectRole);
Expand Down Expand Up @@ -121,7 +122,7 @@ export const RuleGroup = ({ pluginName, ruleDescription, rules, isPluginEnabled,
dispatch(
updateNotificationStateAction(
isEnabled,
NOTIFICATIONS_PLUGIN_ATTRIBUTE_ENABLED_KEY(toCamelCase(pluginName)),
NOTIFICATIONS_PLUGIN_ATTRIBUTE_ENABLED_KEY(pluginNameInCamelCase),
),
);
};
Expand Down Expand Up @@ -234,7 +235,7 @@ export const RuleGroup = ({ pluginName, ruleDescription, rules, isPluginEnabled,
];

return (
<div className={cx('rule-section')}>
<div className={cx('rule-section')} data-automation-id={`${pluginNameInCamelCase}RulesSection`}>
<Layout description={''} className={cx('rule-section-layout')}>
<div className={cx('rule-section-header')}>
<FieldElement
Expand Down Expand Up @@ -319,6 +320,7 @@ export const RuleGroup = ({ pluginName, ruleDescription, rules, isPluginEnabled,
onClick={onAdd}
variant={'text'}
startIcon={addIcon}
dataAutomationId="addRuleButton"
>
{formatMessage(messages.addRule)}
</Button>
Expand Down

0 comments on commit 5b1fa03

Please sign in to comment.