Commit 764d091
fix: google revocation handling (#1484)
* refactor(issue-templates): simplify feature request and bug report templates
- Removed unnecessary emoji from template names for a cleaner presentation.
- Eliminated the priority dropdown from the feature request template to streamline the submission process.
- Updated the bug report template to remove the emoji, enhancing consistency across issue templates.
- Adjusted the configuration file to reflect these changes, ensuring clarity in the issue submission process.
* test(socket): enhance SocketProvider tests with async act calls
- Updated SocketProvider tests to utilize `act` for asynchronous callback invocations, ensuring proper handling of state updates during testing.
- Improved test reliability by wrapping callback executions in `act`, aligning with React's testing best practices.
* test(socket): add race condition handling test for useGcalSync
- Introduced a new test case to verify the correct handling of import end events when the awaitingImportResults state changes mid-render.
- Utilized a ref to prevent stale closures, ensuring that the correct state is referenced during socket event processing.
- Enhanced the reliability of the useGcalSync hook by ensuring it properly processes events even when state changes occur asynchronously.
* delete(svg): remove unused circle.svg file
- Deleted the circle.svg file from the public SVG assets as it is no longer needed in the project.
- This cleanup helps streamline the asset management and reduces unnecessary file clutter.
* fix(socket): address PR review comments for useGcalSync
- Update ref synchronously during render instead of in useEffect
to fully eliminate race condition window
- Rename misleading test name (timeout -> successfully)
- Fix test assertions to validate action creator calls directly
instead of using unused variable and dispatch-based assertions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor(sync): rename awaitingImportResults to isImportPending
- Updated state management and selectors to reflect the new naming convention for clarity.
- Adjusted related components and tests to ensure consistency with the updated state name.
- This change enhances code readability and aligns with the overall naming strategy in the project.
* refactor(socket): simplify reconnect logic and update test case
- Removed the 1-second delay in the reconnect function, allowing for immediate reconnection after disconnection.
- Updated the corresponding test case to reflect the change in behavior, ensuring it accurately tests the immediate reconnection functionality.
- This change enhances the responsiveness of the socket client and improves the clarity of the test case.
* refactor(tests): update useGcalSync tests to remove fake timers
- Removed the use of fake timers in the tests for useGcalSync, simplifying the test setup.
- Updated type definitions for event handler variables to allow for undefined values, enhancing type safety.
- This change improves test clarity and aligns with best practices for handling asynchronous events in React testing.
* test(socket): add integration tests for Google Calendar re-authentication flow
- Introduced a new test suite for the Google Calendar re-authentication process, validating user experience during import operations.
- Implemented tests to ensure the spinner visibility during import initiation, handling of socket events, and correct state updates upon import completion.
- Enhanced test reliability by utilizing `act` for asynchronous operations and capturing socket event callbacks.
- This addition improves coverage for the re-authentication flow and ensures a seamless user experience during Google Calendar synchronization.
* refactor(sync): rename setAwaitingImportResults to setIsImportPending
- Updated the Redux action and corresponding function names to improve clarity and consistency in the import state management.
- Adjusted all related components and tests to reflect the new naming convention, ensuring seamless integration across the codebase.
- This change enhances code readability and aligns with the overall naming strategy in the project.
* feat(errors): enhance Google token error handling and add corresponding tests
- Updated the error handling for invalid Google tokens to prune user data and notify clients via WebSocket.
- Modified the response to include a specific payload indicating Google access has been revoked.
- Added unit tests to verify the new error handling behavior, ensuring proper response and state management during Google token invalidation.
- This change improves user experience by providing clearer feedback on session status and data management.
* feat(user): implement pruneGoogleData method and corresponding tests
- Added the pruneGoogleData method to UserService, which stops Google Calendar sync and removes the Google field from the user document.
- Introduced a new test suite for pruneGoogleData, verifying that user data is correctly pruned and associated events are deleted.
- This enhancement improves data management and user experience by ensuring that outdated Google data is effectively removed.
* feat(sync): implement Google revoked access handling and notifications
- Added functionality to handle Google access revocation by pruning user data and notifying clients via WebSocket.
- Updated SyncController to respond with a structured message when access is revoked, improving user feedback.
- Introduced tests to verify the new behavior, ensuring proper handling of revoked access scenarios.
- This enhancement improves data management and user experience by effectively managing Google Calendar access changes.
* feat(api): implement Google revoked access handling in CompassApi
- Added handling for Google access revocation in CompassApi, ensuring users remain logged in while displaying a toast notification.
- Introduced a new utility function to extract error codes from Axios errors, enhancing error management.
- Updated tests to verify the new behavior, including scenarios for Google revoked access.
- This enhancement improves user experience by providing clear feedback and managing Google Calendar data effectively.
* chore: fix conflicts in useGcalSync
* refactor: revert try/catch in event.controller
* test(compass): enhance Google revoked access handling tests
- Updated the test for handling Google access revocation to ensure proper behavior on 401/410 responses.
- Introduced a new payload structure for the GOOGLE_REVOKED error code and verified that the correct toast notification is displayed.
- Improved test coverage by iterating over multiple status codes to validate consistent error handling and user feedback.
* test(socket): enhance useGcalSync tests with timer management
- Added beforeEach and afterEach hooks to manage fake timers in the useGcalSync test suite.
- This change improves test reliability by ensuring proper timer handling during asynchronous operations.
* refactor(errors): improve Google error handling type safety
- Updated error handling functions to accept `unknown` type instead of specific error types, enhancing type safety and flexibility.
- Adjusted the `handleExpressError` and `isFullSyncRequired` functions to work with the new type definitions, ensuring consistent error management across the application.
- This change improves code robustness and prepares the error handling system for a wider range of error scenarios.
* feat(sync): implement deleteWatchesByUser and enhance Google error handling
- Introduced the deleteWatchesByUser method in SyncService to remove watch records for a specific user, improving data management.
- Added createGoogleError utility for generating mock Google errors, enhancing test coverage and error handling.
- Updated gcal.utils to include getGoogleErrorStatus for better error status retrieval from Google errors.
- Enhanced tests for SyncService to validate behavior when handling Google errors, ensuring robust error management.
* feat(auth): implement handleGoogleRevoked utility for improved Google access management
- Introduced the handleGoogleRevoked function to centralize handling of Google access revocation, including toast notifications and event management.
- Updated CompassApi and useGcalSync to utilize the new utility, ensuring consistent behavior across the application.
- Enhanced tests for handleGoogleRevoked to verify correct toast display and event dispatching, improving test coverage and reliability.
- This change enhances user experience by providing clear feedback and managing Google Calendar data effectively upon access revocation.
* fix(event-test-utils): update keyboard shortcut for saving event forms
- Changed the keyboard shortcut for saving event forms from "Enter" to "Meta+Enter" to accommodate different operating systems (Cmd+Enter on Mac, Win+Enter on Windows/Linux).
- This update ensures consistent behavior across platforms when saving event data.
* refactor(event-form): unify keyboard shortcuts for form submission
- Updated keyboard shortcuts for submitting event forms to use "mod+enter" for consistency across platforms (Cmd+Enter on Mac, Ctrl+Enter on Windows/Linux).
- Adjusted related tests and utility functions to reflect the new shortcut, ensuring reliable behavior in form submissions.
- This change enhances user experience by providing a consistent interaction model across different operating systems.
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent ddd0437 commit 764d091
30 files changed
Lines changed: 801 additions & 50 deletions
File tree
- e2e/utils
- packages
- backend/src
- __tests__/mocks.gcal/errors
- common
- errors/handlers
- services/gcal
- servers/websocket
- sync
- controllers
- services
- user/services
- core/src
- constants
- types
- web/src
- common
- apis
- constants
- utils/auth
- ducks/events
- context
- slices
- socket/hooks
- views
- Calendar/hooks
- Forms
- EventForm
- SomedayEventForm
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
216 | 218 | | |
217 | 219 | | |
218 | 220 | | |
| |||
Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
Lines changed: 12 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
94 | | - | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| |||
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
107 | | - | |
| 109 | + | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
111 | 113 | | |
112 | 114 | | |
113 | | - | |
| 115 | + | |
| 116 | + | |
114 | 117 | | |
115 | | - | |
116 | | - | |
117 | | - | |
| 118 | + | |
| 119 | + | |
118 | 120 | | |
119 | 121 | | |
120 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
121 | 126 | | |
122 | 127 | | |
123 | 128 | | |
| |||
Lines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
| 4 | + | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| 12 | + | |
| 13 | + | |
8 | 14 | | |
9 | 15 | | |
10 | 16 | | |
| |||
38 | 44 | | |
39 | 45 | | |
40 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
41 | 81 | | |
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
21 | 36 | | |
22 | 37 | | |
23 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 45 | + | |
| 46 | + | |
49 | 47 | | |
50 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
54 | | - | |
| 57 | + | |
55 | 58 | | |
56 | 59 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
63 | 72 | | |
64 | 73 | | |
65 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
66 | 79 | | |
67 | 80 | | |
68 | 81 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
239 | 244 | | |
240 | 245 | | |
241 | 246 | | |
Lines changed: 56 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| 38 | + | |
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
| |||
184 | 191 | | |
185 | 192 | | |
186 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
187 | 242 | | |
188 | 243 | | |
189 | 244 | | |
| |||
0 commit comments