Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates task storage from localStorage to IndexedDB to improve consistency with event storage (which already uses IndexedDB per issue #1404). The migration includes a one-time automatic data migration from localStorage to IndexedDB, updates to the task repository layer to use async operations, and comprehensive test coverage including unit tests and end-to-end tests.
Changes:
- Added new IndexedDB storage utilities for task CRUD operations with proper error handling
- Implemented automatic migration from localStorage to IndexedDB on app initialization
- Updated task hooks and repository to use async IndexedDB operations instead of synchronous localStorage
- Added comprehensive test coverage for storage utilities, migration, and e2e task workflows
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 18 comments.
Show a summary per file
| File | Description |
|---|---|
packages/web/src/common/utils/storage/task.storage.util.ts |
New utility functions for task CRUD operations in IndexedDB |
packages/web/src/common/utils/storage/task.storage.util.test.ts |
Comprehensive unit tests for IndexedDB task storage utilities |
packages/web/src/common/utils/storage/task-migration.util.ts |
One-time migration logic from localStorage to IndexedDB with validation |
packages/web/src/common/utils/storage/task-migration.util.test.ts |
Tests for migration scenarios including edge cases and error handling |
packages/web/src/common/utils/storage/compass-local.db.ts |
Added version 2 schema with tasks table to existing Dexie database |
packages/web/src/common/utils/app-init.util.ts |
Integrated task migration into app initialization flow |
packages/web/src/common/utils/app-init.util.test.ts |
Tests for initialization with migration |
packages/web/src/views/Day/hooks/tasks/useTaskEffects.ts |
Converted to async operations with IndexedDB, added race condition guards |
packages/web/src/views/Day/hooks/tasks/useTaskEffects.test.ts |
Updated tests for async behavior |
packages/web/src/views/Day/hooks/tasks/useTaskActions.ts |
Updated task actions to use async IndexedDB operations |
packages/web/src/views/Day/hooks/tasks/useTaskActions.test.ts |
Updated action tests for async behavior |
packages/web/src/common/repositories/task/task.repository.ts |
Changed interface methods to return Promises |
packages/web/src/common/repositories/task/local.task.repository.ts |
Implemented async methods using IndexedDB utilities |
packages/web/src/common/repositories/task/local.task.repository.test.ts |
Updated repository tests for async operations |
e2e/utils/task-test-utils.ts |
New e2e test utilities for task creation and verification |
e2e/tasks/task-persistence.spec.ts |
E2e test verifying task persistence across page reloads |
e2e/tasks/create-task.spec.ts |
E2e test for task creation workflow |
- Introduced new test files for task creation and persistence using Playwright. - Implemented utility functions for preparing the task page, creating tasks, and verifying task visibility. - Updated local task repository to utilize IndexedDB for task storage, enhancing data persistence across page reloads. - Added migration utility to transfer tasks from localStorage to IndexedDB, ensuring data integrity and improved performance. This commit enhances the testing framework for task management, ensuring robust functionality and user experience.
7944405 to
77ca02c
Compare
…or useTaskEffects
…roved error handling and state management
…nd consistency with mocked functions
- Added move method to LocalTaskRepository and TaskRepository interface. - Introduced TaskSessionService to manage task sessions and handle loading, updating, and saving tasks. - Created utility functions for task repository management, including getTaskRepository for selecting local or cloud storage. - Implemented migration logic from local to cloud storage with error handling. - Updated TaskProvider to utilize TaskSessionService for managing task state. - Added tests for task migration and session management functionalities. - Removed obsolete useTaskEffects hook and related tests.
…t and enhance IndexedDB integration
…tion for improved migration handling
…edback - Added loading state handling in TaskList and Tasks components to improve user experience during task loading. - Updated useTaskListInputFocus to prevent focusing on input when tasks are loading. - Enhanced TaskContext to include isLoadingTasks state for better task management. - Modified Tasks component to display loading message and handle empty task states. - Refactored useTaskActions to block actions while tasks are loading. - Implemented tests to ensure loading state is handled correctly and does not interfere with task actions. - Removed obsolete task session service and related tests to streamline task management logic.
…oved task handling
…storage utilities
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 47 out of 47 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (3)
packages/web/src/tests/utils/storage/indexeddb.test.util.ts:9
clearCompassLocalDbresolves immediately ondeleteDatabase(...).onblocked, which can leave the IndexedDB state intact (e.g., if a Dexie connection from a prior test is still open). This can cause cross-test contamination/flakiness. Consider closing the Dexie connection and/or falling back to clearing the relevant object stores when deletion is blocked (similar to the e2e reset helper).
export async function clearCompassLocalDb(): Promise<void> {
await new Promise<void>((resolve) => {
const request = indexedDB.deleteDatabase(COMPASS_LOCAL_DB_NAME);
request.onsuccess = () => resolve();
request.onerror = () => resolve();
request.onblocked = () => resolve();
});
packages/web/src/views/Day/view/DayViewContent.test.tsx:50
- The new
addTasktest helper doesn’t wait for tasks to finish loading before clicking "Create new task" / typing. SinceTaskListnow blocks creating tasks whileisLoadingTasksis true, this can make the tests flaky (input may never appear). Consider reusing the sharedclickCreateTaskButton/addTasks+waitForTaskListReadyhelpers (which already wait for "Loading tasks..." to disappear) or adding an explicit wait here before interacting.
packages/web/src/views/Day/view/DayViewContent.test.tsx:72 beforeEachonly clearslocalStorage, but tasks now persist in IndexedDB. Without also clearing thecompass-localIndexedDB between tests, this suite can leak tasks across tests (especially when running the file in watch mode or when a prior test created tasks). Consider callingclearCompassLocalDb()(or a store-level clear) here as well, similar to other updated task tests.
This commit enhances the testing framework for task management, ensuring robust functionality and user experience.
Closes #1411