From 1bde9a36b8fa7e1ee3c7a4ba40be95f233aab0e0 Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Fri, 3 Jan 2025 15:25:34 -0500 Subject: [PATCH] feat: dataset image url update --- src/datasets/domain/models/DatasetPreview.ts | 1 + .../repositories/transformers/DatasetPreviewPayload.ts | 1 + .../transformers/datasetPreviewsTransformers.ts | 5 ++++- test/integration/collections/CollectionsRepository.test.ts | 1 + test/testHelpers/TestConstants.ts | 3 ++- test/testHelpers/datasets/datasetPreviewHelper.ts | 6 ++++-- 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/datasets/domain/models/DatasetPreview.ts b/src/datasets/domain/models/DatasetPreview.ts index 29150f2f..f139ec0d 100644 --- a/src/datasets/domain/models/DatasetPreview.ts +++ b/src/datasets/domain/models/DatasetPreview.ts @@ -13,4 +13,5 @@ export interface DatasetPreview { publicationStatuses: PublicationStatus[] parentCollectionName: string parentCollectionAlias: string + imageUrl?: string } diff --git a/src/datasets/infra/repositories/transformers/DatasetPreviewPayload.ts b/src/datasets/infra/repositories/transformers/DatasetPreviewPayload.ts index ae9a7622..42652222 100644 --- a/src/datasets/infra/repositories/transformers/DatasetPreviewPayload.ts +++ b/src/datasets/infra/repositories/transformers/DatasetPreviewPayload.ts @@ -14,4 +14,5 @@ export interface DatasetPreviewPayload { publicationStatuses: string[] identifier_of_dataverse: string name_of_dataverse: string + image_url?: string } diff --git a/src/datasets/infra/repositories/transformers/datasetPreviewsTransformers.ts b/src/datasets/infra/repositories/transformers/datasetPreviewsTransformers.ts index e9b61307..2f87ac19 100644 --- a/src/datasets/infra/repositories/transformers/datasetPreviewsTransformers.ts +++ b/src/datasets/infra/repositories/transformers/datasetPreviewsTransformers.ts @@ -47,6 +47,9 @@ export const transformDatasetPreviewPayloadToDatasetPreview = ( description: datasetPreviewPayload.description, publicationStatuses: publicationStatuses, parentCollectionAlias: datasetPreviewPayload.identifier_of_dataverse, - parentCollectionName: datasetPreviewPayload.name_of_dataverse + parentCollectionName: datasetPreviewPayload.name_of_dataverse, + ...(datasetPreviewPayload.image_url && { + imageUrl: datasetPreviewPayload.image_url + }) } } diff --git a/test/integration/collections/CollectionsRepository.test.ts b/test/integration/collections/CollectionsRepository.test.ts index a251dd4d..f38f1641 100644 --- a/test/integration/collections/CollectionsRepository.test.ts +++ b/test/integration/collections/CollectionsRepository.test.ts @@ -399,6 +399,7 @@ describe('CollectionsRepository', () => { ) expect(actualDatasetPreview.parentCollectionName).toBe(expectedCollectionsName) expect(actualDatasetPreview.type).toBe(CollectionItemType.DATASET) + expect(actualDatasetPreview.imageUrl).toBe('http://dataverse.com') expect(actualCollectionPreview.name).toBe(expectedCollectionsName) expect(actualCollectionPreview.alias).toBe(testSubCollectionAlias) diff --git a/test/testHelpers/TestConstants.ts b/test/testHelpers/TestConstants.ts index 4a2adfb8..ab020e7e 100644 --- a/test/testHelpers/TestConstants.ts +++ b/test/testHelpers/TestConstants.ts @@ -89,7 +89,8 @@ export class TestConstants { dsDescriptionValue: 'This is the description of the dataset.' } ], - subject: ['Medicine, Health and Life Sciences'] + subject: ['Medicine, Health and Life Sciences'], + imageUrl: 'http://dataverse.com' } } ] diff --git a/test/testHelpers/datasets/datasetPreviewHelper.ts b/test/testHelpers/datasets/datasetPreviewHelper.ts index 82d09ad0..fb61d792 100644 --- a/test/testHelpers/datasets/datasetPreviewHelper.ts +++ b/test/testHelpers/datasets/datasetPreviewHelper.ts @@ -29,7 +29,8 @@ export const createDatasetPreviewModel = (): DatasetPreview => { description: 'test', publicationStatuses: [PublicationStatus.Draft, PublicationStatus.Unpublished], parentCollectionAlias: 'parentCollection', - parentCollectionName: 'Parent Collection' + parentCollectionName: 'Parent Collection', + imageUrl: 'http://dataverse.com' } return datasetPreviewModel } @@ -50,6 +51,7 @@ export const createDatasetPreviewPayload = (): DatasetPreviewPayload => { type: 'dataset', publicationStatuses: ['Draft', 'Unpublished'], identifier_of_dataverse: 'parentCollection', - name_of_dataverse: 'Parent Collection' + name_of_dataverse: 'Parent Collection', + image_url: 'http://dataverse.com' } }