Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Добавить data-tid #2900

Merged
merged 43 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
cd0e418
chore: add data-tid and export
HelenaIsh May 26, 2022
0608b66
chore: fix prettier
HelenaIsh May 26, 2022
4c608df
chore: delete data-tid from CommonWrapper
HelenaIsh May 30, 2022
1365ee1
chore: add data-tid page to docs
HelenaIsh May 31, 2022
25cdd3c
chore: small fixes
HelenaIsh May 31, 2022
476f827
chore: delete comments
HelenaIsh May 31, 2022
9033388
chore: add origin field
HelenaIsh May 31, 2022
f3e5352
chore: refactor componentsDataTid
HelenaIsh Jun 1, 2022
00b93c3
chore: add internal components to data-tids list
HelenaIsh Jun 1, 2022
ff0c2fd
chore: fix export of data-tids of inner components
HelenaIsh Jun 1, 2022
2b14c70
Revert "chore: add origin field"
HelenaIsh Jun 1, 2022
fff1a59
chore: delete origin
HelenaIsh Jun 1, 2022
435303c
chore: fix export inner components
HelenaIsh Jun 1, 2022
616ef41
chore: fix docs
HelenaIsh Jun 1, 2022
ee471c3
chore: rename datatids objects
HelenaIsh Jun 2, 2022
acb46fb
chore: fix table styles
HelenaIsh Jun 2, 2022
57c0e1e
chore: fix ts error
HelenaIsh Jun 2, 2022
f3f3ea8
chore: add search to Select
HelenaIsh Jun 3, 2022
0f8121f
chore: fix import of inner components in internal
HelenaIsh Jun 3, 2022
a8c6c20
chore: fix typo
HelenaIsh Jun 3, 2022
8fd1b9a
chore: delete internal components from data-tid table
HelenaIsh Jun 3, 2022
d0cc5ee
chore: skip error
HelenaIsh Jun 3, 2022
e9f6174
chore: mark as deprecated
HelenaIsh Jun 3, 2022
404c8c0
chore: fix FileUploader tests
HelenaIsh Jun 6, 2022
2e6d37a
Merge branch 'master' into data-tid
HelenaIsh Jun 6, 2022
5aee6d0
chore: small fix
HelenaIsh Jun 6, 2022
6f3e0a7
chore: small refactor of data-tid table
HelenaIsh Jun 6, 2022
4fea332
chore: delete console.log
HelenaIsh Jun 6, 2022
462ba97
chore: add expect-error to ts-ignore
HelenaIsh Jun 7, 2022
eea9e83
chore: delete empty object
HelenaIsh Jun 7, 2022
d80c2a4
chore: update styles
HelenaIsh Jun 7, 2022
2a098ee
chore: fix ts error
HelenaIsh Jun 7, 2022
91477a9
Revert "chore: mark as deprecated"
HelenaIsh Jun 8, 2022
8fed45a
chore: move data-tids to internal folder
HelenaIsh Jun 8, 2022
b67e030
chore: delete search
HelenaIsh Jun 8, 2022
929023a
chore: update table style
HelenaIsh Jun 8, 2022
112b78c
chore: update table style 2
HelenaIsh Jun 8, 2022
a2a4555
chore: fix typo
HelenaIsh Jun 9, 2022
568d9d3
chore: return search
HelenaIsh Jun 9, 2022
599f8f4
Merge branch 'master' into data-tid
HelenaIsh Jun 9, 2022
69a6fa6
chore: fix review
HelenaIsh Jun 15, 2022
4144ee1
chore: fix typo
HelenaIsh Jun 27, 2022
74e6fa3
Merge branch 'master' into data-tid
HelenaIsh Jun 27, 2022
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
1 change: 1 addition & 0 deletions packages/react-ui/.styleguide/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const getCommonSections = () => {
{ name: 'Roadmap', content: path.join(__dirname, '../ROADMAP.md') },
{ name: 'Migration', content: path.join(__dirname, '../MIGRATION.md'), exampleMode: 'expand' },
{ name: 'LocaleContext', content: path.join(__dirname, '../lib/locale/LOCALECONTEXT.md') },
{ name: 'DataTids', content: path.join(__dirname, '../internal/DataTids/DATATIDS.md') },
{ name: 'SSR', content: path.join(__dirname, '../SSR.md') },
{ name: 'Mobiles', content: path.join(__dirname, '../MOBILES.md') },
{ name: 'Accessibility', content: path.join(__dirname, '../../../accessibility.md') },
Expand Down
11 changes: 10 additions & 1 deletion packages/react-ui/components/Autocomplete/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export interface AutocompleteState {
isMobileOpened: boolean;
}

export const AutocompleteDataTids = {
root: 'Autocomplete__root',
} as const;

/**
* Стандартный инпут с подсказками.
*
Expand Down Expand Up @@ -212,7 +216,12 @@ export class Autocomplete extends React.Component<AutocompleteProps, Autocomplet

return (
<RenderLayer onFocusOutside={this.handleBlur} onClickOutside={this.handleClickOutside} active={focused}>
<span className={styles.root(this.theme)} style={{ width }} ref={this.refRootSpan}>
<span
data-tid={AutocompleteDataTids.root}
className={styles.root(this.theme)}
style={{ width }}
ref={this.refRootSpan}
>
<Input {...inputProps} />
{isMobile ? this.renderMobileMenu() : this.renderMenu()}
</span>
Expand Down
6 changes: 5 additions & 1 deletion packages/react-ui/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ export interface ButtonState {
focusedByTab: boolean;
}

export const ButtonDataTids = {
root: 'Button__root',
} as const;

@rootNode
export class Button extends React.Component<ButtonProps, ButtonState> {
public static __KONTUR_REACT_UI__ = 'Button';
Expand Down Expand Up @@ -374,7 +378,7 @@ export class Button extends React.Component<ButtonProps, ButtonState> {
return (
<CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>
<span {...wrapProps}>
<button ref={this._ref} {...rootProps}>
<button data-tid={ButtonDataTids.root} ref={this._ref} {...rootProps}>
{innerShadowNode}
{outlineNode}
{loadingNode}
Expand Down
5 changes: 5 additions & 0 deletions packages/react-ui/components/Center/Center.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export interface CenterProps
}
> {}

export const CenterDataTids = {
root: 'Center__root',
} as const;

/**
* Контейнер, который центрирует элементы внутри себя.
*/
Expand All @@ -47,6 +51,7 @@ export class Center extends React.Component<CenterProps> {

return (
<div
data-tid={CenterDataTids.root}
{...rest}
className={cx({
[styles.root()]: true,
Expand Down
6 changes: 6 additions & 0 deletions packages/react-ui/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ export interface CheckboxState {
indeterminate: boolean;
isShiftPressed: boolean;
}

export const CheckboxDataTids = {
root: 'Checkbox__root',
} as const;

@rootNode
export class Checkbox extends React.PureComponent<CheckboxProps, CheckboxState> {
public static __KONTUR_REACT_UI__ = 'Checkbox';
Expand Down Expand Up @@ -250,6 +255,7 @@ export class Checkbox extends React.PureComponent<CheckboxProps, CheckboxState>

return (
<label
data-tid={CheckboxDataTids.root}
className={rootClass}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
Expand Down
5 changes: 5 additions & 0 deletions packages/react-ui/components/CurrencyInput/CurrencyInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export interface CurrencyInputState {
focused: boolean;
}

export const CurrencyInputDataTids = {
root: 'CurrencyInput__root',
} as const;

/**
* Поле для денежных сумм (и других числовых значений).
* Принимает любые свойства `Input`.
Expand Down Expand Up @@ -141,6 +145,7 @@ export class CurrencyInput extends React.PureComponent<CurrencyInputProps, Curre

return (
<Input
data-tid={CurrencyInputDataTids.root}
{...rest}
value={this.state.formatted}
onBlur={this.handleBlur}
Expand Down
6 changes: 5 additions & 1 deletion packages/react-ui/components/CurrencyLabel/CurrencyLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ export const defaultProps = {
fractionDigits: 2,
};

export const CurrencyLabelDataTids = {
root: 'CurrencyLabel__root',
} as const;

export const CurrencyLabel = (props: CurrencyLabelProps): JSX.Element => {
const { value, fractionDigits, currencySymbol } = props;
return (
<CommonWrapper {...props}>
<span>
<span data-tid={CurrencyLabelDataTids.root}>
{CurrencyHelper.format(value, { fractionDigits })}
{currencySymbol && String.fromCharCode(0xa0) /* &nbsp; */}
{currencySymbol}
Expand Down
13 changes: 12 additions & 1 deletion packages/react-ui/components/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export interface DatePickerState {

type DatePickerValue = string;

export const DatePickerDataTids = {
root: 'DatePicker__root',
pickerRoot: 'Picker__root',
pickerTodayWrapper: 'Picker__todayWrapper',
} as const;

@rootNode
export class DatePicker extends React.PureComponent<DatePickerProps<DatePickerValue>, DatePickerState> {
public static __KONTUR_REACT_UI__ = 'DatePicker';
Expand Down Expand Up @@ -250,7 +256,12 @@ export class DatePicker extends React.PureComponent<DatePickerProps<DatePickerVa

if (this.state.opened) {
picker = (
<DropdownContainer getParent={this.getParent} offsetY={2} align={this.props.menuAlign}>
<DropdownContainer
data-tid={DatePickerDataTids.root}
getParent={this.getParent}
offsetY={2}
align={this.props.menuAlign}
>
<Picker
value={date}
minDate={formattedMinDate}
Expand Down
9 changes: 7 additions & 2 deletions packages/react-ui/components/DatePicker/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ThemeContext } from '../../lib/theming/ThemeContext';

import { styles } from './Picker.styles';
import { DatePickerLocale, DatePickerLocaleHelper } from './locale';
import { DatePickerDataTids } from './DatePicker';

interface Props {
maxDate?: CalendarDateShape;
Expand Down Expand Up @@ -75,7 +76,11 @@ export class Picker extends React.Component<Props, State> {
const { date } = this.state;

return (
<div className={styles.root(this.theme)} onMouseDown={(e) => e.preventDefault()}>
<div
data-tid={DatePickerDataTids.pickerRoot}
className={styles.root(this.theme)}
onMouseDown={(e) => e.preventDefault()}
>
<Calendar
ref={(c) => (this.calendar = c)}
value={this.props.value}
Expand All @@ -102,7 +107,7 @@ export class Picker extends React.Component<Props, State> {
const today = new InternalDate({ order, separator }).setComponents(InternalDateGetter.getTodayComponents());
return (
<button
data-tid="Picker__todayWrapper"
data-tid={DatePickerDataTids.pickerTodayWrapper}
className={styles.todayWrapper(this.theme)}
onClick={this.handleSelectToday(today)}
tabIndex={-1}
Expand Down
5 changes: 5 additions & 0 deletions packages/react-ui/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export interface DropdownProps extends CommonProps {

type DropdownSelectType = Select<React.ReactNode, React.ReactNode>;

export const DropdownDataTids = {
root: 'Dropdown__root',
} as const;

/**
* Выпадающее меню.
*
Expand Down Expand Up @@ -178,6 +182,7 @@ export class Dropdown extends React.Component<DropdownProps> {

return (
<Select<React.ReactNode, React.ReactNode>
data-tid={DropdownDataTids.root}
ref={this._refSelect}
{...filterProps(props, PASS_PROPS)}
value={caption}
Expand Down
12 changes: 9 additions & 3 deletions packages/react-ui/components/FileUploader/FileUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export interface FileUploaderRef {
reset: () => void;
}

export const FileUploaderDataTids = {
root: 'FileUploader__root',
content: 'FileUploader__content',
link: 'FileUploader__link',
} as const;

const defaultRenderFile = (file: FileUploaderAttachedFile, fileNode: React.ReactElement) => fileNode;

const _FileUploader = React.forwardRef<FileUploaderRef, _FileUploaderProps>((props: _FileUploaderProps, ref) => {
Expand Down Expand Up @@ -227,7 +233,7 @@ const _FileUploader = React.forwardRef<FileUploaderRef, _FileUploaderProps>((pro

return (
<CommonWrapper {...props}>
<div className={jsStyles.root(theme)} style={useMemoObject({ width })}>
<div data-tid={FileUploaderDataTids.root} className={jsStyles.root(theme)} style={useMemoObject({ width })}>
{!hideFiles && !isSingleMode && !!files.length && <FileUploaderFileList renderFile={renderFile} />}
<div className={uploadButtonWrapperClassNames}>
<label
Expand All @@ -236,8 +242,8 @@ const _FileUploader = React.forwardRef<FileUploaderRef, _FileUploaderProps>((pro
ref={labelRef}
className={uploadButtonClassNames}
>
<div data-tid={'FileUploader__content'} className={jsStyles.content()}>
<span data-tid={'FileUploader__link'} className={linkClassNames}>
<div data-tid={FileUploaderDataTids.content} className={jsStyles.content()}>
<span data-tid={FileUploaderDataTids.link} className={linkClassNames}>
{hasOneFileForSingle ? locale.choosedFile : locale.chooseFile}
</span>
&nbsp;
Expand Down
6 changes: 5 additions & 1 deletion packages/react-ui/components/FxInput/FxInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export interface FxInputProps
}
> {}

export const FxInputDataTids = {
root: 'FxInput__root',
} as const;

/** Принимает все свойства `Input`'a */
@rootNode
export class FxInput extends React.Component<FxInputProps> {
Expand Down Expand Up @@ -87,7 +91,7 @@ export class FxInput extends React.Component<FxInputProps> {
}

return (
<Group width={this.props.width}>
<Group data-tid={FxInputDataTids.root} width={this.props.width}>
{button}
{this.getProps().type === 'currency' ? (
<CurrencyInput
Expand Down
9 changes: 7 additions & 2 deletions packages/react-ui/components/Gapped/Gapped.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export interface GappedProps extends CommonProps {
children: React.ReactNode;
}

export const GappedDataTids = {
vertical: 'Gapped__vertical',
horizontal: 'Gapped__horizontal',
} as const;

/**
* Контейнер, расстояние между элементами в котором равно `gap`.
*/
Expand Down Expand Up @@ -94,7 +99,7 @@ export class Gapped extends React.Component<GappedProps> {
);
});

return <div>{children}</div>;
return <div data-tid={GappedDataTids.vertical}>{children}</div>;
}

private renderHorizontal() {
Expand All @@ -109,7 +114,7 @@ export class Gapped extends React.Component<GappedProps> {
const contStyle: React.CSSProperties = wrap ? { marginTop: -gap - 1, marginLeft: -gap } : { whiteSpace: 'nowrap' };

return (
<div style={rootStyle}>
<div data-tid={GappedDataTids.horizontal} style={rootStyle}>
<div style={contStyle}>
{React.Children.toArray(children)
.filter(this.filterChildren)
Expand Down
6 changes: 5 additions & 1 deletion packages/react-ui/components/GlobalLoader/GlobalLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ interface DefaultProps {
}
export type GlobalLoaderComponentProps = GlobalLoaderProps & DefaultProps;

export const GlobalLoaderDataTids = {
root: 'GlobalLoader',
} as const;

let currentGlobalLoader: GlobalLoader;

@rootNode
Expand Down Expand Up @@ -160,7 +164,7 @@ export class GlobalLoader extends React.Component<GlobalLoaderComponentProps, Gl
expectedResponseTime={this.state.expectedResponseTime}
delayBeforeHide={this.props.delayBeforeHide}
status={status}
data-tid="GlobalLoader"
data-tid={GlobalLoaderDataTids.root}
disableAnimations={this.props.disableAnimations}
/>
</CommonWrapper>
Expand Down
6 changes: 5 additions & 1 deletion packages/react-ui/components/Group/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ const passCornersIfButton = (child: React.ReactNode, firstChild: React.ReactNode
return child;
};

export const GroupDataTids = {
root: 'Group__root',
} as const;

@rootNode
export class Group extends React.Component<GroupProps> {
public static __KONTUR_REACT_UI__ = 'Group';
Expand All @@ -94,7 +98,7 @@ export class Group extends React.Component<GroupProps> {

return (
<CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>
<span className={styles.root()} style={style}>
<span data-tid={GroupDataTids.root} className={styles.root()} style={style}>
{React.Children.map(childrenArray, (child) => {
if (!child || !React.isValidElement<GroupChildProps>(child)) {
return null;
Expand Down
6 changes: 5 additions & 1 deletion packages/react-ui/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ export interface InputState {
needsPolyfillPlaceholder: boolean;
}

export const InputDataTids = {
root: 'Input__root',
} as const;

/**
* Интерфейс пропсов наследуется от `React.InputHTMLAttributes<HTMLInputElement>`.
* Все пропсы кроме перечисленных, `className` и `style` передаются в `<input>`
Expand Down Expand Up @@ -328,7 +332,7 @@ export class Input extends React.Component<InputProps, InputState> {
const input = mask ? this.renderMaskedInput(inputProps, mask) : React.createElement('input', inputProps);

return (
<label {...labelProps}>
<label data-tid={InputDataTids.root} {...labelProps}>
<span className={styles.sideContainer()}>
{this.renderLeftIcon()}
{this.renderPrefix()}
Expand Down
6 changes: 5 additions & 1 deletion packages/react-ui/components/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export interface LinkState {
focusedByTab: boolean;
}

export const LinkDataTids = {
root: 'Link__root',
} as const;

/**
* Элемент ссылки из HTML.
*/
Expand Down Expand Up @@ -149,7 +153,7 @@ export class Link extends React.Component<LinkProps, LinkState> {
};

return (
<a {...rest} {...linkProps}>
<a data-tid={LinkDataTids.root} {...rest} {...linkProps}>
{iconElement}
{this.props.children}
{arrow}
Expand Down
9 changes: 7 additions & 2 deletions packages/react-ui/components/Loader/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ export interface LoaderState {
spinnerStyle?: object;
}

export const LoaderDataTids = {
veil: 'Loader__Veil',
spinner: 'Loader__Spinner',
} as const;

/**
* DRAFT - лоадер-контейнер
*/
Expand Down Expand Up @@ -217,7 +222,7 @@ export class Loader extends React.Component<LoaderProps, LoaderState> {

return (
<CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>
<div className={styles.loader()} data-tid={isLoaderActive ? 'Loader__Veil' : ''}>
<div className={styles.loader()} data-tid={isLoaderActive ? LoaderDataTids.veil : ''}>
<ZIndex
priority={'Loader'}
applyZIndex={isLoaderActive}
Expand Down Expand Up @@ -254,7 +259,7 @@ export class Loader extends React.Component<LoaderProps, LoaderState> {
private renderSpinner(type?: 'mini' | 'normal' | 'big', caption?: React.ReactNode, component?: React.ReactNode) {
return (
<span
data-tid={'Loader__Spinner'}
data-tid={LoaderDataTids.spinner}
className={cx(styles.spinnerContainer(), { [styles.spinnerContainerSticky()]: this.state.isStickySpinner })}
style={this.state.spinnerStyle}
>
Expand Down
Loading