diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-12-31 02:23:43 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-12-31 02:23:43 +0900 |
| commit | 907632a6f6fbeee7d2b128303fa8e3893f5e9c0d (patch) | |
| tree | 3a2efbaabf3b1fb4a95af7f2f1569a06a93e15c9 /src/server/repositories/sync.ts | |
| parent | ed93dd099f43dd6746276a72953485de91b49c8c (diff) | |
| download | kioku-907632a6f6fbeee7d2b128303fa8e3893f5e9c0d.tar.gz kioku-907632a6f6fbeee7d2b128303fa8e3893f5e9c0d.tar.zst kioku-907632a6f6fbeee7d2b128303fa8e3893f5e9c0d.zip | |
test(sync): add client-side sync tests for note-related entities
Add comprehensive tests for syncing NoteType, NoteFieldType, Note, and
NoteFieldValue entities in push.test.ts and pull.test.ts. Tests cover:
- Data format conversion between local and server representations
- Applying pulled entities to local IndexedDB
- Pushing pending changes to server
- Updating existing entities during sync
- Syncing all note-related entities together
Also removes unused variable in sync repository.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/server/repositories/sync.ts')
| -rw-r--r-- | src/server/repositories/sync.ts | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/server/repositories/sync.ts b/src/server/repositories/sync.ts index ac9b336..8c4fd25 100644 --- a/src/server/repositories/sync.ts +++ b/src/server/repositories/sync.ts @@ -5,8 +5,8 @@ import { decks, noteFieldTypes, noteFieldValues, - noteTypes, notes, + noteTypes, reviewLogs, } from "../db/schema.js"; import type { @@ -634,9 +634,7 @@ export const syncRepository: SyncRepository = { noteTypeId: noteData.noteTypeId, createdAt: new Date(noteData.createdAt), updatedAt: clientUpdatedAt, - deletedAt: noteData.deletedAt - ? new Date(noteData.deletedAt) - : null, + deletedAt: noteData.deletedAt ? new Date(noteData.deletedAt) : null, syncVersion: 1, }) .returning({ id: notes.id, syncVersion: notes.syncVersion }); @@ -860,10 +858,7 @@ export const syncRepository: SyncRepository = { pulledNotes = noteResults.filter((n) => deckIdList.includes(n.deckId)); } - // Get note IDs for filtering note field values - const noteIdList = pulledNotes.map((n) => n.id); - - // Also get all user's note IDs (not just recently synced ones) for field value filtering + // Get all user's note IDs (not just recently synced ones) for field value filtering let allUserNoteIds: string[] = []; if (deckIdList.length > 0) { const allNotes = await db |
