Skip to content

Commit 11fdbc2

Browse files
committed
Merge branch 'develop' of github.com:IQSS/dataverse-client-javascript into 146-edit-dataset-use-case
2 parents f97fb2c + d7e80c0 commit 11fdbc2

File tree

6 files changed

+45
-43
lines changed

6 files changed

+45
-43
lines changed

src/collections/domain/models/Collection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export interface Collection {
33
id: number
44
alias: string
55
name: string
6+
isReleased: string
67
affiliation?: string
78
description?: string
89
isPartOf: DvObjectOwnerNode

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export interface CollectionPayload {
44
alias: string
55
name: string
66
affiliation?: string
7+
isReleased: string
78
description?: string
89
isPartOf: OwnerNodePayload
910
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const transformPayloadToCollection = (collectionPayload: CollectionPayload): Col
1414
id: collectionPayload.id,
1515
alias: collectionPayload.alias,
1616
name: collectionPayload.name,
17+
isReleased: collectionPayload.isReleased,
1718
affiliation: collectionPayload.affiliation,
1819
description: transformHtmlToMarkdown(collectionPayload.description),
1920
...(collectionPayload.isPartOf && {

test/integration/collections/CollectionsRepository.test.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,27 @@ describe('CollectionsRepository', () => {
4040
const actual = await testGetCollection.getCollection()
4141
expect(actual.alias).toBe(ROOT_COLLECTION_ALIAS)
4242
})
43-
})
4443

44+
test('should return isReleased is true for root collection', async () => {
45+
const actual = await testGetCollection.getCollection()
46+
expect(actual.alias).toBe(ROOT_COLLECTION_ALIAS)
47+
expect(actual.isReleased).toBe(true)
48+
})
49+
})
4550
describe('by string alias', () => {
4651
test('should return collection when it exists filtering by id AS (alias)', async () => {
4752
const actual = await testGetCollection.getCollection(
4853
TestConstants.TEST_CREATED_COLLECTION_ALIAS_2
4954
)
5055
expect(actual.alias).toBe(TestConstants.TEST_CREATED_COLLECTION_ALIAS_2)
5156
})
52-
57+
test('should return isReleased is false for unpublished collection', async () => {
58+
const actual = await testGetCollection.getCollection(
59+
TestConstants.TEST_CREATED_COLLECTION_ALIAS_2
60+
)
61+
expect(actual.alias).toBe(TestConstants.TEST_CREATED_COLLECTION_ALIAS_2)
62+
expect(actual.isReleased).toBe(false)
63+
})
5364
test('should return error when collection does not exist', async () => {
5465
const expectedError = new ReadError(
5566
`[404] Can't find dataverse with identifier='${TestConstants.TEST_DUMMY_COLLECTION_ALIAS}'`

test/integration/files/FilesRepository.test.ts

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -59,35 +59,26 @@ describe('FilesRepository', () => {
5959
// Uploading test file 1 with some categories
6060
const uploadFileResponse = await uploadFileViaApi(testDatasetIds.numericId, testTextFile1Name, {
6161
categories: [testCategoryName]
62+
}).catch(() => {
63+
throw new Error(`Tests beforeAll(): Error while uploading file ${testTextFile1Name}`)
6264
})
63-
.then()
64-
.catch((e) => {
65-
console.log(e)
66-
throw new Error(`Tests beforeAll(): Error while uploading file ${testTextFile1Name}`)
67-
})
6865
// Uploading test file 2
69-
await uploadFileViaApi(testDatasetIds.numericId, testTextFile2Name)
70-
.then()
71-
.catch((e) => {
72-
console.log(e)
73-
throw new Error(`Tests beforeAll(): Error while uploading file ${testTextFile2Name}`)
74-
})
66+
await uploadFileViaApi(testDatasetIds.numericId, testTextFile2Name).catch(() => {
67+
throw new Error(`Tests beforeAll(): Error while uploading file ${testTextFile2Name}`)
68+
})
7569
// Uploading test file 3
76-
await uploadFileViaApi(testDatasetIds.numericId, testTextFile3Name)
77-
.then()
78-
.catch((e) => {
79-
console.log(e)
80-
throw new Error(`Tests beforeAll(): Error while uploading file ${testTextFile3Name}`)
81-
})
70+
await uploadFileViaApi(testDatasetIds.numericId, testTextFile3Name).catch(() => {
71+
throw new Error(`Tests beforeAll(): Error while uploading file ${testTextFile3Name}`)
72+
})
8273
// Uploading test file 4
83-
await uploadFileViaApi(testDatasetIds.numericId, testTabFile4Name)
84-
.then()
85-
.catch((e) => {
86-
console.log(e)
87-
throw new Error(`Tests beforeAll(): Error while uploading file ${testTabFile4Name}`)
88-
})
74+
await uploadFileViaApi(testDatasetIds.numericId, testTabFile4Name).catch(() => {
75+
throw new Error(`Tests beforeAll(): Error while uploading file ${testTabFile4Name}`)
76+
})
8977
// Registering test file 1
90-
await registerFileViaApi(uploadFileResponse.data.data.files[0].dataFile.id)
78+
79+
await registerFileViaApi(uploadFileResponse.data.data.files[0].dataFile.id).catch(() => {
80+
throw new Error(`Tests beforeAll(): Error while registering file ${testTextFile1Name}`)
81+
})
9182
const filesSubset = await sut.getDatasetFiles(
9283
testDatasetIds.numericId,
9384
latestDatasetVersionId,
@@ -544,23 +535,17 @@ describe('FilesRepository', () => {
544535
})
545536

546537
test('should return citation when dataset is deaccessioned', async () => {
547-
await publishDatasetViaApi(testDatasetIds.numericId)
548-
.then()
549-
.catch(() => {
550-
throw new Error('Error while publishing test Dataset')
551-
})
552-
553-
await waitForNoLocks(testDatasetIds.numericId, 10)
554-
.then()
555-
.catch(() => {
556-
throw new Error('Error while waiting for no locks')
557-
})
558-
559-
await deaccessionDatasetViaApi(testDatasetIds.numericId, '1.0')
560-
.then()
561-
.catch(() => {
562-
throw new Error('Error while deaccessioning test Dataset')
563-
})
538+
await publishDatasetViaApi(testDatasetIds.numericId).catch(() => {
539+
throw new Error('Error while publishing test Dataset')
540+
})
541+
542+
await waitForNoLocks(testDatasetIds.numericId, 10).catch(() => {
543+
throw new Error('Error while waiting for no locks')
544+
})
545+
546+
await deaccessionDatasetViaApi(testDatasetIds.numericId, '1.0').catch(() => {
547+
throw new Error('Error while deaccessioning test Dataset')
548+
})
564549

565550
const actualFileCitation = await sut.getFileCitation(
566551
testFileId,

test/testHelpers/collections/collectionHelper.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import collectionJson1 from './test-collection-1.json'
77
import collectionJson2 from './test-collection-2.json'
88

99
const COLLECTION_ID = 11111
10+
const COLLECTION_IS_RELEASED = 'true'
1011
const COLLECTION_ALIAS_STR = 'secondCollection'
1112
const COLLECTION_NAME_STR = 'Laboratory Research'
1213
const COLLECTION_AFFILIATION_STR = 'Laboratory Research Corporation'
@@ -23,6 +24,7 @@ export const createCollectionModel = (): Collection => {
2324
id: COLLECTION_ID,
2425
alias: COLLECTION_ALIAS_STR,
2526
name: COLLECTION_NAME_STR,
27+
isReleased: COLLECTION_IS_RELEASED,
2628
affiliation: COLLECTION_AFFILIATION_STR,
2729
description: COLLECTION_DESCRIPTION_MARKDOWN,
2830
isPartOf: { type: DvObjectType.DATAVERSE, identifier: 'root', displayName: 'Root' }
@@ -35,6 +37,7 @@ export const createCollectionPayload = (): CollectionPayload => {
3537
id: COLLECTION_ID,
3638
alias: COLLECTION_ALIAS_STR,
3739
name: COLLECTION_NAME_STR,
40+
isReleased: COLLECTION_IS_RELEASED,
3841
affiliation: COLLECTION_AFFILIATION_STR,
3942
description: COLLECTION_DESCRIPTION_HTML,
4043
isPartOf: { type: DvObjectType.DATAVERSE, identifier: 'root', displayName: 'Root' }

0 commit comments

Comments
 (0)