Skip to content

Commit c3f76f8

Browse files
committed
fix: copilot reviews
1 parent 812dd22 commit c3f76f8

5 files changed

Lines changed: 29 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel
1616
- New Use Case: [Get a Template](./docs/useCases.md#get-a-template) under Templates.
1717
- New Use Case: [Delete a Template](./docs/useCases.md#delete-a-template) under Templates.
1818
- New Use Case: [Update Terms of Access](./docs/useCases.md#update-terms-of-access).
19-
- Guestbooks: Added use cases and repository support for Guestbook CRUD.
19+
- Guestbooks: Added use cases and repository support for guestbook creation, listing, and enabling/disabling.
2020
- Access: Added a dedicated `access` module for guestbook-at-request and download terms/guestbook submission endpoints.
2121

2222
### Changed

docs/useCases.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,7 +2917,13 @@ import { submitGuestbookForDatafilesDownload } from '@iqss/dataverse-client-java
29172917

29182918
submitGuestbookForDatafilesDownload
29192919
.execute([10, 11], {
2920-
guestbookResponse: { answers: [{ id: 123, value: 'Good' }] }
2920+
guestbookResponse: {
2921+
answers: [
2922+
{ id: 123, value: 'Good' },
2923+
{ id: 124, value: ['Multi', 'Line'] },
2924+
{ id: 125, value: 'Yellow' }
2925+
]
2926+
}
29212927
})
29222928
.then((signedUrl: string) => {
29232929
/* ... */
@@ -2937,7 +2943,13 @@ import { submitGuestbookForDatasetDownload } from '@iqss/dataverse-client-javasc
29372943

29382944
submitGuestbookForDatasetDownload
29392945
.execute('doi:10.5072/FK2/XXXXXX', {
2940-
guestbookResponse: { answers: [{ id: 123, value: 'Good' }] }
2946+
guestbookResponse: {
2947+
answers: [
2948+
{ id: 123, value: 'Good' },
2949+
{ id: 124, value: ['Multi', 'Line'] },
2950+
{ id: 125, value: 'Yellow' }
2951+
]
2952+
}
29412953
})
29422954
.then((signedUrl: string) => {
29432955
/* ... */
@@ -2957,7 +2969,13 @@ import { submitGuestbookForDatasetVersionDownload } from '@iqss/dataverse-client
29572969

29582970
submitGuestbookForDatasetVersionDownload
29592971
.execute(10, ':latest', {
2960-
guestbookResponse: { answers: [{ id: 123, value: 'Good' }] }
2972+
guestbookResponse: {
2973+
answers: [
2974+
{ id: 123, value: 'Good' },
2975+
{ id: 124, value: ['Multi', 'Line'] },
2976+
{ id: 125, value: 'Yellow' }
2977+
]
2978+
}
29612979
})
29622980
.then((signedUrl: string) => {
29632981
/* ... */

src/guestbooks/domain/useCases/GetGuestbooksByCollectionId.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { UseCase } from '../../../core/domain/useCases/UseCase'
22
import { IGuestbooksRepository } from '../repositories/IGuestbooksRepository'
33
import { Guestbook } from '../models/Guestbook'
44

5-
export class GetGuestbooksBycollectionId implements UseCase<Guestbook[]> {
5+
export class GetGuestbooksByCollectionId implements UseCase<Guestbook[]> {
66
constructor(private readonly guestbooksRepository: IGuestbooksRepository) {}
77

88
/**

src/guestbooks/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { GuestbooksRepository } from './infra/repositories/GuestbooksRepository'
22
import { CreateGuestbook } from './domain/useCases/CreateGuestbook'
33
import { GetGuestbook } from './domain/useCases/GetGuestbook'
4-
import { GetGuestbooksBycollectionId } from './domain/useCases/GetGuestbooksByCollectionId'
4+
import { GetGuestbooksByCollectionId } from './domain/useCases/GetGuestbooksByCollectionId'
55
import { SetGuestbookEnabled } from './domain/useCases/SetGuestbookEnabled'
66

77
const guestbooksRepository = new GuestbooksRepository()
88

99
const createGuestbook = new CreateGuestbook(guestbooksRepository)
1010
const getGuestbook = new GetGuestbook(guestbooksRepository)
11-
const getGuestbooksBycollectionId = new GetGuestbooksBycollectionId(guestbooksRepository)
11+
const getGuestbooksBycollectionId = new GetGuestbooksByCollectionId(guestbooksRepository)
1212
const setGuestbookEnabled = new SetGuestbookEnabled(guestbooksRepository)
1313

1414
export { createGuestbook, getGuestbook, getGuestbooksBycollectionId, setGuestbookEnabled }

test/unit/guestbooks/GetGuestbooksByDataverseIdentifier.test.ts renamed to test/unit/guestbooks/GetGuestbooksByCollectionId.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ReadError } from '../../../src'
22
import { Guestbook } from '../../../src/guestbooks/domain/models/Guestbook'
33
import { IGuestbooksRepository } from '../../../src/guestbooks/domain/repositories/IGuestbooksRepository'
4-
import { GetGuestbooksBycollectionId } from '../../../src/guestbooks/domain/useCases/GetGuestbooksByCollectionId'
4+
import { GetGuestbooksByCollectionId } from '../../../src/guestbooks/domain/useCases/GetGuestbooksByCollectionId'
55

6-
describe('GetGuestbooksBycollectionId', () => {
6+
describe('GetGuestbooksByCollectionId', () => {
77
const guestbooks: Guestbook[] = [
88
{
99
id: 12,
@@ -24,7 +24,7 @@ describe('GetGuestbooksBycollectionId', () => {
2424
const repository: IGuestbooksRepository = {} as IGuestbooksRepository
2525
repository.getGuestbooksBycollectionId = jest.fn().mockResolvedValue(guestbooks)
2626

27-
const sut = new GetGuestbooksBycollectionId(repository)
27+
const sut = new GetGuestbooksByCollectionId(repository)
2828
const actual = await sut.execute(collectionId)
2929

3030
expect(repository.getGuestbooksBycollectionId).toHaveBeenCalledWith(collectionId)
@@ -34,7 +34,7 @@ describe('GetGuestbooksBycollectionId', () => {
3434
test('should throw ReadError when repository fails', async () => {
3535
const repository: IGuestbooksRepository = {} as IGuestbooksRepository
3636
repository.getGuestbooksBycollectionId = jest.fn().mockRejectedValue(new ReadError())
37-
const sut = new GetGuestbooksBycollectionId(repository)
37+
const sut = new GetGuestbooksByCollectionId(repository)
3838

3939
await expect(sut.execute(collectionId)).rejects.toThrow(ReadError)
4040
})

0 commit comments

Comments
 (0)