Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel
- New Use Case: [Get a Template](./docs/useCases.md#get-a-template) under Templates.
- New Use Case: [Delete a Template](./docs/useCases.md#delete-a-template) under Templates.
- New Use Case: [Update Terms of Access](./docs/useCases.md#update-terms-of-access).
- New Use Case: [Get Publish Dataset Disclaimer Text](./docs/useCases.md#get-publish-dataset-disclaimer-text).
- New Use Case: [Get Dataset Publish Popup Custom Text](./docs/useCases.md#get-dataset-publish-popup-custom-text).

### Changed

Expand Down
40 changes: 37 additions & 3 deletions docs/useCases.md
Original file line number Diff line number Diff line change
Expand Up @@ -1398,8 +1398,6 @@ _See [use case](../src/datasets/domain/useCases/GetDatasetAvailableCategories.ts

The `datasetId` parameter is a number for numeric identifiers or string for persistent identifiers.

# <<<<<<< HEAD

#### Get Dataset Templates

Returns a [DatasetTemplate](../src/datasets/domain/models/DatasetTemplate.ts) array containing the dataset templates of the requested collection, given the collection identifier or alias.
Expand Down Expand Up @@ -2525,6 +2523,42 @@ getAvailableDatasetMetadataExportFormats

_See [use case](../src/info/domain/useCases/GetAvailableDatasetMetadataExportFormats.ts) implementation_.

#### Get Dataset Publish Popup Custom Text

Returns the custom text displayed in the dataset publish confirmation popup

##### Example call:

```typescript
import { getDatasetPublishPopupCustomText } from '@iqss/dataverse-client-javascript'

/* ... */

getDatasetPublishPopupCustomText.execute().then((text: string) => {
/* ... */
})
```

_See [use case](../src/info/domain/useCases/GetDatasetPublishPopupCustomText.ts) implementation_.

#### Get Publish Dataset Disclaimer Text

Returns the disclaimer text displayed in the dataset publish flow.

##### Example calls:

```typescript
import { getPublishDatasetDisclaimerText } from '@iqss/dataverse-client-javascript'

/* ... */

getPublishDatasetDisclaimerText.execute().then((disclaimerText: string) => {
/* ... */
})
```

_See [use case](../src/info/domain/useCases/GetPublishDatasetDisclaimerText.ts) implementation_.

## Licenses

### Get Available Standard License Terms
Expand Down Expand Up @@ -2559,7 +2593,7 @@ import { submitContactInfo } from '@iqss/dataverse-client-javascript'
/* ... */

const contactDTO: ContactDTO = {
targedId: 1
targetId: 1,
subject: 'Data Question',
body: 'Please help me understand your data. Thank you!',
fromEmail: 'test@gmail.com'
Expand Down
2 changes: 2 additions & 0 deletions src/info/domain/repositories/IDataverseInfoRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ export interface IDataverseInfoRepository {
getMaxEmbargoDurationInMonths(): Promise<number>
getApplicationTermsOfUse(lang?: string): Promise<string>
getAvailableDatasetMetadataExportFormats(): Promise<DatasetMetadataExportFormats>
getDatasetPublishPopupCustomText(): Promise<string>
getPublishDatasetDisclaimerText(): Promise<string>
}
19 changes: 19 additions & 0 deletions src/info/domain/useCases/GetDatasetPublishPopupCustomText.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { UseCase } from '../../../core/domain/useCases/UseCase'
import { IDataverseInfoRepository } from '../repositories/IDataverseInfoRepository'

export class GetDatasetPublishPopupCustomText implements UseCase<string> {
private dataverseInfoRepository: IDataverseInfoRepository

constructor(dataverseInfoRepository: IDataverseInfoRepository) {
this.dataverseInfoRepository = dataverseInfoRepository
}

/**
* Returns a string containing custom text for the Publish Dataset modal.
*
* @returns {Promise<string>}
*/
async execute(): Promise<string> {
return await this.dataverseInfoRepository.getDatasetPublishPopupCustomText()
}
Comment on lines +4 to +18
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new use case doesn’t have a corresponding unit test under test/unit/info/ (other info use cases do). Add tests covering the success path (repository returns text) and error propagation (repository rejects).

Copilot uses AI. Check for mistakes.
}
19 changes: 19 additions & 0 deletions src/info/domain/useCases/GetPublishDatasetDisclaimerText.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { UseCase } from '../../../core/domain/useCases/UseCase'
import { IDataverseInfoRepository } from '../repositories/IDataverseInfoRepository'

export class GetPublishDatasetDisclaimerText implements UseCase<string> {
private dataverseInfoRepository: IDataverseInfoRepository

constructor(dataverseInfoRepository: IDataverseInfoRepository) {
this.dataverseInfoRepository = dataverseInfoRepository
}

/**
* Returns a string containing the disclaimer text for the Publish Dataset modal.
*
* @returns {Promise<string>}
*/
async execute(): Promise<string> {
return await this.dataverseInfoRepository.getPublishDatasetDisclaimerText()
}
Comment on lines +4 to +18
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new use case doesn’t have a corresponding unit test under test/unit/info/ (other info use cases do). Add tests covering the success path (repository returns text) and error propagation (repository rejects).

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are there in unit/info/DataversInfoRepository.test.ts, not sure why this comment was triggered.

}
10 changes: 9 additions & 1 deletion src/info/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { GetZipDownloadLimit } from './domain/useCases/GetZipDownloadLimit'
import { GetMaxEmbargoDurationInMonths } from './domain/useCases/GetMaxEmbargoDurationInMonths'
import { GetApplicationTermsOfUse } from './domain/useCases/GetApplicationTermsOfUse'
import { GetAvailableDatasetMetadataExportFormats } from './domain/useCases/GetAvailableDatasetMetadataExportFormats'
import { GetDatasetPublishPopupCustomText } from './domain/useCases/GetDatasetPublishPopupCustomText'
import { GetPublishDatasetDisclaimerText } from './domain/useCases/GetPublishDatasetDisclaimerText'

const dataverseInfoRepository = new DataverseInfoRepository()

Expand All @@ -14,13 +16,19 @@ const getApplicationTermsOfUse = new GetApplicationTermsOfUse(dataverseInfoRepos
const getAvailableDatasetMetadataExportFormats = new GetAvailableDatasetMetadataExportFormats(
dataverseInfoRepository
)
const getPublishDatasetDisclaimerText = new GetPublishDatasetDisclaimerText(dataverseInfoRepository)
const getDatasetPublishPopupCustomText = new GetDatasetPublishPopupCustomText(
dataverseInfoRepository
)

export {
getDataverseVersion,
getZipDownloadLimit,
getMaxEmbargoDurationInMonths,
getApplicationTermsOfUse,
getAvailableDatasetMetadataExportFormats
getAvailableDatasetMetadataExportFormats,
getDatasetPublishPopupCustomText,
getPublishDatasetDisclaimerText
}

export { DatasetMetadataExportFormats } from './domain/models/DatasetMetadataExportFormats'
22 changes: 22 additions & 0 deletions src/info/infra/repositories/DataverseInfoRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,26 @@ export class DataverseInfoRepository extends ApiRepository implements IDataverse
throw error
})
}
public async getDatasetPublishPopupCustomText(): Promise<string> {
return this.doGet(
this.buildApiEndpoint(this.infoResourceName, `settings/:DatasetPublishPopupCustomText`)
)
.then((response: AxiosResponse<{ data: { message: string } }>) => {
return response.data.data.message
})
.catch((error) => {
throw error
})
}
public async getPublishDatasetDisclaimerText(): Promise<string> {
return this.doGet(
this.buildApiEndpoint(this.infoResourceName, `settings/:PublishDatasetDisclaimerText`)
)
.then((response: AxiosResponse<{ data: { message: string } }>) => {
return response.data.data.message
})
.catch((error) => {
throw error
})
}
}
37 changes: 36 additions & 1 deletion test/integration/info/DataverseInfoRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { TestConstants } from '../../testHelpers/TestConstants'
import {
deleteApplicationTermsOfUseViaApi,
setApplicationTermsOfUseViaApi,
setMaxEmbargoDurationInMonthsViaApi
setDatasetPublishPopupCustomTextViaApi,
setMaxEmbargoDurationInMonthsViaApi,
setPublishDatasetDisclaimerTextViaApi
} from '../../testHelpers/info/infoHelper'
import { ReadError } from '../../../src/core/domain/repositories/ReadError'

Expand Down Expand Up @@ -53,7 +55,40 @@ describe('DataverseInfoRepository', () => {
expect(actual).toBe(testMaxEmbargoDurationInMonths)
})
})
describe('getPublishDatasetDisclaimerText', () => {
test('should return error when the setting does not exist', async () => {
const errorExpected: ReadError = new ReadError(
'[404] Setting :PublishDatasetDisclaimerText not found'
)

await expect(sut.getPublishDatasetDisclaimerText()).rejects.toThrow(errorExpected)
})

test('should return text when the setting exists', async () => {
const testPublishDatasetDisclaimerText = 'please read and accept'
await setPublishDatasetDisclaimerTextViaApi(testPublishDatasetDisclaimerText)
const actual = await sut.getPublishDatasetDisclaimerText()

expect(actual).toBe(testPublishDatasetDisclaimerText)
})
})
describe('getDatasetPublishPopupCustomText', () => {
test('should return error when the setting does not exist', async () => {
const errorExpected: ReadError = new ReadError(
'[404] Setting :DatasetPublishPopupCustomText not found'
)

await expect(sut.getDatasetPublishPopupCustomText()).rejects.toThrow(errorExpected)
})

test('should return text when the setting exists', async () => {
const testDatasetPublishPopupCustomText = 'custom publish popup text'
await setDatasetPublishPopupCustomTextViaApi(testDatasetPublishPopupCustomText)
const actual = await sut.getDatasetPublishPopupCustomText()

expect(actual).toBe(testDatasetPublishPopupCustomText)
})
})
describe('getApplicationTermsOfUse', () => {
test('should return no terms message when terms are not set', async () => {
const defaultNoTermsOfUseMessage =
Expand Down
23 changes: 22 additions & 1 deletion test/testHelpers/info/infoHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,28 @@ export const setApplicationTermsOfUseViaApi = async (
}
)
}

export const setDatasetPublishPopupCustomTextViaApi = async (
datasetPublishPopupCustomText: string
): Promise<AxiosResponse> => {
return await axios.put(
`${TestConstants.TEST_API_URL}/admin/settings/:DatasetPublishPopupCustomText`,
datasetPublishPopupCustomText,
{
headers: { 'Content-Type': 'text/plain' }
}
)
}
export const setPublishDatasetDisclaimerTextViaApi = async (
publishDatasetDisclaimerText: string
): Promise<AxiosResponse> => {
return await axios.put(
`${TestConstants.TEST_API_URL}/admin/settings/:PublishDatasetDisclaimerText`,
publishDatasetDisclaimerText,
{
headers: { 'Content-Type': 'text/plain' }
}
)
}
export const deleteApplicationTermsOfUseViaApi = async (): Promise<AxiosResponse> => {
return await axios.delete(`${TestConstants.TEST_API_URL}/admin/settings/:ApplicationTermsOfUse`)
}
72 changes: 72 additions & 0 deletions test/unit/info/DataverseInfoRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,76 @@ describe('DataverseInfoRepository', () => {
expect(error).toBeInstanceOf(Error)
})
})

describe('getDatasetPublishPopupCustomText', () => {
test('should return dataset publish popup custom text on successful response', async () => {
const testPopupText = 'Custom popup text.'
const testSuccessfulResponse = {
data: {
status: 'OK',
data: {
message: testPopupText
}
}
}
jest.spyOn(axios, 'get').mockResolvedValue(testSuccessfulResponse)

const actual = await sut.getDatasetPublishPopupCustomText()

expect(axios.get).toHaveBeenCalledWith(
`${TestConstants.TEST_API_URL}/info/settings/:DatasetPublishPopupCustomText`,
TestConstants.TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG
)
expect(actual).toMatch(testPopupText)
})

test('should return error result on error response', async () => {
jest.spyOn(axios, 'get').mockRejectedValue(TestConstants.TEST_ERROR_RESPONSE)

let error: ReadError | undefined
await sut.getDatasetPublishPopupCustomText().catch((e) => (error = e))

expect(axios.get).toHaveBeenCalledWith(
`${TestConstants.TEST_API_URL}/info/settings/:DatasetPublishPopupCustomText`,
TestConstants.TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG
)
expect(error).toBeInstanceOf(Error)
})
})

describe('getPublishDatasetDisclaimerText', () => {
test('should return publish dataset disclaimer text on successful response', async () => {
const testDisclaimerText = 'Disclaimer text.'
const testSuccessfulResponse = {
data: {
status: 'OK',
data: {
message: testDisclaimerText
}
}
}
jest.spyOn(axios, 'get').mockResolvedValue(testSuccessfulResponse)

const actual = await sut.getPublishDatasetDisclaimerText()

expect(axios.get).toHaveBeenCalledWith(
`${TestConstants.TEST_API_URL}/info/settings/:PublishDatasetDisclaimerText`,
TestConstants.TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG
)
expect(actual).toMatch(testDisclaimerText)
})

test('should return error result on error response', async () => {
jest.spyOn(axios, 'get').mockRejectedValue(TestConstants.TEST_ERROR_RESPONSE)

let error: ReadError | undefined
await sut.getPublishDatasetDisclaimerText().catch((e) => (error = e))

expect(axios.get).toHaveBeenCalledWith(
`${TestConstants.TEST_API_URL}/info/settings/:PublishDatasetDisclaimerText`,
TestConstants.TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG
)
expect(error).toBeInstanceOf(Error)
})
})
})