diff --git a/docs/useCases.md b/docs/useCases.md index 3630da65..6d0e4602 100644 --- a/docs/useCases.md +++ b/docs/useCases.md @@ -287,6 +287,8 @@ The optional `datasetVersionId` parameter can correspond to a numeric version id There is an optional third parameter called `includeDeaccessioned`, which indicates whether to consider deaccessioned versions or not in the dataset search. If not set, the default value is `false`. +There is an optional fourth parameter called `keepRawFields`, which indicates whether or not to keep the metadata fields as they are and avoid the transformation to Markdown. The default value is `false`. + #### Get Dataset By Private URL Token Returns a [Dataset](../src/datasets/domain/models/Dataset.ts) instance, given an associated Private URL Token. @@ -307,6 +309,8 @@ getPrivateUrlDataset.execute(token).then((dataset: Dataset) => { _See [use case](../src/datasets/domain/useCases/GetPrivateUrlDataset.ts)_ definition. +There is an optional second parameter called `keepRawFields`, which indicates whether or not to keep the metadata fields as they are and avoid the transformation to Markdown. The default value is `false`. + #### Get Dataset Citation Text Returns the Dataset citation text. diff --git a/src/datasets/domain/repositories/IDatasetsRepository.ts b/src/datasets/domain/repositories/IDatasetsRepository.ts index 7568d5b8..6d5abf8e 100644 --- a/src/datasets/domain/repositories/IDatasetsRepository.ts +++ b/src/datasets/domain/repositories/IDatasetsRepository.ts @@ -10,7 +10,8 @@ export interface IDatasetsRepository { getDataset( datasetId: number | string, datasetVersionId: string, - includeDeaccessioned: boolean + includeDeaccessioned: boolean, + keepRawFields: boolean ): Promise getDatasetLocks(datasetId: number | string): Promise getDatasetCitation( @@ -18,7 +19,7 @@ export interface IDatasetsRepository { datasetVersionId: string, includeDeaccessioned: boolean ): Promise - getPrivateUrlDataset(token: string): Promise + getPrivateUrlDataset(token: string, keepRawFields: boolean): Promise getAllDatasetPreviews( limit?: number, offset?: number, diff --git a/src/datasets/domain/useCases/GetDataset.ts b/src/datasets/domain/useCases/GetDataset.ts index b133615e..ad9f24b8 100644 --- a/src/datasets/domain/useCases/GetDataset.ts +++ b/src/datasets/domain/useCases/GetDataset.ts @@ -16,17 +16,20 @@ export class GetDataset implements UseCase { * @param {number | string} [datasetId] - The dataset identifier, which can be a string (for persistent identifiers), or a number (for numeric identifiers). * @param {string | DatasetNotNumberedVersion} [datasetVersionId=DatasetNotNumberedVersion.LATEST] - The dataset version identifier, which can be a version-specific numeric string (for example, 1.0) or a DatasetNotNumberedVersion enum value. If this parameter is not set, the default value is: DatasetNotNumberedVersion.LATEST * @param {boolean} [includeDeaccessioned=false] - Indicates whether to consider deaccessioned versions in the dataset search or not. The default value is false + * @param {boolean} [keepRawFields=false] - Indicates whether or not the use case should keep the metadata fields as they are and avoid the transformation to markdown. The default value is false. * @returns {Promise} */ async execute( datasetId: number | string, datasetVersionId: string | DatasetNotNumberedVersion = DatasetNotNumberedVersion.LATEST, - includeDeaccessioned = false + includeDeaccessioned = false, + keepRawFields = false ): Promise { return await this.datasetsRepository.getDataset( datasetId, datasetVersionId, - includeDeaccessioned + includeDeaccessioned, + keepRawFields ) } } diff --git a/src/datasets/domain/useCases/GetPrivateUrlDataset.ts b/src/datasets/domain/useCases/GetPrivateUrlDataset.ts index e2d3c918..199619b6 100644 --- a/src/datasets/domain/useCases/GetPrivateUrlDataset.ts +++ b/src/datasets/domain/useCases/GetPrivateUrlDataset.ts @@ -13,9 +13,10 @@ export class GetPrivateUrlDataset implements UseCase { * Returns a Dataset instance, given an associated Private URL Token. * * @param {string} [token] - A Private URL token. + * @param {boolean} [keepRawFields=false] - Indicates whether or not the use case should keep the metadata fields as they are and avoid the transformation to markdown. The default value is false. * @returns {Promise} */ - async execute(token: string): Promise { - return await this.datasetsRepository.getPrivateUrlDataset(token) + async execute(token: string, keepRawFields = false): Promise { + return await this.datasetsRepository.getPrivateUrlDataset(token, keepRawFields) } } diff --git a/src/datasets/infra/repositories/DatasetsRepository.ts b/src/datasets/infra/repositories/DatasetsRepository.ts index 48603485..212d7e5c 100644 --- a/src/datasets/infra/repositories/DatasetsRepository.ts +++ b/src/datasets/infra/repositories/DatasetsRepository.ts @@ -33,7 +33,7 @@ export class DatasetsRepository extends ApiRepository implements IDatasetsReposi }) } - public async getPrivateUrlDataset(token: string): Promise { + public async getPrivateUrlDataset(token: string, keepRawFields: boolean): Promise { return this.doGet( this.buildApiEndpoint(this.datasetsResourceName, `privateUrlDatasetVersion/${token}`), false, @@ -41,7 +41,7 @@ export class DatasetsRepository extends ApiRepository implements IDatasetsReposi returnOwners: true } ) - .then((response) => transformVersionResponseToDataset(response)) + .then((response) => transformVersionResponseToDataset(response, keepRawFields)) .catch((error) => { throw error }) @@ -50,7 +50,8 @@ export class DatasetsRepository extends ApiRepository implements IDatasetsReposi public async getDataset( datasetId: number | string, datasetVersionId: string, - includeDeaccessioned: boolean + includeDeaccessioned: boolean, + keepRawFields: boolean ): Promise { return this.doGet( this.buildApiEndpoint(this.datasetsResourceName, `versions/${datasetVersionId}`, datasetId), @@ -61,7 +62,7 @@ export class DatasetsRepository extends ApiRepository implements IDatasetsReposi returnOwners: true } ) - .then((response) => transformVersionResponseToDataset(response)) + .then((response) => transformVersionResponseToDataset(response, keepRawFields)) .catch((error) => { throw error }) diff --git a/src/datasets/infra/repositories/transformers/datasetTransformers.ts b/src/datasets/infra/repositories/transformers/datasetTransformers.ts index 4ace370d..51f40489 100644 --- a/src/datasets/infra/repositories/transformers/datasetTransformers.ts +++ b/src/datasets/infra/repositories/transformers/datasetTransformers.ts @@ -209,12 +209,18 @@ export const transformMetadataChildFieldValueToRequestPayload = ( return metadataChildFieldRequestPayload } -export const transformVersionResponseToDataset = (response: AxiosResponse): Dataset => { +export const transformVersionResponseToDataset = ( + response: AxiosResponse, + keepRawFields: boolean +): Dataset => { const versionPayload = response.data.data - return transformVersionPayloadToDataset(versionPayload) + return transformVersionPayloadToDataset(versionPayload, keepRawFields) } -export const transformVersionPayloadToDataset = (versionPayload: DatasetPayload): Dataset => { +export const transformVersionPayloadToDataset = ( + versionPayload: DatasetPayload, + keepRawFields: boolean +): Dataset => { const datasetModel: Dataset = { id: versionPayload.datasetId, versionId: versionPayload.id, @@ -227,7 +233,10 @@ export const transformVersionPayloadToDataset = (versionPayload: DatasetPayload) lastUpdateTime: new Date(versionPayload.lastUpdateTime), releaseTime: new Date(versionPayload.releaseTime) }, - metadataBlocks: transformPayloadToDatasetMetadataBlocks(versionPayload.metadataBlocks), + metadataBlocks: transformPayloadToDatasetMetadataBlocks( + versionPayload.metadataBlocks, + keepRawFields + ), ...(versionPayload.isPartOf && { isPartOf: transformPayloadToOwnerNode(versionPayload.isPartOf) }) @@ -260,25 +269,28 @@ const transformPayloadToDatasetLicense = (licensePayload: LicensePayload): Datas } const transformPayloadToDatasetMetadataBlocks = ( - metadataBlocksPayload: MetadataBlocksPayload + metadataBlocksPayload: MetadataBlocksPayload, + keepRawFields: boolean ): DatasetMetadataBlocks => { return Object.keys(metadataBlocksPayload).map((metadataBlockKey) => { const metadataBlock = metadataBlocksPayload[metadataBlockKey] return { name: metadataBlock.name, - fields: transformPayloadToDatasetMetadataFields(metadataBlock.fields) + fields: transformPayloadToDatasetMetadataFields(metadataBlock.fields, keepRawFields) } }) as DatasetMetadataBlocks } const transformPayloadToDatasetMetadataFields = ( - metadataFieldsPayload: MetadataFieldPayload[] + metadataFieldsPayload: MetadataFieldPayload[], + keepRawFields: boolean ): DatasetMetadataFields => { return metadataFieldsPayload.reduce( (datasetMetadataFieldsMap: DatasetMetadataFields, field: MetadataFieldPayload) => { datasetMetadataFieldsMap[field.typeName] = transformPayloadToDatasetMetadataFieldValue( field.value, - field.typeClass + field.typeClass, + keepRawFields ) return datasetMetadataFieldsMap }, @@ -288,7 +300,8 @@ const transformPayloadToDatasetMetadataFields = ( const transformPayloadToDatasetMetadataFieldValue = ( metadataFieldValuePayload: MetadataFieldValuePayload, - typeClass: string + typeClass: string, + keepRawFields: boolean ): DatasetMetadataFieldValue => { function isArrayOfSubfieldValue( array: (string | MetadataSubfieldValuePayload)[] @@ -301,29 +314,37 @@ const transformPayloadToDatasetMetadataFieldValue = ( } if (typeof metadataFieldValuePayload === 'string') { + if (keepRawFields) { + return metadataFieldValuePayload + } return transformHtmlToMarkdown(metadataFieldValuePayload) } else if (Array.isArray(metadataFieldValuePayload)) { if (isArrayOfSubfieldValue(metadataFieldValuePayload)) { return metadataFieldValuePayload.map((metadataSubfieldValuePayload) => - transformPayloadToDatasetMetadataSubfieldValue(metadataSubfieldValuePayload) + transformPayloadToDatasetMetadataSubfieldValue(metadataSubfieldValuePayload, keepRawFields) ) } else { + if (keepRawFields) { + return metadataFieldValuePayload + } return metadataFieldValuePayload.map(transformHtmlToMarkdown) } } else { return transformPayloadToDatasetMetadataSubfieldValue( - metadataFieldValuePayload as MetadataSubfieldValuePayload + metadataFieldValuePayload as MetadataSubfieldValuePayload, + keepRawFields ) } } const transformPayloadToDatasetMetadataSubfieldValue = ( - metadataSubfieldValuePayload: MetadataSubfieldValuePayload + metadataSubfieldValuePayload: MetadataSubfieldValuePayload, + keepRawFields: boolean ): DatasetMetadataSubField => { const result: DatasetMetadataSubField = {} Object.keys(metadataSubfieldValuePayload).forEach((key) => { const subFieldValue = metadataSubfieldValuePayload[key].value - result[key] = transformHtmlToMarkdown(subFieldValue) + result[key] = keepRawFields ? subFieldValue : transformHtmlToMarkdown(subFieldValue) }) return result } diff --git a/src/files/infra/repositories/transformers/fileTransformers.ts b/src/files/infra/repositories/transformers/fileTransformers.ts index b0945c64..b39f6284 100644 --- a/src/files/infra/repositories/transformers/fileTransformers.ts +++ b/src/files/infra/repositories/transformers/fileTransformers.ts @@ -27,7 +27,7 @@ export const transformFileResponseToFile = ( if (returnDatasetVersion) { return [ transformFilePayloadToFile(filePayload), - transformVersionPayloadToDataset(filePayload.datasetVersion) + transformVersionPayloadToDataset(filePayload.datasetVersion, false) ] } return transformFilePayloadToFile(filePayload) diff --git a/test/functional/datasets/GetDataset.test.ts b/test/functional/datasets/GetDataset.test.ts new file mode 100644 index 00000000..012393b2 --- /dev/null +++ b/test/functional/datasets/GetDataset.test.ts @@ -0,0 +1,109 @@ +import { ApiConfig, createDataset, getDataset, ReadError } from '../../../src' +import { DataverseApiAuthMechanism } from '../../../src/core/infra/repositories/ApiConfig' +import { DatasetDescription } from '../../../src/datasets/domain/models/Dataset' +import { deleteUnpublishedDatasetViaApi } from '../../testHelpers/datasets/datasetHelper' +import { TestConstants } from '../../testHelpers/TestConstants' + +const testNewDataset = { + metadataBlockValues: [ + { + name: 'citation', + fields: { + title: 'Dataset created using the createDataset use case', + author: [ + { + authorName: 'Admin, Dataverse', + authorAffiliation: 'Dataverse.org' + }, + { + authorName: 'Owner, Dataverse', + authorAffiliation: 'Dataversedemo.org' + } + ], + datasetContact: [ + { + datasetContactEmail: 'finch@mailinator.com', + datasetContactName: 'Finch, Fiona' + } + ], + dsDescription: [ + { + dsDescriptionValue: 'Hello world' + } + ], + subject: ['Medicine, Health and Life Sciences'] + } + } + ] +} + +describe('execute', () => { + beforeEach(async () => { + ApiConfig.init( + TestConstants.TEST_API_URL, + DataverseApiAuthMechanism.API_KEY, + process.env.TEST_API_KEY + ) + }) + + test('should successfully get a dataset when a valid id is sent', async () => { + const createdDatasetIdentifiers = await createDataset.execute(testNewDataset) + + const dataset = await getDataset.execute(createdDatasetIdentifiers.numericId) + expect(dataset).not.toBeNull() + expect(dataset.id).toBe(createdDatasetIdentifiers.numericId) + + await deleteUnpublishedDatasetViaApi(createdDatasetIdentifiers.numericId) + }) + + test('should successfully get a dataset when a valid persistent id is sent', async () => { + const createdDatasetIdentifiers = await createDataset.execute(testNewDataset) + + const dataset = await getDataset.execute(createdDatasetIdentifiers.persistentId) + expect(dataset).not.toBeNull() + expect(dataset.id).toBe(createdDatasetIdentifiers.numericId) + + await deleteUnpublishedDatasetViaApi(createdDatasetIdentifiers.numericId) + }) + + test('should throw an error when an invalid id is sent', async () => { + const nonExistentTestDatasetId = 'non-existent-dataset' + const expectedError = new ReadError(`[400] Bad dataset ID number: ${nonExistentTestDatasetId}.`) + + await expect(getDataset.execute(nonExistentTestDatasetId)).rejects.toThrow(expectedError) + }) + + test('should return metadata fields in markdown format when keepRawFields is false', async () => { + const createdDatasetIdentifiers = await createDataset.execute(testNewDataset) + + const dataset = await getDataset.execute( + createdDatasetIdentifiers.numericId, + undefined, + false, + false + ) + + expect( + (dataset.metadataBlocks[0].fields.dsDescription[0] as DatasetDescription).dsDescriptionValue + ).toBe('Hello **world**') + + await deleteUnpublishedDatasetViaApi(createdDatasetIdentifiers.numericId) + }) + + test('should not return metadata fields in markdown format when keepRawFields is true', async () => { + const createdDatasetIdentifiers = await createDataset.execute(testNewDataset) + + const dataset = await getDataset.execute( + createdDatasetIdentifiers.numericId, + undefined, + false, + true + ) + + expect( + (dataset.metadataBlocks[0].fields.dsDescription[0] as DatasetDescription).dsDescriptionValue + ).toBe('Hello world') + + await deleteUnpublishedDatasetViaApi(createdDatasetIdentifiers.numericId) + }) +}) diff --git a/test/integration/datasets/DatasetsRepository.test.ts b/test/integration/datasets/DatasetsRepository.test.ts index 7bfafcd1..95df6123 100644 --- a/test/integration/datasets/DatasetsRepository.test.ts +++ b/test/integration/datasets/DatasetsRepository.test.ts @@ -157,6 +157,7 @@ describe('DatasetsRepository', () => { const actual = await sut.getDataset( testDatasetIds.numericId, DatasetNotNumberedVersion.LATEST, + false, false ) expect(actual.id).toBe(testDatasetIds.numericId) @@ -170,7 +171,8 @@ describe('DatasetsRepository', () => { const actual = await sut.getDataset( testDatasetIds.numericId, DatasetNotNumberedVersion.LATEST, - true + true, + false ) expect(actual.id).toBe(testDatasetIds.numericId) @@ -181,7 +183,8 @@ describe('DatasetsRepository', () => { const actual = await sut.getDataset( testDatasetIds.numericId, DatasetNotNumberedVersion.LATEST, - true + true, + false ) expect(actual.id).toBe(testDatasetIds.numericId) ApiConfig.init( @@ -196,7 +199,7 @@ describe('DatasetsRepository', () => { `[404] Dataset version ${DatasetNotNumberedVersion.LATEST} of dataset ${testDatasetIds.numericId} not found` ) await expect( - sut.getDataset(testDatasetIds.numericId, DatasetNotNumberedVersion.LATEST, false) + sut.getDataset(testDatasetIds.numericId, DatasetNotNumberedVersion.LATEST, false, false) ).rejects.toThrow(expectedError) }) @@ -206,7 +209,7 @@ describe('DatasetsRepository', () => { ) await expect( - sut.getDataset(nonExistentTestDatasetId, DatasetNotNumberedVersion.LATEST, false) + sut.getDataset(nonExistentTestDatasetId, DatasetNotNumberedVersion.LATEST, false, false) ).rejects.toThrow(expectedError) }) }) @@ -226,11 +229,13 @@ describe('DatasetsRepository', () => { const createdDataset = await sut.getDataset( testDatasetIds.numericId, DatasetNotNumberedVersion.LATEST, + false, false ) const actual = await sut.getDataset( createdDataset.persistentId, DatasetNotNumberedVersion.LATEST, + false, false ) expect(actual.id).toBe(testDatasetIds.numericId) @@ -242,7 +247,7 @@ describe('DatasetsRepository', () => { `[400] Bad dataset ID number: ${testWrongPersistentId}.` ) await expect( - sut.getDataset(testWrongPersistentId, DatasetNotNumberedVersion.LATEST, false) + sut.getDataset(testWrongPersistentId, DatasetNotNumberedVersion.LATEST, false, false) ).rejects.toThrow(expectedError) }) }) @@ -263,6 +268,7 @@ describe('DatasetsRepository', () => { const actual = await sut.getDataset( createdDatasetNumericId, DatasetNotNumberedVersion.LATEST, + false, false ) @@ -294,13 +300,13 @@ describe('DatasetsRepository', () => { describe('getPrivateUrlDataset', () => { test('should return dataset when token is valid', async () => { - const actual = await sut.getPrivateUrlDataset(privateUrlToken) + const actual = await sut.getPrivateUrlDataset(privateUrlToken, false) expect(actual.id).toBe(testDatasetIds.numericId) }) test('should return error when token is not valid', async () => { const expectedError = new ReadError(expectedErrorInvalidToken) - await expect(sut.getPrivateUrlDataset('invalidToken')).rejects.toThrow(expectedError) + await expect(sut.getPrivateUrlDataset('invalidToken', false)).rejects.toThrow(expectedError) }) }) @@ -471,6 +477,7 @@ describe('DatasetsRepository', () => { const actualCreatedDataset = await sut.getDataset( createdDataset.numericId, DatasetNotNumberedVersion.LATEST, + false, false ) @@ -528,6 +535,7 @@ describe('DatasetsRepository', () => { const newDatasetVersion = await sut.getDataset( testDatasetIds.numericId, DatasetNotNumberedVersion.LATEST, + false, false ) @@ -568,6 +576,7 @@ describe('DatasetsRepository', () => { const datasetAfterFirstPublish = await sut.getDataset( testDatasetIds.numericId, DatasetNotNumberedVersion.LATEST, + false, false ) @@ -587,6 +596,7 @@ describe('DatasetsRepository', () => { const datasetAfterUpdatingCurrentVersion = await sut.getDataset( testDatasetIds.numericId, DatasetNotNumberedVersion.LATEST, + false, false ) @@ -651,6 +661,7 @@ describe('DatasetsRepository', () => { const actualCreatedDataset = await sut.getDataset( createdDataset.numericId, DatasetNotNumberedVersion.LATEST, + false, false ) @@ -668,6 +679,7 @@ describe('DatasetsRepository', () => { const actualUpdatedDataset = await sut.getDataset( createdDataset.numericId, DatasetNotNumberedVersion.LATEST, + false, false ) diff --git a/test/unit/datasets/DatasetsRepository.test.ts b/test/unit/datasets/DatasetsRepository.test.ts index cbab1938..55671c8b 100644 --- a/test/unit/datasets/DatasetsRepository.test.ts +++ b/test/unit/datasets/DatasetsRepository.test.ts @@ -125,7 +125,8 @@ describe('DatasetsRepository', () => { let actual = await sut.getDataset( testDatasetModel.id, testVersionId, - testIncludeDeaccessioned + testIncludeDeaccessioned, + false ) expect(axios.get).toHaveBeenCalledWith(expectedApiEndpoint, expectedRequestConfigApiKey) @@ -133,7 +134,12 @@ describe('DatasetsRepository', () => { // Session cookie auth ApiConfig.init(TestConstants.TEST_API_URL, DataverseApiAuthMechanism.SESSION_COOKIE) - actual = await sut.getDataset(testDatasetModel.id, testVersionId, testIncludeDeaccessioned) + actual = await sut.getDataset( + testDatasetModel.id, + testVersionId, + testIncludeDeaccessioned, + false + ) expect(axios.get).toHaveBeenCalledWith( expectedApiEndpoint, expectedRequestConfigSessionCookie @@ -154,7 +160,8 @@ describe('DatasetsRepository', () => { const actual = await sut.getDataset( testDatasetModel.id, testVersionId, - testIncludeDeaccessioned + testIncludeDeaccessioned, + false ) expect(axios.get).toHaveBeenCalledWith( @@ -177,7 +184,8 @@ describe('DatasetsRepository', () => { const actual = await sut.getDataset( testDatasetModel.id, testVersionId, - testIncludeDeaccessioned + testIncludeDeaccessioned, + false ) expect(axios.get).toHaveBeenCalledWith( @@ -203,7 +211,8 @@ describe('DatasetsRepository', () => { const actual = await sut.getDataset( testDatasetModel.id, testVersionId, - testIncludeDeaccessioned + testIncludeDeaccessioned, + false ) expect(axios.get).toHaveBeenCalledWith( @@ -218,7 +227,7 @@ describe('DatasetsRepository', () => { let error = undefined as unknown as ReadError await sut - .getDataset(testDatasetModel.id, testVersionId, testIncludeDeaccessioned) + .getDataset(testDatasetModel.id, testVersionId, testIncludeDeaccessioned, false) .catch((e) => (error = e)) expect(axios.get).toHaveBeenCalledWith( @@ -237,7 +246,8 @@ describe('DatasetsRepository', () => { let actual = await sut.getDataset( testDatasetModel.persistentId, testVersionId, - testIncludeDeaccessioned + testIncludeDeaccessioned, + false ) expect(axios.get).toHaveBeenCalledWith(expectedApiEndpoint, expectedRequestConfigApiKey) @@ -249,7 +259,8 @@ describe('DatasetsRepository', () => { actual = await sut.getDataset( testDatasetModel.persistentId, testVersionId, - testIncludeDeaccessioned + testIncludeDeaccessioned, + false ) expect(axios.get).toHaveBeenCalledWith( @@ -264,7 +275,7 @@ describe('DatasetsRepository', () => { let error = undefined as unknown as ReadError await sut - .getDataset(testDatasetModel.persistentId, testVersionId, testIncludeDeaccessioned) + .getDataset(testDatasetModel.persistentId, testVersionId, testIncludeDeaccessioned, false) .catch((e) => (error = e)) expect(axios.get).toHaveBeenCalledWith( @@ -284,7 +295,7 @@ describe('DatasetsRepository', () => { test('should return Dataset when response is successful', async () => { jest.spyOn(axios, 'get').mockResolvedValue(testDatasetVersionSuccessfulResponse) - const actual = await sut.getPrivateUrlDataset(testPrivateUrlToken) + const actual = await sut.getPrivateUrlDataset(testPrivateUrlToken, false) expect(axios.get).toHaveBeenCalledWith( `${TestConstants.TEST_API_URL}/datasets/privateUrlDatasetVersion/${testPrivateUrlToken}`, @@ -297,7 +308,7 @@ describe('DatasetsRepository', () => { jest.spyOn(axios, 'get').mockRejectedValue(TestConstants.TEST_ERROR_RESPONSE) let error = undefined as unknown as ReadError - await sut.getPrivateUrlDataset(testPrivateUrlToken).catch((e) => (error = e)) + await sut.getPrivateUrlDataset(testPrivateUrlToken, false).catch((e) => (error = e)) expect(axios.get).toHaveBeenCalledWith( `${TestConstants.TEST_API_URL}/datasets/privateUrlDatasetVersion/${testPrivateUrlToken}`, @@ -821,7 +832,7 @@ describe('DatasetsRepository', () => { test('should return error result on error response', async () => { jest.spyOn(axios, 'post').mockRejectedValue(TestConstants.TEST_ERROR_RESPONSE) - let error: WriteError = undefined + let error: WriteError | undefined = undefined await sut.publishDataset(testDatasetModel.id, testVersionUpdateType).catch((e) => (error = e)) expect(axios.post).toHaveBeenCalledWith( @@ -878,7 +889,7 @@ describe('DatasetsRepository', () => { test('should return error result on error response', async () => { jest.spyOn(axios, 'put').mockRejectedValue(TestConstants.TEST_ERROR_RESPONSE) - let error: WriteError = undefined + let error: WriteError | undefined = undefined await sut .updateDataset(testDatasetModel.id, testNewDataset, testMetadataBlocks) .catch((e) => (error = e)) diff --git a/test/unit/datasets/GetPrivateUrlDataset.test.ts b/test/unit/datasets/GetPrivateUrlDataset.test.ts index f5a44b13..caea59e5 100644 --- a/test/unit/datasets/GetPrivateUrlDataset.test.ts +++ b/test/unit/datasets/GetPrivateUrlDataset.test.ts @@ -15,7 +15,10 @@ describe('execute', () => { const actual = await sut.execute(testPrivateUrlToken) expect(actual).toEqual(testDataset) - expect(datasetsRepositoryStub.getPrivateUrlDataset).toHaveBeenCalledWith(testPrivateUrlToken) + expect(datasetsRepositoryStub.getPrivateUrlDataset).toHaveBeenCalledWith( + testPrivateUrlToken, + false + ) }) test('should return error result on repository error', async () => {