Skip to content

Commit ff42b7f

Browse files
committed
fix: map linked dataset correctly according to model
1 parent d37c5f8 commit ff42b7f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/collections/infra/repositories/transformers/collectionTransformers.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,13 @@ export const transformCollectionLinksResponseToCollectionLinks = (
159159
const responseDataPayload = response.data.data
160160
const linkedCollections = responseDataPayload.linkedDataverses
161161
const collectionsLinkingToThis = responseDataPayload.dataversesLinkingToThis
162-
const linkedDatasets = responseDataPayload.linkedDatasets
162+
const linkedDatasets = responseDataPayload.linkedDatasets.map(
163+
(ld: { identifier: string; title: string }) => ({
164+
persistentId: ld.identifier,
165+
title: ld.title
166+
})
167+
)
168+
163169
return {
164170
linkedCollections,
165171
collectionsLinkingToThis,

test/integration/collections/CollectionsRepository.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2093,16 +2093,18 @@ describe('CollectionsRepository', () => {
20932093
const thirdCollectionAlias = 'getCollectionLinksThird'
20942094
const fourthCollectionAlias = 'getCollectionLinksFourth'
20952095
let childDatasetNumericId: number
2096+
let childDatasetPersistentId: string
20962097
beforeAll(async () => {
20972098
await createCollectionViaApi(firstCollectionAlias)
20982099
await createCollectionViaApi(secondCollectionAlias)
20992100
await createCollectionViaApi(thirdCollectionAlias)
21002101
await createCollectionViaApi(fourthCollectionAlias)
2101-
const { numericId: createdId } = await createDataset.execute(
2102+
const { numericId: createdId, persistentId: createdPid } = await createDataset.execute(
21022103
TestConstants.TEST_NEW_DATASET_DTO,
21032104
fourthCollectionAlias
21042105
)
21052106
childDatasetNumericId = createdId
2107+
childDatasetPersistentId = createdPid
21062108
await sut.linkCollection(secondCollectionAlias, firstCollectionAlias)
21072109
await sut.linkCollection(firstCollectionAlias, thirdCollectionAlias)
21082110
await sut.linkCollection(firstCollectionAlias, fourthCollectionAlias)
@@ -2131,6 +2133,7 @@ describe('CollectionsRepository', () => {
21312133
expect(collectionLinks.linkedDatasets[0].title).toBe(
21322134
'Dataset created using the createDataset use case'
21332135
)
2136+
expect(collectionLinks.linkedDatasets[0].persistentId).toBe(childDatasetPersistentId)
21342137
})
21352138

21362139
test('should return error when collection does not exist', async () => {

0 commit comments

Comments
 (0)