-
Notifications
You must be signed in to change notification settings - Fork 0
Add comprehensive test coverage and WebSocket notifications for CalDAV due date updates #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: dkhalife <1736645+dkhalife@users.noreply.github.com>
Co-authored-by: dkhalife <1736645+dkhalife@users.noreply.github.com>
Co-authored-by: dkhalife <1736645+dkhalife@users.noreply.github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Co-authored-by: dkhalife <1736645+dkhalife@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive test coverage for CalDAV due date parsing and generation functionality, while also implementing real-time WebSocket notifications when tasks are updated via the CalDAV API.
Key Changes:
- Added 6 new tests in
parser_test.gocovering all due date parsing scenarios (timestamp format, date-only format, nil handling, updates, and removals) - Added 3 new tests in
caldav_test.gofor VTODO generation with due dates and LAST-MODIFIED timestamps - Enhanced
CalDAVAPIHandlerto broadcast WebSocket notifications when tasks are updated through CalDAV
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apiserver/internal/utils/caldav/parser_test.go | New comprehensive test suite for ParseVTODO function covering all due date scenarios |
| apiserver/internal/repos/caldav/caldav_test.go | Added tests for generateVTODO with due dates and timestamp verification |
| apiserver/internal/apis/caldav.go | Integrated WebSocket server to broadcast task updates after CalDAV PUT operations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Overview
The CalDAV API already supported updating task due dates through PUT requests with VTODO data, but lacked comprehensive test coverage and real-time notification support. This PR enhances the implementation with proper testing and real-time updates.
What's Changed
1. Added Comprehensive Test Coverage
Created
parser_test.gowith 6 new tests covering all due date parsing scenarios:DUE:20230115T120000Z)DUE:20230116)Enhanced
caldav_test.gowith 3 additional tests:2. Added Real-time WebSocket Notifications
Enhanced
CalDAVAPIHandlerto broadcast WebSocket notifications when tasks are updated via CalDAV:This ensures that when a task is updated through CalDAV synchronization, all connected web clients receive real-time updates, providing a consistent experience across the REST API and CalDAV endpoints.
How It Works
When a CalDAV client updates a task's due date:
/dav/tasks/{taskId}.icswith VTODO containing a DUE fieldParseVTODOextracts the title and due date (supports both full timestamp and date-only formats)UpdateTaskupdates the task's NextDueDate fieldUpsertTaskpersists changes (GORM automatically updates the UpdatedAt timestamp)Supported due date formats:
DUE:20230115T120000ZDUE:20230116Testing
Backward Compatibility
All changes are backward compatible. The WebSocket broadcasting is non-blocking and includes graceful error handling, so CalDAV updates will succeed even if WebSocket notifications fail.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.