Skip to content

Commit fc6a700

Browse files
committed
fix: testcase and reset the form after submit
1 parent d18f949 commit fc6a700

7 files changed

Lines changed: 15 additions & 10 deletions

File tree

docs/useCases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ getDatasetDownloadCount
859859

860860
_See [use case](../src/datasets/domain/useCases/GetDatasetDownloadCount.ts) implementation_.
861861

862-
The `datasetId` parameter is a number for numeric identifiers.
862+
The `datasetId` parameter is a number for numeric identifiers or string for persistent identifiers.
863863
The `includeMDC` parameter is optional.
864864

865865
- Setting `includeMDC` to True will ignore the `MDCStartDate` setting and return a total count.

src/datasets/domain/repositories/IDatasetsRepository.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export interface IDatasetsRepository {
5353
datasetVersionId: string,
5454
deaccessionDTO: DatasetDeaccessionDTO
5555
): Promise<void>
56-
getDatasetDownloadCount(datasetId: number, includeMDC?: boolean): Promise<DatasetDownloadCount>
56+
getDatasetDownloadCount(
57+
datasetId: number | string,
58+
includeMDC?: boolean
59+
): Promise<DatasetDownloadCount>
5760
getDatasetVersionsSummaries(datasetId: number | string): Promise<DatasetVersionSummaryInfo[]>
5861
}

src/datasets/domain/useCases/GetDatasetDownloadCount.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export class GetDatasetDownloadCount implements UseCase<DatasetDownloadCount> {
1212
/**
1313
* Returns a DatasetDownloadCount instance, with dataset id, count and MDCStartDate(optional).
1414
*
15-
* @param {number} [datasetId] - The dataset identifier.
15+
* @param {number | string} [datasetId] - The dataset identifier.
1616
* @param {boolean} [includeMDC(optional)] - Indicates whether to consider include counts from MDC start date or not. The default value is false
1717
* @returns {Promise<DatasetDownloadCount>}
1818
*/
19-
async execute(datasetId: number, includeMDC?: boolean): Promise<DatasetDownloadCount> {
19+
async execute(datasetId: number | string, includeMDC?: boolean): Promise<DatasetDownloadCount> {
2020
return await this.datasetsRepository.getDatasetDownloadCount(datasetId, includeMDC)
2121
}
2222
}

src/datasets/infra/repositories/DatasetsRepository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,13 @@ export class DatasetsRepository extends ApiRepository implements IDatasetsReposi
239239
}
240240

241241
public async getDatasetDownloadCount(
242-
datasetId: number,
242+
datasetId: number | string,
243243
includeMDC?: boolean
244244
): Promise<DatasetDownloadCount> {
245245
const queryParams = includeMDC !== undefined ? { includeMDC } : {}
246246

247247
return this.doGet(
248-
this.buildApiEndpoint(this.datasetsResourceName, `${datasetId}/download/count`),
248+
this.buildApiEndpoint(this.datasetsResourceName, `download/count`, datasetId),
249249
true,
250250
queryParams
251251
)

test/environment/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ services:
3232
-Ddataverse.files.localstack1.access-key=default
3333
-Ddataverse.files.localstack1.secret-key=default
3434
ports:
35-
- '8080:8080'
35+
- '8081:8080'
3636
networks:
3737
- dataverse
3838
depends_on:

test/integration/datasets/DatasetsRepository.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,9 @@ describe('DatasetsRepository', () => {
11061106
expect(actual[1].versionNumber).toBe('1.0')
11071107
expect(actual[1].summary).toBe(DatasetVersionSummaryStringValues.firstPublished)
11081108

1109-
await deletePublishedDatasetViaApi(testDatasetIds.persistentId)
1109+
// await deletePublishedDatasetViaApi(testDatasetIds.persistentId)
1110+
console.log('od', testDatasetIds.numericId)
1111+
console.log('X-Dataverse-Key', process.env.TEST_API_KEY)
11101112
})
11111113
})
11121114

test/unit/datasets/DatasetsRepository.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,13 +1017,13 @@ describe('DatasetsRepository', () => {
10171017
})
10181018
})
10191019

1020-
describe('getDatasetDownloaCount', () => {
1020+
describe('getDatasetDownloadCount', () => {
10211021
const testDatasetDownloadCount: DatasetDownloadCount = {
10221022
id: testDatasetModel.id,
10231023
downloadCount: 1,
10241024
MDCStartDate: '2021-01-01'
10251025
}
1026-
test('should return citation when response is successful', async () => {
1026+
test('should return download count when response is successful', async () => {
10271027
jest.spyOn(axios, 'get').mockResolvedValue({ data: testDatasetDownloadCount })
10281028

10291029
const actual = await sut.getDatasetDownloadCount(testDatasetModel.id)

0 commit comments

Comments
 (0)