diff --git a/src/modules/file/file.usecase.spec.ts b/src/modules/file/file.usecase.spec.ts index ae9d77ae..f6083bdc 100644 --- a/src/modules/file/file.usecase.spec.ts +++ b/src/modules/file/file.usecase.spec.ts @@ -519,7 +519,7 @@ describe('FileUseCases', () => { jest.spyOn(fileRepository, 'findByUuid').mockResolvedValueOnce(file); jest - .spyOn(folderUseCases, 'getFolderByUuidAndUserAndNotDeleted') + .spyOn(folderUseCases, 'getFolderByUuid') .mockResolvedValueOnce(destinationFolder); jest @@ -573,7 +573,7 @@ describe('FileUseCases', () => { jest.spyOn(fileRepository, 'findByUuid').mockResolvedValueOnce(file); jest - .spyOn(folderUseCases, 'getFolderByUuidAndUserAndNotDeleted') + .spyOn(folderUseCases, 'getFolderByUuid') .mockResolvedValueOnce(mockDestinationFolder); expect( @@ -590,9 +590,7 @@ describe('FileUseCases', () => { it('When a file is moved to a non existent folder, then it should throw a not found error', () => { jest.spyOn(fileRepository, 'findByUuid').mockResolvedValueOnce(file); - jest - .spyOn(folderUseCases, 'getFolderByUuidAndUserAndNotDeleted') - .mockResolvedValueOnce(null); + jest.spyOn(folderUseCases, 'getFolderByUuid').mockResolvedValueOnce(null); expect( service.moveFile(userMocked, file.uuid, destinationFolder.uuid), ).rejects.toThrow(`File can not be moved to ${destinationFolder.uuid}`); diff --git a/src/modules/file/file.usecase.ts b/src/modules/file/file.usecase.ts index d10987f9..66bf555c 100644 --- a/src/modules/file/file.usecase.ts +++ b/src/modules/file/file.usecase.ts @@ -602,11 +602,10 @@ export class FileUseCases { ); } - const destinationFolder = - await this.folderUsecases.getFolderByUuidAndUserAndNotDeleted( - destinationUuid, - user, - ); + const destinationFolder = await this.folderUsecases.getFolderByUuid( + destinationUuid, + user, + ); if (!destinationFolder || destinationFolder.removed === true) { throw new UnprocessableEntityException( `File can not be moved to ${destinationUuid}`, diff --git a/src/modules/folder/folder.controller.spec.ts b/src/modules/folder/folder.controller.spec.ts index e00725a9..008ebd57 100644 --- a/src/modules/folder/folder.controller.spec.ts +++ b/src/modules/folder/folder.controller.spec.ts @@ -321,9 +321,7 @@ describe('FolderController', () => { describe('getFolderContent', () => { it('When folde content is requested and the current folder is not found, then it should throw', async () => { - jest - .spyOn(folderUseCases, 'getFolderByUuidAndUserAndNotDeleted') - .mockResolvedValue(null); + jest.spyOn(folderUseCases, 'getFolderByUuid').mockResolvedValue(null); expect( folderController.getFolderContent(userMocked, v4(), { @@ -354,7 +352,7 @@ describe('FolderController', () => { })); jest - .spyOn(folderUseCases, 'getFolderByUuidAndUserAndNotDeleted') + .spyOn(folderUseCases, 'getFolderByUuid') .mockResolvedValue(currentFolder); jest @@ -486,7 +484,7 @@ describe('FolderController', () => { ]; jest - .spyOn(folderUseCases, 'getFolderByUuidAndUserAndNotDeleted') + .spyOn(folderUseCases, 'getFolderByUuid') .mockResolvedValue(parentFolder); jest .spyOn(fileUseCases, 'searchFilesInFolder') @@ -505,7 +503,7 @@ describe('FolderController', () => { const parentFolder = newFolder({ attributes: { uuid: folderUuid } }); jest - .spyOn(folderUseCases, 'getFolderByUuidAndUserAndNotDeleted') + .spyOn(folderUseCases, 'getFolderByUuid') .mockResolvedValue(parentFolder); jest.spyOn(fileUseCases, 'searchFilesInFolder').mockResolvedValue([]); @@ -519,9 +517,7 @@ describe('FolderController', () => { }); it('When the parent folder does not exist, then it should throw', async () => { - jest - .spyOn(folderUseCases, 'getFolderByUuidAndUserAndNotDeleted') - .mockResolvedValue(null); + jest.spyOn(folderUseCases, 'getFolderByUuid').mockResolvedValue(null); await expect( folderController.checkFilesExistenceInFolder(user, folderUuid, query), diff --git a/src/modules/folder/folder.controller.ts b/src/modules/folder/folder.controller.ts index 4113807e..8577b209 100644 --- a/src/modules/folder/folder.controller.ts +++ b/src/modules/folder/folder.controller.ts @@ -443,11 +443,10 @@ export class FolderController { @Param('uuid') folderUuid: string, @Body() query: CheckFileExistenceInFolderDto, ) { - const parentFolder = - await this.folderUseCases.getFolderByUuidAndUserAndNotDeleted( - folderUuid, - user, - ); + const parentFolder = await this.folderUseCases.getFolderByUuid( + folderUuid, + user, + ); if (!parentFolder) { throw new InvalidParentFolderException('Parent folder not valid!'); @@ -488,7 +487,7 @@ export class FolderController { @Query() query: BasicPaginationDto, ) { const [currentFolder, childrenFolders, files] = await Promise.all([ - this.folderUseCases.getFolderByUuidAndUserAndNotDeleted(folderUuid, user), + this.folderUseCases.getFolderByUuid(folderUuid, user), this.folderUseCases.getFolders( user.id, { diff --git a/src/modules/folder/folder.usecase.ts b/src/modules/folder/folder.usecase.ts index 4544ca55..e5ecc28a 100644 --- a/src/modules/folder/folder.usecase.ts +++ b/src/modules/folder/folder.usecase.ts @@ -93,7 +93,7 @@ export class FolderUseCases { return folder; } - async getFolderByUuidAndUserAndNotDeleted( + async getFolderByUuid( folderUuid: FolderAttributes['uuid'], user: User, ): Promise { @@ -800,10 +800,7 @@ export class FolderUseCases { ); } - const destinationFolder = await this.getFolderByUuidAndUserAndNotDeleted( - destinationUuid, - user, - ); + const destinationFolder = await this.getFolderByUuid(destinationUuid, user); if (destinationFolder.removed === true) { throw new UnprocessableEntityException( `Folder can not be moved to ${destinationUuid}`,