diff --git a/src/files/domain/repositories/FileRepository.ts b/src/files/domain/repositories/FileRepository.ts index e34a01bea..158806a33 100644 --- a/src/files/domain/repositories/FileRepository.ts +++ b/src/files/domain/repositories/FileRepository.ts @@ -12,9 +12,9 @@ export interface FileRepository { paginationInfo?: FilePaginationInfo, criteria?: FileCriteria ) => Promise - getCountInfoByDatasetPersistentId: ( + getFilesCountInfoByDatasetPersistentId: ( datasetPersistentId: string, datasetVersion: DatasetVersion ) => Promise - getFileUserPermissionsById: (id: number) => Promise + getUserPermissionsById: (id: number) => Promise } diff --git a/src/files/domain/useCases/checkFileDownloadPermission.ts b/src/files/domain/useCases/checkFileDownloadPermission.ts index 9176c6a5b..974f0dd5b 100644 --- a/src/files/domain/useCases/checkFileDownloadPermission.ts +++ b/src/files/domain/useCases/checkFileDownloadPermission.ts @@ -6,7 +6,7 @@ export async function checkFileDownloadPermission( file: File ): Promise { if (file.version.publishingStatus === FilePublishingStatus.DEACCESSIONED) { - return fileRepository.getFileUserPermissionsById(file.id).then((permissions) => { + return fileRepository.getUserPermissionsById(file.id).then((permissions) => { return permissions.canEditDataset }) } @@ -16,7 +16,7 @@ export async function checkFileDownloadPermission( return true } - return fileRepository.getFileUserPermissionsById(file.id).then((permissions) => { + return fileRepository.getUserPermissionsById(file.id).then((permissions) => { return permissions.canDownloadFile }) } diff --git a/src/files/domain/useCases/checkFileEditDatasetPermission.ts b/src/files/domain/useCases/checkFileEditDatasetPermission.ts index d7ea9d5fd..a2a69206f 100644 --- a/src/files/domain/useCases/checkFileEditDatasetPermission.ts +++ b/src/files/domain/useCases/checkFileEditDatasetPermission.ts @@ -5,7 +5,7 @@ export async function checkFileEditDatasetPermission( fileRepository: FileRepository, file: File ): Promise { - return fileRepository.getFileUserPermissionsById(file.id).then((permissions) => { + return fileRepository.getUserPermissionsById(file.id).then((permissions) => { return permissions.canEditDataset }) } diff --git a/src/files/domain/useCases/getFilesCountInfoByDatasetPersistentId.ts b/src/files/domain/useCases/getFilesCountInfoByDatasetPersistentId.ts index 6305f588c..518897809 100644 --- a/src/files/domain/useCases/getFilesCountInfoByDatasetPersistentId.ts +++ b/src/files/domain/useCases/getFilesCountInfoByDatasetPersistentId.ts @@ -8,7 +8,7 @@ export async function getFilesCountInfoByDatasetPersistentId( datasetVersion: DatasetVersion ): Promise { return fileRepository - .getCountInfoByDatasetPersistentId(datasetPersistentId, datasetVersion) + .getFilesCountInfoByDatasetPersistentId(datasetPersistentId, datasetVersion) .catch((error: Error) => { throw new Error(error.message) }) diff --git a/src/files/infrastructure/FileJSDataverseRepository.ts b/src/files/infrastructure/FileJSDataverseRepository.ts index 4cfa5db24..d9100cc99 100644 --- a/src/files/infrastructure/FileJSDataverseRepository.ts +++ b/src/files/infrastructure/FileJSDataverseRepository.ts @@ -63,7 +63,7 @@ export class FileJSDataverseRepository implements FileRepository { return Promise.resolve(0) } - getCountInfoByDatasetPersistentId( + getFilesCountInfoByDatasetPersistentId( // eslint-disable-next-line unused-imports/no-unused-vars datasetPersistentId: string, // eslint-disable-next-line unused-imports/no-unused-vars @@ -77,7 +77,7 @@ export class FileJSDataverseRepository implements FileRepository { }) } - getFileUserPermissionsById(id: number): Promise { + getUserPermissionsById(id: number): Promise { return getFileUserPermissions .execute(id) .then((jsFileUserPermissions) => diff --git a/src/stories/files/FileMockLoadingRepository.ts b/src/stories/files/FileMockLoadingRepository.ts index 6177273f7..6c36865db 100644 --- a/src/stories/files/FileMockLoadingRepository.ts +++ b/src/stories/files/FileMockLoadingRepository.ts @@ -19,7 +19,7 @@ export class FileMockLoadingRepository implements FileRepository { }) } - getCountInfoByDatasetPersistentId( + getFilesCountInfoByDatasetPersistentId( // eslint-disable-next-line unused-imports/no-unused-vars datasetPersistentId: string, // eslint-disable-next-line unused-imports/no-unused-vars @@ -32,7 +32,7 @@ export class FileMockLoadingRepository implements FileRepository { }) } // eslint-disable-next-line unused-imports/no-unused-vars - getFileUserPermissionsById(id: number): Promise { + getUserPermissionsById(id: number): Promise { return new Promise((resolve) => { setTimeout(() => { resolve(FileUserPermissionsMother.create()) diff --git a/src/stories/files/FileMockNoDataRepository.ts b/src/stories/files/FileMockNoDataRepository.ts index b8412c213..9f8b77f50 100644 --- a/src/stories/files/FileMockNoDataRepository.ts +++ b/src/stories/files/FileMockNoDataRepository.ts @@ -20,7 +20,7 @@ export class FileMockNoDataRepository implements FileRepository { }) } - getCountInfoByDatasetPersistentId( + getFilesCountInfoByDatasetPersistentId( // eslint-disable-next-line unused-imports/no-unused-vars datasetPersistentId: string, // eslint-disable-next-line unused-imports/no-unused-vars @@ -33,7 +33,7 @@ export class FileMockNoDataRepository implements FileRepository { }) } // eslint-disable-next-line unused-imports/no-unused-vars - getFileUserPermissionsById(id: number): Promise { + getUserPermissionsById(id: number): Promise { return new Promise((resolve) => { setTimeout(() => { resolve(FileUserPermissionsMother.create()) diff --git a/src/stories/files/FileMockNoFiltersRepository.ts b/src/stories/files/FileMockNoFiltersRepository.ts index 60a496144..203366df9 100644 --- a/src/stories/files/FileMockNoFiltersRepository.ts +++ b/src/stories/files/FileMockNoFiltersRepository.ts @@ -21,7 +21,7 @@ export class FileMockNoFiltersRepository implements FileRepository { }) } - getCountInfoByDatasetPersistentId( + getFilesCountInfoByDatasetPersistentId( // eslint-disable-next-line unused-imports/no-unused-vars datasetPersistentId: string, // eslint-disable-next-line unused-imports/no-unused-vars @@ -34,7 +34,7 @@ export class FileMockNoFiltersRepository implements FileRepository { }) } // eslint-disable-next-line unused-imports/no-unused-vars - getFileUserPermissionsById(id: number): Promise { + getUserPermissionsById(id: number): Promise { return new Promise((resolve) => { setTimeout(() => { resolve(FileUserPermissionsMother.create()) diff --git a/src/stories/files/FileMockRepository.ts b/src/stories/files/FileMockRepository.ts index 53706bb0d..f9209ecb9 100644 --- a/src/stories/files/FileMockRepository.ts +++ b/src/stories/files/FileMockRepository.ts @@ -22,7 +22,7 @@ export class FileMockRepository implements FileRepository { }) } - getCountInfoByDatasetPersistentId( + getFilesCountInfoByDatasetPersistentId( // eslint-disable-next-line unused-imports/no-unused-vars datasetPersistentId: string, // eslint-disable-next-line unused-imports/no-unused-vars @@ -35,7 +35,7 @@ export class FileMockRepository implements FileRepository { }) } // eslint-disable-next-line unused-imports/no-unused-vars - getFileUserPermissionsById(id: number): Promise { + getUserPermissionsById(id: number): Promise { return new Promise((resolve) => { setTimeout(() => { resolve(FileUserPermissionsMother.create()) diff --git a/src/stories/files/FileWithDeniedPermissionsRepository.ts b/src/stories/files/FileWithDeniedPermissionsRepository.ts index 5c87a926d..4385df633 100644 --- a/src/stories/files/FileWithDeniedPermissionsRepository.ts +++ b/src/stories/files/FileWithDeniedPermissionsRepository.ts @@ -8,7 +8,7 @@ export class FileWithDeniedPermissionsRepository implements FileRepository { // eslint-disable-next-line unused-imports/no-unused-vars - getFileUserPermissionsById(id: number): Promise { + getUserPermissionsById(id: number): Promise { return new Promise((resolve) => { setTimeout(() => { resolve(FileUserPermissionsMother.createWithDeniedPermissions()) diff --git a/src/stories/files/FileWithGrantedPermissionsRepository.ts b/src/stories/files/FileWithGrantedPermissionsRepository.ts index 5eb6475f5..c3e66e911 100644 --- a/src/stories/files/FileWithGrantedPermissionsRepository.ts +++ b/src/stories/files/FileWithGrantedPermissionsRepository.ts @@ -8,7 +8,7 @@ export class FileWithGrantedPermissionsRepository implements FileRepository { // eslint-disable-next-line unused-imports/no-unused-vars - getFileUserPermissionsById(id: number): Promise { + getUserPermissionsById(id: number): Promise { return new Promise((resolve) => { setTimeout(() => { resolve(FileUserPermissionsMother.createWithGrantedPermissions()) diff --git a/tests/component/sections/dataset/dataset-files/DatasetFiles.spec.tsx b/tests/component/sections/dataset/dataset-files/DatasetFiles.spec.tsx index 5b17d177d..9fa66e39e 100644 --- a/tests/component/sections/dataset/dataset-files/DatasetFiles.spec.tsx +++ b/tests/component/sections/dataset/dataset-files/DatasetFiles.spec.tsx @@ -42,7 +42,7 @@ const filePaginationInfo = new FilePaginationInfo(1, 10, 200) describe('DatasetFiles', () => { beforeEach(() => { fileRepository.getAllByDatasetPersistentId = cy.stub().resolves(testFiles) - fileRepository.getCountInfoByDatasetPersistentId = cy.stub().resolves(testFilesCountInfo) + fileRepository.getFilesCountInfoByDatasetPersistentId = cy.stub().resolves(testFilesCountInfo) }) it('renders the files table', () => { @@ -180,7 +180,7 @@ describe('DatasetFiles', () => { datasetVersion ) - cy.wrap(fileRepository.getCountInfoByDatasetPersistentId).should( + cy.wrap(fileRepository.getFilesCountInfoByDatasetPersistentId).should( 'be.calledWith', datasetPersistentId, datasetVersion diff --git a/tests/component/sections/dataset/dataset-files/files-table/file-actions/FileActionsHeader.spec.tsx b/tests/component/sections/dataset/dataset-files/files-table/file-actions/FileActionsHeader.spec.tsx index 9d22c9601..335b16c43 100644 --- a/tests/component/sections/dataset/dataset-files/files-table/file-actions/FileActionsHeader.spec.tsx +++ b/tests/component/sections/dataset/dataset-files/files-table/file-actions/FileActionsHeader.spec.tsx @@ -15,7 +15,7 @@ describe('FileActionsHeader', () => { userRepository.removeAuthenticated = cy.stub().resolves() const files = FileMother.createMany(2) const fileRepository: FileRepository = {} as FileRepository - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: files[0].id, canEditDataset: true diff --git a/tests/component/sections/dataset/dataset-files/files-table/file-actions/edit-files-menu/EditFilesMenu.spec.tsx b/tests/component/sections/dataset/dataset-files/files-table/file-actions/edit-files-menu/EditFilesMenu.spec.tsx index dd7aac757..db841720a 100644 --- a/tests/component/sections/dataset/dataset-files/files-table/file-actions/edit-files-menu/EditFilesMenu.spec.tsx +++ b/tests/component/sections/dataset/dataset-files/files-table/file-actions/edit-files-menu/EditFilesMenu.spec.tsx @@ -15,7 +15,7 @@ describe('EditFilesMenu', () => { beforeEach(() => { userRepository.getAuthenticated = cy.stub().resolves(user) userRepository.removeAuthenticated = cy.stub().resolves() - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: files[0].id, canEditDataset: true @@ -74,7 +74,7 @@ describe('EditFilesMenu', () => { }) it.skip('does not render the Edit Files menu when the user does not have update dataset permissions', () => { - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: files[0].id, canEditDataset: false diff --git a/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/FileActionButtons.spec.tsx b/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/FileActionButtons.spec.tsx index beef29fba..3451e1151 100644 --- a/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/FileActionButtons.spec.tsx +++ b/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/FileActionButtons.spec.tsx @@ -22,7 +22,7 @@ describe('FileActionButtons', () => { userRepository.getAuthenticated = cy.stub().resolves(user) userRepository.removeAuthenticated = cy.stub().resolves() const fileRepository: FileRepository = {} as FileRepository - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: file.id, canEditDataset: true diff --git a/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/access-file-menu/AccessStatus.spec.tsx b/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/access-file-menu/AccessStatus.spec.tsx index 79e591067..c1ba17998 100644 --- a/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/access-file-menu/AccessStatus.spec.tsx +++ b/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/access-file-menu/AccessStatus.spec.tsx @@ -25,7 +25,7 @@ describe('AccessStatus', () => { it('renders the access status restricted with access', () => { const fileRestrictedWithAccess = FileMother.createWithRestrictedAccessWithAccessGranted() const fileRepository: FileRepository = {} as FileRepository - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: fileRestrictedWithAccess.id, canDownloadFile: true @@ -47,7 +47,7 @@ describe('AccessStatus', () => { it('renders the access status embargoed', () => { const fileRestrictedWithAccess = FileMother.createWithRestrictedAccessWithAccessGranted() const fileRepository: FileRepository = {} as FileRepository - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: fileRestrictedWithAccess.id, canDownloadFile: true @@ -75,7 +75,7 @@ describe('AccessStatus', () => { it('renders the access status embargoed restricted with access', () => { const fileRestrictedWithAccess = FileMother.createWithRestrictedAccessWithAccessGranted() const fileRepository: FileRepository = {} as FileRepository - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: fileRestrictedWithAccess.id, canDownloadFile: true diff --git a/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/access-file-menu/RequestAccessOption.spec.tsx b/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/access-file-menu/RequestAccessOption.spec.tsx index dbeaec172..edf2eb32d 100644 --- a/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/access-file-menu/RequestAccessOption.spec.tsx +++ b/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/access-file-menu/RequestAccessOption.spec.tsx @@ -69,7 +69,7 @@ describe('RequestAccessOption', () => { it('does not render the request access button when the file status is public', () => { const filePublic = FileMother.createWithPublicAccess() const fileRepository: FileRepository = {} as FileRepository - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: filePublic.id, canDownloadFile: true @@ -96,7 +96,7 @@ describe('RequestAccessOption', () => { it('does not render the request access button when the file status is restricted with access granted', () => { const fileRestrictedWithAccess = FileMother.createWithRestrictedAccessWithAccessGranted() const fileRepository: FileRepository = {} as FileRepository - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: fileRestrictedWithAccess.id, canDownloadFile: true diff --git a/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/file-options-menu/FileOptionsMenu.spec.tsx b/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/file-options-menu/FileOptionsMenu.spec.tsx index f4b961ddf..e3a0928ef 100644 --- a/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/file-options-menu/FileOptionsMenu.spec.tsx +++ b/tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/file-options-menu/FileOptionsMenu.spec.tsx @@ -15,7 +15,7 @@ describe('FileOptionsMenu', () => { beforeEach(() => { userRepository.getAuthenticated = cy.stub().resolves(user) userRepository.removeAuthenticated = cy.stub().resolves() - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: file.id, canEditDataset: true @@ -71,7 +71,7 @@ describe('FileOptionsMenu', () => { }) it('does not render is the user do not have permissions to update the dataset', () => { - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: file.id, canEditDataset: false diff --git a/tests/component/sections/dataset/dataset-files/files-table/files-info/file-info-cell/file-info-data/file-thumbnail/FileThumbnail.spec.tsx b/tests/component/sections/dataset/dataset-files/files-table/files-info/file-info-cell/file-info-data/file-thumbnail/FileThumbnail.spec.tsx index 3c8949ec2..29a269c67 100644 --- a/tests/component/sections/dataset/dataset-files/files-table/files-info/file-info-cell/file-info-data/file-thumbnail/FileThumbnail.spec.tsx +++ b/tests/component/sections/dataset/dataset-files/files-table/files-info/file-info-cell/file-info-data/file-thumbnail/FileThumbnail.spec.tsx @@ -8,7 +8,7 @@ const fileRepository: FileRepository = {} as FileRepository describe('FileThumbnail', () => { it('renders FileThumbnailPreviewImage when thumbnail is provided and file can be downloaded', () => { const file = FileMother.createWithThumbnail() - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: file.id, canDownloadFile: true @@ -40,7 +40,7 @@ describe('FileThumbnail', () => { it('renders FileThumbnailPreviewImage when thumbnail is provided with unlocked icon if restricted with access', () => { const file = FileMother.createWithThumbnailRestrictedWithAccessGranted() - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: file.id, canDownloadFile: true @@ -101,7 +101,7 @@ describe('FileThumbnail', () => { it('renders FileThumbnailIcon when thumbnail is not provided with unlock icon when restricted with access', () => { const file = FileMother.createWithRestrictedAccessWithAccessGranted() - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( FileUserPermissionsMother.create({ fileId: file.id, canDownloadFile: true diff --git a/tests/component/sections/dataset/dataset-files/useFiles.spec.tsx b/tests/component/sections/dataset/dataset-files/useFiles.spec.tsx index 90284be51..dbc7c07ea 100644 --- a/tests/component/sections/dataset/dataset-files/useFiles.spec.tsx +++ b/tests/component/sections/dataset/dataset-files/useFiles.spec.tsx @@ -51,8 +51,8 @@ const FilesTableTestComponent = ({ datasetPersistentId }: { datasetPersistentId: describe('useFiles', () => { beforeEach(() => { fileRepository.getAllByDatasetPersistentId = cy.stub().resolves(files) - fileRepository.getCountInfoByDatasetPersistentId = cy.stub().resolves(filesCountInfo) - fileRepository.getFileUserPermissionsById = cy + fileRepository.getFilesCountInfoByDatasetPersistentId = cy.stub().resolves(filesCountInfo) + fileRepository.getUserPermissionsById = cy .stub() .resolves(FileUserPermissionsMother.create({ fileId: files[0].id })) }) @@ -80,7 +80,7 @@ describe('useFiles', () => { cy.customMount() cy.findByText('Loading...').should('exist') - cy.wrap(fileRepository.getCountInfoByDatasetPersistentId).should( + cy.wrap(fileRepository.getFilesCountInfoByDatasetPersistentId).should( 'be.calledOnceWith', 'persistentId' ) @@ -98,7 +98,7 @@ describe('useFiles', () => { it('calls the file repository to get the permissions before removing the loading', () => { const files = FileMother.createMany(5) fileRepository.getAllByDatasetPersistentId = cy.stub().resolves(files) - fileRepository.getFileUserPermissionsById = cy.stub().resolves( + fileRepository.getUserPermissionsById = cy.stub().resolves( new Promise((resolve) => { setTimeout(() => { resolve(FileUserPermissionsMother.create({ fileId: files[0].id })) @@ -116,14 +116,14 @@ describe('useFiles', () => { cy.wrap(fileRepository.getAllByDatasetPersistentId).should('be.calledOnceWith', 'persistentId') cy.findByText('Loading...').should('exist') - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledWith', files[0].id) + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledWith', files[0].id) cy.findByText('Loading...').should('exist') cy.findByText('Files count: 100').should('exist') }) it('calls the file repository to get the files only if files count info is greater than 0', () => { - fileRepository.getCountInfoByDatasetPersistentId = cy + fileRepository.getFilesCountInfoByDatasetPersistentId = cy .stub() .resolves(FilesCountInfoMother.create({ total: 0 })) diff --git a/tests/component/sections/file/file-permissions/useFileDownloadPermission.spec.tsx b/tests/component/sections/file/file-permissions/useFileDownloadPermission.spec.tsx index 90e465f6d..9492c88d3 100644 --- a/tests/component/sections/file/file-permissions/useFileDownloadPermission.spec.tsx +++ b/tests/component/sections/file/file-permissions/useFileDownloadPermission.spec.tsx @@ -24,14 +24,14 @@ function TestComponent({ file }: { file: File }) { describe('useFileDownloadPermission', () => { beforeEach(() => { fileRepository.getAllByDatasetPersistentId = cy.stub().resolves([]) - fileRepository.getCountInfoByDatasetPersistentId = cy + fileRepository.getFilesCountInfoByDatasetPersistentId = cy .stub() .resolves(FilesCountInfoMother.create()) }) it('should return file download permission', () => { const file = FileMother.createDeaccessioned() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .resolves(FileUserPermissionsMother.create({ fileId: file.id, canEditDataset: true })) @@ -41,13 +41,13 @@ describe('useFileDownloadPermission', () => { ) - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledWith', file.id) + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledWith', file.id) cy.findByText('Has download permission').should('exist') }) it('should return false for file download permission if there is an error', () => { const file = FileMother.createDeaccessioned() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .rejects(new Error('Error getting file user permissions')) @@ -57,7 +57,7 @@ describe('useFileDownloadPermission', () => { ) - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledWith', file.id) + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledWith', file.id) cy.findByText('Does not have download permission').should('exist') }) }) diff --git a/tests/component/sections/file/file-permissions/useFileEditDatasetPermission.spec.tsx b/tests/component/sections/file/file-permissions/useFileEditDatasetPermission.spec.tsx index 870dc4ef1..cebdd7865 100644 --- a/tests/component/sections/file/file-permissions/useFileEditDatasetPermission.spec.tsx +++ b/tests/component/sections/file/file-permissions/useFileEditDatasetPermission.spec.tsx @@ -24,14 +24,14 @@ function TestComponent({ file }: { file: File }) { describe('useFileEditDatasetPermission', () => { beforeEach(() => { fileRepository.getAllByDatasetPersistentId = cy.stub().resolves([]) - fileRepository.getCountInfoByDatasetPersistentId = cy + fileRepository.getFilesCountInfoByDatasetPersistentId = cy .stub() .resolves(FilesCountInfoMother.create()) }) it('should return edit dataset permission', () => { const file = FileMother.createDefault() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .resolves(FileUserPermissionsMother.create({ fileId: file.id, canEditDataset: true })) @@ -41,13 +41,13 @@ describe('useFileEditDatasetPermission', () => { ) - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledWith', file.id) + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledWith', file.id) cy.findByText('Has edit dataset permission').should('exist') }) it('should return false for edit dataset permission if there is an error', () => { const file = FileMother.createDefault() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .rejects(new Error('Error getting file user permissions')) @@ -57,7 +57,7 @@ describe('useFileEditDatasetPermission', () => { ) - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledWith', file.id) + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledWith', file.id) cy.findByText('Does not have edit dataset permission').should('exist') }) }) diff --git a/tests/component/sections/file/file-permissions/useFilePermissions.spec.tsx b/tests/component/sections/file/file-permissions/useFilePermissions.spec.tsx index 7f2d2b9f1..127ae2f9b 100644 --- a/tests/component/sections/file/file-permissions/useFilePermissions.spec.tsx +++ b/tests/component/sections/file/file-permissions/useFilePermissions.spec.tsx @@ -79,7 +79,7 @@ function TestComponent({ file, permission }: { file: File; permission: FilePermi describe('useFilePermissions', () => { beforeEach(() => { fileRepository.getAllByDatasetPersistentId = cy.stub().resolves([]) - fileRepository.getCountInfoByDatasetPersistentId = cy + fileRepository.getFilesCountInfoByDatasetPersistentId = cy .stub() .resolves(FilesCountInfoMother.create()) }) @@ -87,7 +87,7 @@ describe('useFilePermissions', () => { describe('Download permission', () => { it('should not call getFileUserPermissionsById when the file is not deaccessioned nor restricted nor embargoed', () => { const file = FileMother.createDefault() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .resolves(FileUserPermissionsMother.create({ fileId: file.id })) @@ -96,13 +96,13 @@ describe('useFilePermissions', () => { ) - cy.wrap(fileRepository.getFileUserPermissionsById).should('not.be.called') + cy.wrap(fileRepository.getUserPermissionsById).should('not.be.called') cy.findByText('Has file permission').should('exist') }) it('should call getFileUserPermissionsById when the file is deaccessioned', () => { const file = FileMother.createDeaccessioned() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .resolves(FileUserPermissionsMother.create({ fileId: file.id, canEditDataset: true })) @@ -112,13 +112,13 @@ describe('useFilePermissions', () => { ) - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledWith', file.id) + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledWith', file.id) cy.findByText('Has file permission').should('exist') }) it('should call getFileUserPermissionsById when the file is restricted', () => { const file = FileMother.createWithRestrictedAccess() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .resolves(FileUserPermissionsMother.create({ fileId: file.id, canDownloadFile: true })) cy.mount( @@ -127,13 +127,13 @@ describe('useFilePermissions', () => { ) - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledWith', file.id) + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledWith', file.id) cy.findByText('Has file permission').should('exist') }) it('should call getFileUserPermissionsById when the file is public but latest version is restricted', () => { const file = FileMother.createWithPublicAccessButLatestVersionRestricted() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .resolves(FileUserPermissionsMother.create({ fileId: file.id, canDownloadFile: true })) cy.mount( @@ -142,13 +142,13 @@ describe('useFilePermissions', () => { ) - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledWith', file.id) + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledWith', file.id) cy.findByText('Has file permission').should('exist') }) it('should call getFileUserPermissionsById when the file is embargoed', () => { const file = FileMother.createWithEmbargo() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .resolves(FileUserPermissionsMother.create({ fileId: file.id, canDownloadFile: true })) cy.mount( @@ -157,13 +157,13 @@ describe('useFilePermissions', () => { ) - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledWith', file.id) + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledWith', file.id) cy.findByText('Has file permission').should('exist') }) it('should return false if there is an error in the use case request', () => { const file = FileMother.createWithEmbargo() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .rejects(new Error('There was an error getting the file user permissions')) cy.mount( @@ -172,13 +172,13 @@ describe('useFilePermissions', () => { ) - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledWith', file.id) + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledWith', file.id) cy.findByText('Does not have file permission').should('exist') }) it('should use the saved state of the permission the second time the file is being consulted', () => { const file = FileMother.createWithRestrictedAccess() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .resolves(FileUserPermissionsMother.create({ fileId: file.id, canDownloadFile: true })) cy.mount( @@ -189,12 +189,12 @@ describe('useFilePermissions', () => { cy.findAllByText('Has file permission').should('exist') cy.findAllByText('Has file permission again').should('exist') - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledOnce') + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledOnce') }) it('should always allow to download if the user is in anonymized view (privateUrl)', () => { const file = FileMother.createWithRestrictedAccess() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .resolves(FileUserPermissionsMother.create({ fileId: file.id, canDownloadFile: false })) @@ -208,7 +208,7 @@ describe('useFilePermissions', () => { ) - cy.wrap(fileRepository.getFileUserPermissionsById).should('not.be.called') + cy.wrap(fileRepository.getUserPermissionsById).should('not.be.called') cy.findAllByText('Has file permission').should('exist') }) }) @@ -216,7 +216,7 @@ describe('useFilePermissions', () => { describe('Edit dataset permission', () => { it('should call getFileUserPermissionsById when asking for edit dataset permission', () => { const file = FileMother.createDefault() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .resolves(FileUserPermissionsMother.create({ fileId: file.id, canEditDataset: true })) @@ -226,13 +226,13 @@ describe('useFilePermissions', () => { ) - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledWith', file.id) + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledWith', file.id) cy.findByText('Has file permission').should('exist') }) it('should return false if there is an error in the use case request', () => { const file = FileMother.createDefault() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .rejects(new Error('There was an error getting the file user permissions')) cy.mount( @@ -241,13 +241,13 @@ describe('useFilePermissions', () => { ) - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledWith', file.id) + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledWith', file.id) cy.findByText('Does not have file permission').should('exist') }) it('should use the saved state of the edit dataset permission the second time the file is being consulted', () => { const file = FileMother.createDefault() - fileRepository.getFileUserPermissionsById = cy + fileRepository.getUserPermissionsById = cy .stub() .resolves(FileUserPermissionsMother.create({ fileId: file.id, canEditDataset: true })) cy.mount( @@ -258,7 +258,7 @@ describe('useFilePermissions', () => { cy.findAllByText('Has file permission').should('exist') cy.findAllByText('Has file permission again').should('exist') - cy.wrap(fileRepository.getFileUserPermissionsById).should('be.calledOnce') + cy.wrap(fileRepository.getUserPermissionsById).should('be.calledOnce') }) }) }) diff --git a/tests/e2e-integration/integration/files/FileJSDataverseRepository.spec.ts b/tests/e2e-integration/integration/files/FileJSDataverseRepository.spec.ts index 31e8d0d38..f4df27cbc 100644 --- a/tests/e2e-integration/integration/files/FileJSDataverseRepository.spec.ts +++ b/tests/e2e-integration/integration/files/FileJSDataverseRepository.spec.ts @@ -420,7 +420,7 @@ describe('File JSDataverse Repository', () => { } await fileRepository - .getFileUserPermissionsById(datasetResponse.files[0].id) + .getUserPermissionsById(datasetResponse.files[0].id) .then((fileUserPermissions) => { expect(fileUserPermissions).to.deep.equal(expectedFileUserPermissions) }) @@ -502,7 +502,7 @@ describe('File JSDataverse Repository', () => { } await fileRepository - .getCountInfoByDatasetPersistentId(dataset.persistentId, dataset.version) + .getFilesCountInfoByDatasetPersistentId(dataset.persistentId, dataset.version) .then((filesCountInfo) => { expect(filesCountInfo).to.deep.equal(expectedFilesCountInfo) })