diff --git a/x-pack/plugins/cases/public/components/files/file_delete_button_icon.test.tsx b/x-pack/plugins/cases/public/components/files/file_delete_button_icon.test.tsx
index 7d24f2bd5dfe2..5629ae4fcf6c0 100644
--- a/x-pack/plugins/cases/public/components/files/file_delete_button_icon.test.tsx
+++ b/x-pack/plugins/cases/public/components/files/file_delete_button_icon.test.tsx
@@ -49,7 +49,7 @@ describe('FileDeleteButtonIcon', () => {
userEvent.click(deleteButton);
- expect(await screen.findAllByTestId('property-actions-confirm-modal'));
+ expect(await screen.findByTestId('property-actions-confirm-modal')).toBeInTheDocument();
});
it('clicking delete button in the confirmation modal calls deleteFileAttachment with proper params', async () => {
@@ -61,7 +61,7 @@ describe('FileDeleteButtonIcon', () => {
userEvent.click(deleteButton);
- expect(await screen.findAllByTestId('property-actions-confirm-modal'));
+ expect(await screen.findByTestId('property-actions-confirm-modal')).toBeInTheDocument();
userEvent.click(await screen.findByTestId('confirmModalConfirmButton'));
diff --git a/x-pack/plugins/cases/public/components/files/file_type.test.tsx b/x-pack/plugins/cases/public/components/files/file_type.test.tsx
index bc8de8d43d40f..28ff713b4a63a 100644
--- a/x-pack/plugins/cases/public/components/files/file_type.test.tsx
+++ b/x-pack/plugins/cases/public/components/files/file_type.test.tsx
@@ -15,6 +15,7 @@ import { FILE_ATTACHMENT_TYPE } from '../../../common/api';
import { createAppMockRenderer } from '../../common/mock';
import { basicCase, basicFileMock } from '../../containers/mock';
import { getFileType } from './file_type';
+import userEvent from '@testing-library/user-event';
describe('getFileType', () => {
const fileType = getFileType();
@@ -62,6 +63,30 @@ describe('getFileType', () => {
expect(await screen.findByTestId('cases-files-download-button')).toBeInTheDocument();
});
+ it('actions renders a delete button', async () => {
+ appMockRender = createAppMockRenderer();
+
+ // @ts-ignore
+ appMockRender.render(fileType.getAttachmentViewObject({ ...attachmentViewProps }).actions);
+
+ expect(await screen.findByTestId('cases-files-delete-button')).toBeInTheDocument();
+ });
+
+ it('clicking the delete button in actions opens deletion modal', async () => {
+ appMockRender = createAppMockRenderer();
+
+ // @ts-ignore
+ appMockRender.render(fileType.getAttachmentViewObject({ ...attachmentViewProps }).actions);
+
+ const deleteButton = await screen.findByTestId('cases-files-delete-button');
+
+ expect(deleteButton).toBeInTheDocument();
+
+ userEvent.click(deleteButton);
+
+ expect(await screen.findByTestId('property-actions-confirm-modal')).toBeInTheDocument();
+ });
+
it('empty externalReferenceMetadata returns blank FileAttachmentViewObject', () => {
expect(
fileType.getAttachmentViewObject({ ...attachmentViewProps, externalReferenceMetadata: {} })
diff --git a/x-pack/plugins/cases/public/components/files/files_table.test.tsx b/x-pack/plugins/cases/public/components/files/files_table.test.tsx
index 144d48a688992..5f877db3df9b4 100644
--- a/x-pack/plugins/cases/public/components/files/files_table.test.tsx
+++ b/x-pack/plugins/cases/public/components/files/files_table.test.tsx
@@ -131,6 +131,36 @@ describe('FilesTable', () => {
expect(await screen.findByTestId('cases-files-download-button')).toBeInTheDocument();
});
+ it('delete button renders correctly', async () => {
+ appMockRender.render();
+
+ expect(mockedFilesClient.getDownloadHref).toBeCalledTimes(1);
+ expect(mockedFilesClient.getDownloadHref).toHaveBeenCalledWith({
+ fileKind: constructFileKindIdByOwner(mockedTestProvidersOwner[0]),
+ id: basicFileMock.id,
+ });
+
+ expect(await screen.findByTestId('cases-files-delete-button')).toBeInTheDocument();
+ });
+
+ it('clicking delete button opens deletion modal', async () => {
+ appMockRender.render();
+
+ expect(mockedFilesClient.getDownloadHref).toBeCalledTimes(1);
+ expect(mockedFilesClient.getDownloadHref).toHaveBeenCalledWith({
+ fileKind: constructFileKindIdByOwner(mockedTestProvidersOwner[0]),
+ id: basicFileMock.id,
+ });
+
+ const deleteButton = await screen.findByTestId('cases-files-delete-button');
+
+ expect(deleteButton).toBeInTheDocument();
+
+ userEvent.click(deleteButton);
+
+ expect(await screen.findByTestId('property-actions-confirm-modal')).toBeInTheDocument();
+ });
+
it('go to next page calls onTableChange with correct values', async () => {
const mockPagination = { pageIndex: 0, pageSize: 1, totalItemCount: 2 };