Skip to content

Commit aa63e2b

Browse files
authored
fix(web): sync local events before google connect refresh (#1582)
* feat(auth): enhance Google connection handling with local events synchronization - Integrated local events synchronization into the Google connection process, ensuring that local events are synced before connecting to Google. - Added error handling to display a toast notification if local event synchronization fails, preventing the connection to Google in such cases. - Updated tests to verify the new synchronization logic and error handling, ensuring robust functionality in the authentication flow. * feat(auth): implement syncPendingLocalEvents for improved local event handling - Introduced syncPendingLocalEvents function to manage synchronization of local events with error handling and Redux dispatching. - Updated authentication flow to utilize syncPendingLocalEvents, ensuring local events are synced before completing Google authentication. - Enhanced tests to cover new synchronization logic and error handling scenarios, improving overall robustness of the authentication process. * feat(auth): refactor Google connection handling and introduce new hooks - Refactored the Google connection logic into a dedicated hook, `useConnectGoogle`, to streamline the authentication process and improve code organization. - Added utility functions for building Google connection requests and managing UI states related to Google Calendar connections. - Updated error handling for Google Calendar repair messages and ensured proper integration with Redux state management. - Introduced comprehensive tests for the new hook and its functionalities, enhancing overall test coverage and reliability. - Adjusted imports across components to utilize the new hook structure, ensuring consistent usage throughout the application. * fix(auth): correct Google Calendar repair dispatch logic - Updated the `useConnectGoogle` hook to ensure the `closeCmdPalette` action is dispatched correctly during the Google repair process. - Refactored related tests to reflect the changes in dispatch expectations, enhancing the accuracy of the test coverage for Google connection handling. * feat(auth): implement useCompleteAuthentication and related tests - Introduced the `useCompleteAuthentication` hook to streamline the authentication process, marking users as authenticated and syncing local events. - Added comprehensive tests for the new hook, ensuring proper functionality and integration with Redux state management. - Updated imports across components to utilize the new hook structure, enhancing code organization and maintainability. - Refactored existing authentication logic to leverage the new hook, improving overall user experience during the authentication flow. * feat(auth): refactor Google authentication to use GoogleAuthConfig - Replaced the SignInUpInput type with GoogleAuthConfig in the authentication logic to better align with the new Google authentication structure. - Updated related tests to reflect the changes in data types, ensuring consistency across the authentication flow. - Introduced a new GoogleAuthConfig type definition to encapsulate the necessary parameters for Google authentication. - Refactored imports and function signatures across various components and hooks to utilize the new configuration type, enhancing code clarity and maintainability. * refactor(auth): update Google login mock paths for consistency - Changed the import paths for the `useGoogleLogin` mock to align with the new directory structure. - Updated related test files to reflect the new import paths, ensuring consistency across the authentication testing suite. * feat(auth): add GoogleButton component for Google sign-in - Introduced a new `GoogleButton` component that features a monochrome Google "G" logo and adheres to Google's design guidelines. - The button includes customizable props for click handling, disabled state, label, and inline styles. - Removed the obsolete `ouath.types.ts` file to streamline the codebase. * fix(auth): update GoogleButton mock path in tests - Changed the import path for the `GoogleButton` mock in the `AuthModal.test.tsx` file to reflect the new directory structure, ensuring consistency with recent component refactoring. * fix(auth): update onSuccess handler to return boolean for auth flow control - Modified the `onSuccess` callback in `useGoogleAuth` to return a boolean value, allowing for better control over the authentication flow. - Updated the `useConnectGoogle` hook to handle the new return value, ensuring proper state reset when authentication is not completed. - Added a test case to verify the behavior when the custom success handler returns false, ensuring the authentication state is reset correctly. * refactor(auth): streamline Google event synchronization process - Removed the direct call to `syncCompassEventsToGoogle` from the `GoogleAuthService` and integrated it into the `UserService` during the Google Calendar sync process. - Updated the test cases for `GoogleAuthService` to reflect changes in event synchronization logic. - Added the `syncCompassEventsToGoogle` function to the `EventService`, encapsulating the logic for syncing Compass events to Google Calendar. - Enhanced error handling for event synchronization in the `UserService`, ensuring robust logging for failures. * feat(sync): implement Google Calendar synchronization in SyncService - Added `startGoogleCalendarSync` method to `SyncService` for initializing calendars, importing events, and managing synchronization tokens. - Updated tests in `sync.service.test.ts` to validate the new synchronization logic, ensuring watches are created only after successful imports. - Refactored `UserService` to utilize `SyncService` for Google Calendar sync, enhancing code organization and reducing duplication. - Mocked `isUsingHttps` in tests to simulate different environments during synchronization. * refactor(sync): migrate Google Calendar sync logic from UserService to SyncService - Replaced calls to `userService.restartGoogleCalendarSync` with `syncService.restartGoogleCalendarSync` across multiple files, centralizing the synchronization logic within the SyncService. - Updated tests to reflect the new structure, ensuring that the sync functionality is properly validated in the context of the SyncService. - Enhanced error handling and logging during the Google Calendar sync process, improving overall robustness and maintainability of the synchronization workflow. * refactor(sync): move syncCompassEventsToGoogle function to SyncService - Transferred the `syncCompassEventsToGoogle` function from `EventService` to `SyncService`, centralizing the synchronization logic for Compass events. - Updated imports and adjusted the function's implementation to fit within the new service structure, ensuring consistency and maintainability. - Enhanced the overall organization of the codebase by consolidating event synchronization responsibilities within the `SyncService`. * chore(ci): upgrade GitHub Actions to use checkout and setup-node v6 - Updated the `checkout` action from v4 to v6 in both `test-e2e.yml` and `test-unit.yml` workflows for improved performance and features. - Upgraded the `setup-node` action from v4 to v6, ensuring compatibility with the latest Node.js version and enhancing caching capabilities for Yarn. * refactor(event): simplify title submission logic in fillTitleAndSaveWithKeyboard function - Updated the title submission method in the `fillTitleAndSaveWithKeyboard` function to use a plain Enter key instead of ControlOrMeta+Enter, improving reliability on Linux CI environments. - Adjusted comments to clarify the behavior of hotkeys in the EventForm, ensuring consistency with related test cases. * refactor(event): enhance title submission reliability in fillTitleAndSaveWithKeyboard function - Updated the title submission logic to use Control+Enter instead of plain Enter, improving reliability across different operating systems in CI environments. - Revised comments to clarify the handling of hotkeys and ensure consistency with the EventForm's behavior. * refactor(event): improve title submission method and enhance code clarity - Introduced a new helper function, `fillTitleAndSaveEventForm`, to streamline the title submission process in the event form. - Updated `fillTitleAndSaveWithMouse` and `fillTitleAndSaveWithKeyboard` to utilize the new helper function, improving code maintainability. - Added detailed comments to clarify the submission process and the rationale behind using the Save control for reliability in CI environments. * refactor(event): unify title submission method across event tests - Replaced individual title submission methods (`fillTitleAndSaveWithMouse` and `fillTitleAndSaveWithKeyboard`) with a single `fillTitleAndSaveEventForm` function across all event-related test files. - Updated all relevant test cases to utilize the new unified method, enhancing code maintainability and reducing duplication. - Improved the reliability of the title submission process by ensuring consistent handling across different interaction types. * refactor(sync): change export to const for syncCompassEventsToGoogle function - Updated the `syncCompassEventsToGoogle` function from an exported function to a constant within the `SyncService` class, improving encapsulation and code organization. - This change enhances maintainability by keeping the function scoped within the service, aligning with the overall structure of the codebase.
1 parent 7250799 commit aa63e2b

File tree

64 files changed

+1227
-973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1227
-973
lines changed

.github/workflows/test-e2e.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ jobs:
1313

1414
steps:
1515
- name: Check out repository
16-
uses: actions/checkout@v4
16+
uses: actions/checkout@v6
1717

1818
- name: Enable Corepack
1919
run: corepack enable
2020

2121
- name: Set up Node.js
22-
uses: actions/setup-node@v4
22+
uses: actions/setup-node@v6
2323
with:
2424
node-version: 24
2525
cache: yarn

.github/workflows/test-unit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ jobs:
1212

1313
steps:
1414
- name: Check out Git repository
15-
uses: actions/checkout@v4
15+
uses: actions/checkout@v6
1616

1717
- name: Enable Corepack
1818
run: corepack enable
1919

2020
- name: Install Node.js and Yarn
21-
uses: actions/setup-node@v4
21+
uses: actions/setup-node@v6
2222
with:
2323
node-version: 24
2424
cache: "yarn"

docs/features/google-sync-and-websocket-flow.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,20 @@ Source files:
414414
Examples:
415415

416416
```json
417-
{ "operation": "REPAIR", "status": "COMPLETED", "eventsCount": 42, "calendarsCount": 3 }
417+
{
418+
"operation": "REPAIR",
419+
"status": "COMPLETED",
420+
"eventsCount": 42,
421+
"calendarsCount": 3
422+
}
418423
```
419424

420425
```json
421-
{ "operation": "INCREMENTAL", "status": "ERRORED", "message": "Incremental Google Calendar sync failed for user: 123" }
426+
{
427+
"operation": "INCREMENTAL",
428+
"status": "ERRORED",
429+
"message": "Incremental Google Calendar sync failed for user: 123"
430+
}
422431
```
423432

424433
### Repair Failure Messaging

e2e/allday/create-allday-event-keyboard.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { test } from "@playwright/test";
22
import {
33
createEventTitle,
44
expectAllDayEventVisible,
5-
fillTitleAndSaveWithKeyboard,
5+
fillTitleAndSaveEventForm,
66
openAllDayEventFormWithKeyboard,
77
prepareCalendarPage,
88
} from "../utils/event-test-utils";
@@ -16,7 +16,7 @@ test("should create an all-day event using keyboard interaction", async ({
1616

1717
const title = createEventTitle("All-Day Event");
1818
await openAllDayEventFormWithKeyboard(page);
19-
await fillTitleAndSaveWithKeyboard(page, title);
19+
await fillTitleAndSaveEventForm(page, title);
2020

2121
await expectAllDayEventVisible(page, title);
2222
});

e2e/allday/create-allday-event-mouse.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { test } from "@playwright/test";
22
import {
33
createEventTitle,
44
expectAllDayEventVisible,
5-
fillTitleAndSaveWithMouse,
5+
fillTitleAndSaveEventForm,
66
openAllDayEventFormWithMouse,
77
prepareCalendarPage,
88
} from "../utils/event-test-utils";
@@ -19,7 +19,7 @@ test("should create an all-day event using mouse interaction", async ({
1919

2020
const title = createEventTitle("All-Day Event");
2121
await openAllDayEventFormWithMouse(page);
22-
await fillTitleAndSaveWithMouse(page, title);
22+
await fillTitleAndSaveEventForm(page, title);
2323

2424
await expectAllDayEventVisible(page, title);
2525
});

e2e/allday/delete-allday-event-keyboard.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
deleteEventWithKeyboard,
55
expectAllDayEventMissing,
66
expectAllDayEventVisible,
7-
fillTitleAndSaveWithKeyboard,
7+
fillTitleAndSaveEventForm,
88
openAllDayEventFormWithKeyboard,
99
openEventForEditingWithKeyboard,
1010
prepareCalendarPage,
@@ -19,7 +19,7 @@ test("should delete an all-day event using keyboard interaction", async ({
1919

2020
const title = createEventTitle("All-Day Event");
2121
await openAllDayEventFormWithKeyboard(page);
22-
await fillTitleAndSaveWithKeyboard(page, title);
22+
await fillTitleAndSaveEventForm(page, title);
2323
await expectAllDayEventVisible(page, title);
2424
await page.waitForTimeout(1000);
2525

e2e/allday/delete-allday-event-mouse.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
deleteEventWithMouse,
55
expectAllDayEventMissing,
66
expectAllDayEventVisible,
7-
fillTitleAndSaveWithMouse,
7+
fillTitleAndSaveEventForm,
88
openAllDayEventFormWithMouse,
99
openEventForEditingWithMouse,
1010
prepareCalendarPage,
@@ -22,7 +22,7 @@ test("should delete an all-day event using mouse interaction", async ({
2222

2323
const title = createEventTitle("All-Day Event");
2424
await openAllDayEventFormWithMouse(page);
25-
await fillTitleAndSaveWithMouse(page, title);
25+
await fillTitleAndSaveEventForm(page, title);
2626
await expectAllDayEventVisible(page, title);
2727

2828
await openEventForEditingWithMouse(page, title);

e2e/allday/update-allday-event-keyboard.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
createEventTitle,
44
expectAllDayEventMissing,
55
expectAllDayEventVisible,
6-
fillTitleAndSaveWithKeyboard,
6+
fillTitleAndSaveEventForm,
77
openAllDayEventFormWithKeyboard,
88
openEventForEditingWithKeyboard,
99
prepareCalendarPage,
@@ -19,14 +19,14 @@ test("should update an all-day event using keyboard interaction", async ({
1919

2020
const title = createEventTitle("All-Day Event");
2121
await openAllDayEventFormWithKeyboard(page);
22-
await fillTitleAndSaveWithKeyboard(page, title);
22+
await fillTitleAndSaveEventForm(page, title);
2323
await expectAllDayEventVisible(page, title);
2424
await page.waitForTimeout(1000);
2525

2626
await openEventForEditingWithKeyboard(page, title);
2727

2828
const updatedTitle = updateEventTitle("All-Day Event");
29-
await fillTitleAndSaveWithKeyboard(page, updatedTitle);
29+
await fillTitleAndSaveEventForm(page, updatedTitle);
3030

3131
await expectAllDayEventVisible(page, updatedTitle);
3232
await expectAllDayEventMissing(page, title);

e2e/allday/update-allday-event-mouse.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
createEventTitle,
44
expectAllDayEventMissing,
55
expectAllDayEventVisible,
6-
fillTitleAndSaveWithMouse,
6+
fillTitleAndSaveEventForm,
77
openAllDayEventFormWithMouse,
88
openEventForEditingWithMouse,
99
prepareCalendarPage,
@@ -22,13 +22,13 @@ test("should update an all-day event using mouse interaction", async ({
2222

2323
const title = createEventTitle("All-Day Event");
2424
await openAllDayEventFormWithMouse(page);
25-
await fillTitleAndSaveWithMouse(page, title);
25+
await fillTitleAndSaveEventForm(page, title);
2626
await expectAllDayEventVisible(page, title);
2727

2828
await openEventForEditingWithMouse(page, title);
2929

3030
const updatedTitle = updateEventTitle("All-Day Event");
31-
await fillTitleAndSaveWithMouse(page, updatedTitle);
31+
await fillTitleAndSaveEventForm(page, updatedTitle);
3232

3333
await expectAllDayEventVisible(page, updatedTitle);
3434
await expectAllDayEventMissing(page, title);

e2e/someday/create-someday-event-keyboard.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { test } from "@playwright/test";
22
import {
33
createEventTitle,
44
expectSomedayEventVisible,
5-
fillTitleAndSaveWithKeyboard,
5+
fillTitleAndSaveEventForm,
66
openSomedayEventFormWithKeyboard,
77
prepareCalendarPage,
88
} from "../utils/event-test-utils";
@@ -16,7 +16,7 @@ test("should create a someday event using keyboard interaction", async ({
1616

1717
const title = createEventTitle("Someday Event");
1818
await openSomedayEventFormWithKeyboard(page);
19-
await fillTitleAndSaveWithKeyboard(page, title);
19+
await fillTitleAndSaveEventForm(page, title);
2020

2121
await expectSomedayEventVisible(page, title);
2222
});

0 commit comments

Comments
 (0)