diff --git a/.changeset/odd-baths-slide.md b/.changeset/odd-baths-slide.md new file mode 100644 index 0000000000..9a7437f872 --- /dev/null +++ b/.changeset/odd-baths-slide.md @@ -0,0 +1,6 @@ +--- +'@alfalab/core-components-file-upload-item': patch +'@alfalab/core-components': patch +--- + +- Добавлен атрибут `data-test-id` к кнопкам с действиями diff --git a/packages/file-upload-item/src/Component.tsx b/packages/file-upload-item/src/Component.tsx index f04ed5d9a9..7c4de9b197 100644 --- a/packages/file-upload-item/src/Component.tsx +++ b/packages/file-upload-item/src/Component.tsx @@ -80,6 +80,7 @@ export const FileUploadItemComponent: React.FC = ({ backgroundColor, actionsPresent, setActionsPresent, + dataTestId, }} > {children} diff --git a/packages/file-upload-item/src/components/actions-control/components/delete-button/delete-button.tsx b/packages/file-upload-item/src/components/actions-control/components/delete-button/delete-button.tsx index bac5a43da5..d872dbb5fc 100644 --- a/packages/file-upload-item/src/components/actions-control/components/delete-button/delete-button.tsx +++ b/packages/file-upload-item/src/components/actions-control/components/delete-button/delete-button.tsx @@ -1,6 +1,7 @@ import React, { type MouseEvent, useContext } from 'react'; import { IconButton } from '@alfalab/core-components-icon-button'; +import { getDataTestId } from '@alfalab/core-components-shared'; import CrossMIcon from '@alfalab/icons-glyph/CrossMIcon'; import { FileUploadItemContext } from '../../../../context/file-upload-item-context'; @@ -8,7 +9,7 @@ import { FileUploadItemContext } from '../../../../context/file-upload-item-cont import styles from '../../actions-control.module.css'; export const DeleteButton = () => { - const { id = '0', disableButtons, onDelete } = useContext(FileUploadItemContext); + const { id = '0', dataTestId, disableButtons, onDelete } = useContext(FileUploadItemContext); const handleDelete = (e: MouseEvent) => { if (onDelete) { @@ -24,6 +25,7 @@ export const DeleteButton = () => { icon={} disabled={disableButtons} onClick={handleDelete} + dataTestId={getDataTestId(dataTestId, 'delete-button')} /> ); }; diff --git a/packages/file-upload-item/src/components/actions-control/components/download-button/download-button.tsx b/packages/file-upload-item/src/components/actions-control/components/download-button/download-button.tsx index 232d4754e8..67ba01c600 100644 --- a/packages/file-upload-item/src/components/actions-control/components/download-button/download-button.tsx +++ b/packages/file-upload-item/src/components/actions-control/components/download-button/download-button.tsx @@ -1,6 +1,7 @@ import React, { type MouseEvent, useContext } from 'react'; import { IconButton } from '@alfalab/core-components-icon-button'; +import { getDataTestId } from '@alfalab/core-components-shared'; import ArrowDownLineDownCompactMIcon from '@alfalab/icons-glyph/ArrowDownLineDownCompactMIcon'; import { FileUploadItemContext } from '../../../../context/file-upload-item-context'; @@ -10,6 +11,7 @@ import styles from '../../actions-control.module.css'; export const DownloadButton = () => { const { id = '0', + dataTestId, downloadLink, download, disableButtons, @@ -35,6 +37,7 @@ export const DownloadButton = () => { download={download} target={target} onClick={handleDownload} + dataTestId={getDataTestId(dataTestId, 'download-button')} /> ); }; diff --git a/packages/file-upload-item/src/components/actions-control/components/restore-button/restore-button.tsx b/packages/file-upload-item/src/components/actions-control/components/restore-button/restore-button.tsx index bb1f38ceea..85fb045b87 100644 --- a/packages/file-upload-item/src/components/actions-control/components/restore-button/restore-button.tsx +++ b/packages/file-upload-item/src/components/actions-control/components/restore-button/restore-button.tsx @@ -1,6 +1,7 @@ import React, { useContext } from 'react'; import { IconButton } from '@alfalab/core-components-icon-button'; +import { getDataTestId } from '@alfalab/core-components-shared'; import ArrowsCwCompactMIcon from '@alfalab/icons-glyph/ArrowsCwCompactMIcon'; import { FileUploadItemContext } from '../../../../context/file-upload-item-context'; @@ -8,7 +9,7 @@ import { FileUploadItemContext } from '../../../../context/file-upload-item-cont import styles from '../../actions-control.module.css'; export const RestoreButton = () => { - const { id = '0', disableButtons, onRestore } = useContext(FileUploadItemContext); + const { id = '0', dataTestId, disableButtons, onRestore } = useContext(FileUploadItemContext); const handleRestore = () => { if (onRestore) { @@ -24,6 +25,7 @@ export const RestoreButton = () => { icon={} disabled={disableButtons} onClick={handleRestore} + dataTestId={getDataTestId(dataTestId, 'restore-button')} /> ); }; diff --git a/packages/file-upload-item/src/context/file-upload-item-context.ts b/packages/file-upload-item/src/context/file-upload-item-context.ts index 5147b0ac16..77a31a9723 100644 --- a/packages/file-upload-item/src/context/file-upload-item-context.ts +++ b/packages/file-upload-item/src/context/file-upload-item-context.ts @@ -37,6 +37,7 @@ type TFileUploadItemContext = { backgroundColor?: SuperEllipseProps['backgroundColor']; actionsPresent?: boolean; setActionsPresent?: (present: boolean) => void; + dataTestId?: string; }; export const FileUploadItemContext = createContext({ @@ -67,4 +68,5 @@ export const FileUploadItemContext = createContext({ backgroundColor: undefined, actionsPresent: false, setActionsPresent: undefined, + dataTestId: '', });