From ec8465b405b05392e1ecc6b8cc366788d13e2814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A7=D0=B5=D0=BB=D0=BD=D0=BE=D0=BA=D0=BE=D0=B2=D0=B0=20?= =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=D0=B0=20?= =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D0=B5=D0=B2=D0=BD=D0=B0?= Date: Thu, 15 Jan 2026 15:42:34 +0300 Subject: [PATCH 1/2] feat(file-upload-item): add data-test-id to action buttons --- .changeset/odd-baths-slide.md | 5 +++++ packages/file-upload-item/src/Component.tsx | 1 + .../components/delete-button/delete-button.tsx | 4 +++- .../components/download-button/download-button.tsx | 3 +++ .../components/restore-button/restore-button.tsx | 4 +++- .../file-upload-item/src/context/file-upload-item-context.ts | 2 ++ 6 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .changeset/odd-baths-slide.md diff --git a/.changeset/odd-baths-slide.md b/.changeset/odd-baths-slide.md new file mode 100644 index 0000000000..fca1c8b275 --- /dev/null +++ b/.changeset/odd-baths-slide.md @@ -0,0 +1,5 @@ +--- +'@alfalab/core-components-file-upload-item': 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: '', }); From d2b8b76a54a73ed875991b8c99b8171339f6123b Mon Sep 17 00:00:00 2001 From: Vadim Kalushko Date: Fri, 16 Jan 2026 10:38:58 +0300 Subject: [PATCH 2/2] Update odd-baths-slide.md --- .changeset/odd-baths-slide.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.changeset/odd-baths-slide.md b/.changeset/odd-baths-slide.md index fca1c8b275..9a7437f872 100644 --- a/.changeset/odd-baths-slide.md +++ b/.changeset/odd-baths-slide.md @@ -1,5 +1,6 @@ --- '@alfalab/core-components-file-upload-item': patch +'@alfalab/core-components': patch --- -Добавлен атрибут `data-test-id` к кнопкам с действиями +- Добавлен атрибут `data-test-id` к кнопкам с действиями