Skip to content

Commit

Permalink
Change the max files that can be bulk deleted.
Browse files Browse the repository at this point in the history
  • Loading branch information
adcoelho committed Jun 28, 2023
1 parent 5c0db11 commit c6a8d3b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/cases/common/constants/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export const FILE_ATTACHMENT_TYPE = '.files';
export const MAX_FILE_SIZE = 100 * 1024 * 1024; // 100 MiB
export const MAX_IMAGE_FILE_SIZE = 10 * 1024 * 1024; // 10 MiB
export const MAX_FILES_PER_CASE = 100;
export const MAX_DELETE_FILES = 50;
export const MAX_DELETE_FILES = 10;
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,32 @@ import { loggerMock } from '@kbn/logging-mocks';
import pReflect from 'p-reflect';
import type { File } from '@kbn/files-plugin/common';
import { FileNotFoundError } from '@kbn/files-plugin/server/file_service/errors';
import { retrieveFilesIgnoringNotFound } from './bulk_delete';
import { bulkDeleteFileAttachments, retrieveFilesIgnoringNotFound } from './bulk_delete';
import { MAX_DELETE_FILES } from '../../../common/constants';
import { createCasesClientMock, createCasesClientMockArgs } from '../mocks';

describe('bulk_delete', () => {
describe('bulkDeleteFileAttachments', () => {
describe('errors', () => {
const casesClient = createCasesClientMock();
const clientArgs = createCasesClientMockArgs();

beforeEach(() => {
jest.clearAllMocks();
});

it(`throws 400 when trying to delete more than ${MAX_DELETE_FILES} files at a time`, async () => {
const fileIds = new Array(MAX_DELETE_FILES + 1).fill('fake-ids');

await expect(
bulkDeleteFileAttachments({ caseId: 'mock-id-4', fileIds }, clientArgs, casesClient)
).rejects.toThrowError(
'Failed to delete file attachments for case: mock-id-4: Error: array must be of length <= 10'
);
});
});
});

describe('retrieveFilesIgnoringNotFound', () => {
const mockLogger = loggerMock.create();

Expand Down

0 comments on commit c6a8d3b

Please sign in to comment.