Use Cases of Editing Guestbook#456
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support in the JavaScript Dataverse client for editing existing Guestbooks (including custom question updates/removals), aligning with Dataverse backend support for PUT /api/guestbooks/{id}.
Changes:
- Added
editGuestbookrepository method, use case, and module exports. - Introduced
EditGuestbookDTOand expandedGuestbookmodel types to allow optional IDs on nested question/option objects. - Added/updated unit + integration tests and updated docs/changelog entries.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/guestbooks/GuestbooksRepository.test.ts | Adds unit coverage for inherited guestbook listing params and editGuestbook request behavior. |
| test/unit/guestbooks/EditGuestbook.test.ts | Adds unit tests for the new EditGuestbook use case behavior and error propagation. |
| test/integration/guestbooks/GuestbooksRepository.test.ts | Adds integration coverage for editing guestbooks, including custom question update/replace/remove scenarios. |
| src/guestbooks/infra/repositories/GuestbooksRepository.ts | Implements editGuestbook via PUT /guestbooks/{id} and supports includeInherited query param for listing. |
| src/guestbooks/index.ts | Wires and exports the new editGuestbook use case and DTO exports. |
| src/guestbooks/domain/useCases/EditGuestbook.ts | Adds the EditGuestbook use case wrapper over the repository method. |
| src/guestbooks/domain/repositories/IGuestbooksRepository.ts | Extends repository contract to include editGuestbook. |
| src/guestbooks/domain/models/Guestbook.ts | Makes nested id fields optional for custom questions/options. |
| src/guestbooks/domain/dtos/EditGuestbookDTO.ts | Introduces the DTO types for guestbook edit payloads. |
| docs/useCases.md | Documents includeInherited and adds an Edit a Guestbook use case section. |
| CHANGELOG.md | Adds an unreleased entry for the new editGuestbook use case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ekraffmiller
left a comment
There was a problem hiding this comment.
Hi Cheng, it looks good! I just have questions about the data sent to the API.
| } | ||
|
|
||
| export interface EditGuestbookDTO { | ||
| id?: number |
There was a problem hiding this comment.
I think it would be good to remove the id from EditGuestbookDTO, since the API endpoint has the id in the URL, and this is duplicate info. Also it removes the possibility that the id in the DTO might not match the id in the url. What do you think?
| nameRequired: boolean | ||
| institutionRequired: boolean | ||
| positionRequired: boolean | ||
| customQuestions: GuestbookCustomQuestion[] |
There was a problem hiding this comment.
since customQuestions are optional in the API, can we make this property optional too?
ekraffmiller
left a comment
There was a problem hiding this comment.
thanks for changes, looks good!
|
tests are passing, ready to merge |
What this PR does / why we need it:
This API allows the user to make edits to an existing Guestbook, including adding and removing Custom Guestbook Questions.
curl -PUT -H "X-Dataverse-key:$API_TOKEN" "$SERVER_URL/api/guestbooks/{ID}" -d "$JSON"When editing, the whole payload should be provided as json format
Which issue(s) this PR closes:
Related Dataverse PRs:
Special notes for your reviewer:
Suggestions on how to test this:
Is there a release notes or changelog update needed for this change?:
yes
Additional documentation: