Skip to content

Commit

Permalink
CB-4060 feat: remove data-testid attribute (#2166)
Browse files Browse the repository at this point in the history
Co-authored-by: mr-anton-t <[email protected]>
  • Loading branch information
Wroud and mr-anton-t authored Dec 6, 2023
1 parent 669ad9c commit b83cd0d
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ export const Switch: SwitchType = observer(function Switch({
}

return (
<Field data-testid="field" title={rest.title}>
<div data-testid="switch-body" className={styles.switchBody}>
<div data-testid="switch-control" className={s(styles, { switchControl: true, disabled: disabled, checked: checkboxState.checked })}>
<div data-testid="switch-control-track" className={styles.switchControlTrack} />
<div data-testid="switch-control-underlay" className={styles.switchControlUnderlay}>
<div data-testid="switch-control-thumb" className={styles.switchControlThumb} />
<Field title={rest.title}>
<div className={styles.switchBody}>
<div className={s(styles, { switchControl: true, disabled: disabled, checked: checkboxState.checked })}>
<div className={styles.switchControlTrack} />
<div className={styles.switchControlUnderlay}>
<div className={styles.switchControlThumb} />
<input
{...rest}
type="checkbox"
Expand All @@ -86,13 +86,12 @@ export const Switch: SwitchType = observer(function Switch({
aria-checked={checkboxState.checked}
checked={checkboxState.checked}
disabled={disabled}
data-testid="switch-input"
className={styles.switchInput}
onChange={checkboxState.change}
/>
</div>
</div>
<FieldLabel htmlFor={id || value || name} data-testid="field-label" className={styles.fieldLabel}>
<FieldLabel htmlFor={id || value || name} className={styles.fieldLabel}>
{children}
</FieldLabel>
</div>
Expand Down
12 changes: 3 additions & 9 deletions webapp/packages/core-blocks/src/FormControls/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,7 @@ export const Combobox: ComboboxType = observer(function Combobox({
<MenuButton {...menu} disabled={readOnly || disabled || hideMenu} className={styles.menuButton}>
<Icon name="arrow" viewBox="0 0 16 16" className={s(styles, { icon: true, focus })} />
</MenuButton>
<Menu
{...menu}
ref={menuRef}
aria-label={propertyName}
className={s(styles, { menu: true })}
modal
>
<Menu {...menu} ref={menuRef} aria-label={propertyName} className={s(styles, { menu: true })} modal>
{!filteredItems.length ? (
<MenuItem id="placeholder" disabled {...menu} className={s(styles, { menuItem: true })}>
{translate('combobox_no_results_placeholder')}
Expand All @@ -322,11 +316,11 @@ export const Combobox: ComboboxType = observer(function Combobox({
onClick={event => handleSelect(event.currentTarget.id)}
>
{iconSelector && (
<div data-testid="item-icon" className={s(styles, { itemIcon: true })}>
<div className={s(styles, { itemIcon: true })}>
{icon && typeof icon === 'string' ? <IconOrImage icon={icon} className={s(styles, { iconOrImage: true })} /> : icon}
</div>
)}
<div data-testid="item-value">{valueSelector(item)}</div>
<div>{valueSelector(item)}</div>
</MenuItem>
);
})
Expand Down
6 changes: 1 addition & 5 deletions webapp/packages/core-blocks/src/FormControls/InputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,7 @@ export const InputField: InputFieldType = observer<ControlledProps | ObjectProps
<Icon name="copy" viewBox="0 0 32 32" className={styles.icon} />
</div>
)}
{icon && (
<div data-testid="icon-container" className={s(styles, { customIconContainer: true })}>
{icon}
</div>
)}
{icon && <div className={s(styles, { customIconContainer: true })}>{icon}</div>}
</div>
{(description || passwordType) && <FieldDescription invalid={error}>{description}</FieldDescription>}
</Field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ interface Props {
export const SnackbarBody: React.FC<React.PropsWithChildren<Props>> = function SnackbarBody({ title, className, children }) {
const styles = useS(style);
return (
<div data-testid="notification-body" className={s(styles, { notificationBody: true }, className)}>
<div data-testid="body-text-block" className={styles.bodyTextBlock}>
<h2 data-testid="text-block-title" title={title} className={styles.textBlockTitle}>
<div className={s(styles, { notificationBody: true }, className)}>
<div className={styles.bodyTextBlock}>
<h2 title={title} className={styles.textBlockTitle}>
{title}
</h2>
<div data-testid="message" className={styles.message}>
{children}
</div>
<div className={styles.message}>{children}</div>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,5 @@ interface Props {

export const SnackbarContent: React.FC<React.PropsWithChildren<Props>> = function SnackbarContent({ children, className }) {
const styles = useS(style);
return (
<div data-testid="notification-content" className={s(styles, { notificationContent: true }, className)}>
{children}
</div>
);
return <div className={s(styles, { notificationContent: true }, className)}>{children}</div>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ export const SnackbarFooter: React.FC<React.PropsWithChildren<Props>> = function
const timeStringFromTimestamp = new Date(timestamp).toLocaleTimeString();

return (
<div data-testid="notification-footer" className={s(styles, { notificationFooter: true }, className)}>
<span data-testid="footer-time" className={styles.footerTime}>
{timeStringFromTimestamp}
</span>
<div data-testid="actions" className={styles.actions}>
{children}
</div>
<div className={s(styles, { notificationFooter: true }, className)}>
<span className={styles.footerTime}>{timeStringFromTimestamp}</span>
<div className={styles.actions}>{children}</div>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface SnackbarStatusProps {
export const SnackbarStatus: React.FC<SnackbarStatusProps> = function SnackbarStatus({ status, className }) {
const styles = useS(style);
return status === ENotificationType.Loading ? (
<div data-testid="loader-container" className={s(styles, { loaderContainer: true }, className)}>
<div className={s(styles, { loaderContainer: true }, className)}>
<Loader className={styles.loader} hideMessage />
</div>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const SnackbarWrapper: React.FC<React.PropsWithChildren<Props>> = functio
}, []);

return (
<div data-testid="notification" className={s(styles, { notification: true, mounted, closing }, className)}>
<div className={s(styles, { notification: true, mounted, closing }, className)}>
{children}
{!persistent && onClose && (
<IconButton name="cross" viewBox="0 0 16 16" className={s(styles, { iconButton: true, large: true })} onClick={onClose} />
Expand Down
4 changes: 1 addition & 3 deletions webapp/packages/core-cli/configs/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
/* eslint-disable @typescript-eslint/no-var-requires */
const testingAttributes = require('../dist/babel-plugins/TestingAttributes.js');

module.exports = api => {
const devMode = !api.env('production');
Expand All @@ -28,6 +26,6 @@ module.exports = api => {
},
],
],
plugins: [[testingAttributes, {}], [require('@reshadow/babel'), {}], devMode && require.resolve('react-refresh/babel')].filter(Boolean),
plugins: [[require('@reshadow/babel'), {}], devMode && require.resolve('react-refresh/babel')].filter(Boolean),
};
};
3 changes: 0 additions & 3 deletions webapp/packages/core-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
"core-cli-validate-dependencies": "./bin/validate-dependencies.js",
"typescript-resolve-references": "./bin/typescript-resolve-references.js"
},
"scripts": {
"install": "tsc"
},
"engines": {
"node": ">=16.0.0"
},
Expand Down
122 changes: 0 additions & 122 deletions webapp/packages/core-cli/src/babel-plugins/TestingAttributes.ts

This file was deleted.

10 changes: 0 additions & 10 deletions webapp/packages/core-cli/tsconfig.eslint.json

This file was deleted.

13 changes: 0 additions & 13 deletions webapp/packages/core-cli/tsconfig.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const NavTreeLimitMessage: NavigationNodeRendererComponent = observer(function N
}

return (
<div className={s(styles, { loadMoreBox: true })} data-testid="load-more-box">
<div className={s(styles, { loadMoreBox: true })}>
<Link title={translate('app_navigationTree_limited', undefined, { limit: limit })} onClick={loadMore}>
{translate('ui_load_more')}
</Link>
Expand Down

0 comments on commit b83cd0d

Please sign in to comment.