Commit cf07f3c
feat(user-metadata): enhance Google metadata handling and update tests (#1531)
* feat(user-metadata): enhance Google metadata handling and update tests
- Updated the user metadata service to assess Google connection and sync status, enriching metadata with connection status and sync state.
- Introduced a new driver for user metadata service tests to streamline testing of metadata updates.
- Modified existing tests to validate new Google metadata assessment logic, ensuring accurate handling of connection and sync states.
- Refactored user driver to support conditional user creation based on Google connection status.
- Cleaned up WebSocket server logic by removing deprecated Google token status checks on connection.
* fix(backend): guard stale watch metadata assessment errors
Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
* fix(backend): prevent concurrent sync by skipping assessment in importIncremental
Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
* fix(sync,web): recover invalid sync tokens and handle connected status
- fix(sync): force-restart sync when Google returns 410 error instead of delegating to assessGoogleMetadata, which checks token existence not validity
- fix(web): add catch-all for connected users with unhandled sync status to show correct label
Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
* fix(web): remove redundant syncStatus check in useConnectGoogle hook
Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
* feat(sync): enhance gcal import handling in SyncController tests
- Introduced new functions to wait for Google Calendar import start and end events.
- Updated tests to utilize these functions for improved clarity and reliability.
- Refactored import result parsing for better type safety and readability.
- Adjusted test assertions to ensure correct behavior during import processes.
* fix(util): improve error handling in waitUntilEvent utility
- Added a catch block to handle errors from the afterEvent promise, ensuring proper rejection with a standardized Error object.
- Enhanced error handling in the beforeEvent callback to ensure consistent error reporting.
* feat(auth): enhance Google Calendar connection handling in useConnectGoogle hook
- Refactored the useConnectGoogle hook to return a structured configuration for command actions and sidebar status.
- Updated tests to reflect changes in the hook's return structure, ensuring accurate assertions for various connection states.
- Improved the SidebarIconRow component to utilize the new configuration for displaying Google Calendar connection status.
- Added a disabled state for the TooltipWrapper when the Google Calendar is connected or syncing.
* feat(sync): enhance Google Calendar import functionality and testing
- Added a `force` option to the `importGCal` method in `SyncControllerDriver` to allow forced imports.
- Introduced a new `WatchDriver` for managing watch collection tests, improving test isolation and flexibility.
- Updated `importGCal` method in `SyncController` to handle the `force` parameter, enabling forced sync operations.
- Enhanced tests in `sync.controller.test.ts` to verify forced import behavior and ensure correct handling of completed sync states.
- Improved user metadata service to return healthy status without active watches when not using HTTPS.
- Updated user service tests to validate event sync token persistence without HTTPS, ensuring local sync health.
* feat(sync): improve Google Calendar repair functionality in useConnectGoogle hook
- Enhanced the useConnectGoogle hook to manage Google Calendar repair state, integrating a new repair action that triggers forced imports.
- Updated the SyncApi to accept an options parameter for the importGCal method, allowing for forced sync operations.
- Refactored tests for useConnectGoogle and related components to validate the new repair logic and ensure accurate assertions for various connection states.
- Improved user interface feedback during repair processes, including updated tooltips and sidebar statuses.
- Ensured that socket emissions for user metadata fetching are correctly triggered during import events.
* docs(tests): update testing guidelines to avoid direct persistence layer imports
- Added a note in testing documentation to discourage importing `mongoService` or other persistence layers directly in tests.
- Recommended using test drivers (e.g., `UserDriver`, `WatchDriver`) to maintain test agnosticism towards the backing store, facilitating easier transitions away from MongoDB in the future.
* fix(web): use state-specific labels for Google Calendar command palette
Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
* test(web): update test assertions to match state-specific Google Calendar labels
Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
* fix(web): prioritize reconnect_required over importing state in Google UI
fix(backend): add race condition check before scheduling Google repair
fix(web): only close command palette when repair triggered from command palette
Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
* fix(backend): remove unused driver methods after local refactor
Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
* fix(husky): run lint-staged in quiet mode during pre-commit hook
* fix(sync): enhance Google Calendar sync handling and notification processing
- Updated SyncController to skip recovery if a full import is already active for the user.
- Refactored syncService to ignore stale notifications when no exact watch record exists, improving notification handling.
- Enhanced tests to validate the new behavior for handling Google Calendar notifications and sync states.
- Improved user metadata service to return appropriate sync statuses without scheduling unnecessary repairs.
* fix(user-metadata): refactor user metadata retrieval and update logic
- Introduced a new type for the response structure from SupertokensUserMetadata, improving type safety.
- Updated the getStoredUserMetadata and updateUserMetadata methods to handle the new response format, ensuring proper error handling and returning the correct metadata.
- Enhanced code readability by simplifying the response handling process.
* feat(user-metadata): implement user metadata refresh and loading state management
- Introduced a new utility function, `refreshUserMetadata`, to handle user metadata retrieval and state updates in the Redux store.
- Enhanced the `userMetadataSlice` to include loading states, allowing for better user experience during metadata fetching.
- Updated the `SessionProvider` to refresh user metadata upon session initialization and when a session already exists.
- Refactored the `useConnectGoogle` hook to incorporate user metadata status, improving the handling of Google Calendar connection states.
- Added tests for the new user metadata utility and updated existing tests to ensure proper functionality and state management.
* test(DayCmdPalette): enhance tests for command palette button states
- Mocked the `react-cmdk` library to provide a more accurate testing environment for the command palette component.
- Updated test assertions to use `getByRole` for button state checks, ensuring better accessibility compliance and clarity in tests.
- Improved the handling of disabled button states in tests for Google Calendar connection and syncing actions.
* refactor(google-auth): update socket handling on Google revocation
- Removed the use of `FETCH_USER_METADATA` in favor of directly reconnecting the socket to ensure a fresh session after Google revocation.
- Updated the test case to reflect the new behavior, verifying that the socket reconnects instead of emitting a metadata fetch event.
- Improved code clarity by simplifying the revocation handling logic.
* feat(websocket): enhance Google Calendar import handling with structured payloads
- Introduced a new type, `ImportGCalEndPayload`, to standardize the payload structure for Google Calendar import completion events.
- Updated the `handleImportGCalEnd` method to accept the new payload type, improving type safety and clarity.
- Refactored various components and tests to utilize the structured payload, ensuring consistent handling of import results and error messages.
- Enhanced tests to validate the new payload structure and its impact on the import flow.
* feat(google-auth): enhance Google sign-in handling with new utility functions
- Introduced utility functions for managing Google sign-in success and session user ID resolution, improving the handling of Google authentication flows.
- Updated the `signInUpPOST` API implementation to integrate Google sign-in success handling, ensuring proper session management.
- Added tests for the new utility functions to validate their behavior in various scenarios, enhancing overall test coverage.
- Refactored the `useGoogleAuth` hook to support reconnect intents, improving user experience during Google Calendar reconnections.
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>1 parent 7129133 commit cf07f3c
59 files changed
Lines changed: 2925 additions & 690 deletions
File tree
- .cursorrules
- .husky
- docs
- packages
- backend/src
- __tests__/drivers
- common/middleware
- servers/websocket
- sync
- controllers
- services
- user/services
- core/src
- types
- util
- web/src
- __tests__/utils/state
- auth
- google
- hooks/oauth
- session
- common
- apis
- utils/toast
- components
- Tooltip
- oauth
- ducks/auth
- selectors
- slices
- socket
- hooks
- provider
- store
- views
- Calendar/components/Sidebar/SidebarIconRow
- CmdPalette
- Day/components
- Now/components
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
| 213 | + | |
212 | 214 | | |
213 | 215 | | |
214 | 216 | | |
| 217 | + | |
215 | 218 | | |
216 | 219 | | |
217 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
Lines changed: 2 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | 3 | | |
8 | 4 | | |
9 | 5 | | |
| |||
12 | 8 | | |
13 | 9 | | |
14 | 10 | | |
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 | 11 | | |
43 | 12 | | |
44 | 13 | | |
| |||
64 | 33 | | |
65 | 34 | | |
66 | 35 | | |
| 36 | + | |
67 | 37 | | |
68 | 38 | | |
69 | 39 | | |
70 | 40 | | |
71 | 41 | | |
72 | 42 | | |
| 43 | + | |
73 | 44 | | |
74 | 45 | | |
75 | 46 | | |
| |||
Lines changed: 19 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
41 | | - | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| |||
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
52 | 62 | | |
53 | 63 | | |
54 | 64 | | |
| |||
67 | 77 | | |
68 | 78 | | |
69 | 79 | | |
70 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
71 | 83 | | |
72 | 84 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 36 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | | - | |
19 | 17 | | |
20 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
116 | 145 | | |
117 | 146 | | |
118 | 147 | | |
| |||
174 | 203 | | |
175 | 204 | | |
176 | 205 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
| |||
Lines changed: 101 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 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
0 commit comments